Multi-slot question
Root / Programming Questions / [.]
MinxrodCreated:
Yes, it does work with arrays.
VAR("2:mySlot2Arr")[0]=42
Is this a secret command?
Wow, this is awesome!!! VAR is the best command ever! (the only way to access the hidden "variable name" type) SB actually has 5 variable types: integer% double# string$ array[] VAR("variable")I disagree - VAR is not a variable type, instead, it's a method that returns a variable - and the variable is always one of the other types. And for the record, the types are: integer% double# (are you sure it's double and not single-precision float?) string$ intarray%[] dblarray#[] strarray$[] :D
Arrays technically aren't types, you could consider them pointers or data structures. A string is technically a type since you can have an array of them. VAR ain't.
And yeah, they are doubles according to the specs.
Data Type (#) Double-precision Real Data Type (variables ending with #)
Pointers and data structures are types.
I like to think that there's:
CHARACTER_ARRAY$ (or STRING$)
CHARACTER_ARRAY_ARRAY$[] (or STRING_ARRAY$[])
INTEGER%
INTEGER_ARRAY%[]
REAL#
REAL_ARRAY#[]
Note that if a type isn't specified, it is assumed real unless you have OPTION DEFINT running, in which case it is assumed integer.
Also, you can apparently do:
DIM S$[1] S$[0]=" " ?S$[0][0]
I like to think that there's: CHARACTER_ARRAY$ (or STRING$) CHARACTER_ARRAY_ARRAY$[] (or STRING_ARRAY$[]) INTEGER% INTEGER_ARRAY%[] REAL# REAL_ARRAY#[] Note that if a type isn't specified, it is assumed real unless you have OPTION DEFINT running, in which case it is assumed integer. Also, you can apparently do:Exactly! ^_^ (this is exactly what I said, you just worded it better)DIM S$[1] S$[0]=" " ?S$[0][0]
Is it possible to access DATA declared in different slots, or would it need to be READ to an array in said slot?When you specify DATA SB keeps it in a central location until the next READ instruction, so yes it's accessible. EDIT: This post was about a different programming language. Changed it to be SmileBasic.
Can't you RESTORE data in other slots, by doing RESTORE "1:@..." or can you not do that with RESTORE and DATA?
Can't you RESTORE data in other slots, by doing RESTORE "1:@..." or can you not do that with RESTORE and DATA?
PRG0 ---- USE 1 VAR A,B,C RESTORE "1:@TEST" READ A,B,C ?A ?B ?Cand
PRG1 ---- @TEST DATA 1,2,3,4,42EDIT: I herp derped pretty baldly. I think I unherped. I apologize for any derps.