Posts: 1,407
Threads: 117
Joined: Dec 2002
Can't compile this program
It gives an Illegal specification at parameter b in line 2
Code:
#define s7 as string*7
declare sub subru (b() as s7)
dim as s7 a(1)
a(1)="10000 "
subru a()
sleep
sub subru (b() as s7)
print b(1)
end sub
If I declare b() as ant, it gives me a Type mismatch in parameter 1 at the
line where the call is
Antoni
Posts: 320
Threads: 24
Joined: Feb 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)
Plus you can't multiply strings by a number. Actually, you cant multiply strings at all.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Posts: 489
Threads: 34
Joined: Jan 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.
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 922
Threads: 15
Joined: Jun 2003
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.
Posts: 61
Threads: 6
Joined: Jan 2005
How does BYREF work? I have look at the FB Keywords Reference, but it says the same as BSAVE..
Posts: 1,407
Threads: 117
Joined: Dec 2002
v!ctor: I never said QB could do that. Just tried it in FB...
Antoni
Posts: 922
Threads: 15
Joined: Jun 2003
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.