Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sub and variables.... where must they be declared....
#1
If you have two or more sub functions that use the same variable, where must i declare that variable...

Imagine the sub doA reads a file and give a valor to a variable called X, then in the suB we use the X variable, if I declare the X variable at the beginning of the program it gives an error, if I declare the X variable in every sub function with dim X, it erase the X valor.....

Sorry if this question is silly, but I am starting using sub functions...

thanks.
Reply
#2
It seems to me that you want a global variable. This is performed using a DIM SHARED i.e.

Code:
DECLARE SUB READINA
DECLARE SUB PRINTA
DIM SHARED A$

READINA
PRINTA

SUB READINA
  A$="Hello World"
END SUB

SUB PRINTA
  PRINT A$
END SUB
his sig left intentionally blank
Reply
#3
Thanks, I'll try it, but I think this is I am looking for.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)