December 11, 2024, 10:35:07 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Newbie Question

Started by dippy46, December 22, 2006, 03:06:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dippy46

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

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

dippy46

@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.

Ionic Wind Support Team

Use NEW.

pointer pBigString
pBigString = NEW(CHAR, bcount)
#<string>pBigString = "whatever"

'when done with the big string just delete it
DELETE pBigString

Paul.
Ionic Wind Support Team

dippy46

@paul

Thanks very much, Peaslee obviously pushed my thinking in the right direction (for a change)ÂÃ,  ;D

Regards

Dave