openconsole
DEF hFILE01 AS BFILE
uint bcount
OPENFILE(hFILE01,"sample.txt","R")
bcount=len(hfile01)
' def bigstring[2000] as istring ' works OK.
def bigstring[bcount] as istring
' line above throws an error
' (7) duplicate definition of variable or label - istring
' can't see why ???
DO
'.......
'.......
UNTIL EOF(hFILE01)
DO:UNTIL INKEY$ <> ""
closefile hFILE01
closeconsole
end
When the program is compiled, the time when the array is created, bcount has no value. You must use a literal or a constant. Arrays cannot be dimensioned at run time.
@Peaslee,
Thankyou for your quick reply, I fully understand what you have said. Can you suggest a method therefore that can pass the bcount to the string, or do I need to be looking at the NEW directive or something.
Regards
Dave.
Use NEW.
pointer pBigString
pBigString = NEW(CHAR, bcount)
#<string>pBigString = "whatever"
'when done with the big string just delete it
DELETE pBigString
Paul.
@paul
Thanks very much, Peaslee obviously pushed my thinking in the right direction (for a change)ÂÃ, ;D
Regards
Dave