Can't pass a fixed string array to a sub.. - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: Can't pass a fixed string array to a sub.. (/thread-6764.html) |
Can't pass a fixed string array to a sub.. - Antoni Gual - 04-04-2005 Can't compile this program It gives an Illegal specification at parameter b in line 2 Code: #define s7 as string*7 If I declare b() as ant, it gives me a Type mismatch in parameter 1 at the line where the call is Can't pass a fixed string array to a sub.. - thegrogen - 04-04-2005 The #define command is a preprossesor thing. That means that whatever is inside the #define will be replaced where its put. Right now, s7 is "as string*7", so with the sub, its declared like this: Code: sub subru (b() as as string*7) Can't pass a fixed string array to a sub.. - dumbledore - 04-05-2005 umm yes you can :wink: that's how to make string fixed-length. such as: dim a as string*7 a="12345678" print a sleep it means that the string can only hold 7 chars. Can't pass a fixed string array to a sub.. - v3cz0r - 04-05-2005 I didn't know QB allowed that, another quirk.. you can't do "foo as string * 123" with byref args but it's allowed by descriptor.. Sorry, but i can't add that, it would need too many hacks, and it's the first time i see that being used. The way around is declaring it as a single field type and passing the UDT array instead by descriptor. Can't pass a fixed string array to a sub.. - SotSvart - 04-05-2005 How does BYREF work? I have look at the FB Keywords Reference, but it says the same as BSAVE.. Can't pass a fixed string array to a sub.. - Antoni Gual - 04-05-2005 v!ctor: I never said QB could do that. Just tried it in FB... Can't pass a fixed string array to a sub.. - v3cz0r - 04-06-2005 But strange enough (at least for me), QB allows that with arrays passed by descriptor.. BYREF is used to declare the mode of function arguments, it's the default one. It means the address of the argument will be passed, not the argument itself, BYVAL should be always used when you don't want explicitly to change the argument inside the function called. |