LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Reading any type of DATA (SB3)

Root / Submissions / [.]

12Me21Created:
Normally you need to know what type the data is (string vs int vs float) before using READ, but if the variable you use is untyped, its type will change to the type of the data. There are basically 2 ways to get untyped vars:
DEF TEST OUT X
 'OUT variables start as untyped
 READ X
END
or
IF 0 THEN DIM A[0] 'arrays are untyped until the DIM is executed, and if it's skipped, the var stays untyped
READ A
So you can easily make a function that reads any type of data:
DEF READ_ANY OUT IS_STRING,NUM,STR
 IF 0 THEN DIM A[0]
 READ A
 IF (A||0)==3 THEN 'Bug: || returns 3 when first arg is a string (a safer way to check might be (A*0 && A*0==A*0) or something
  STR=A:NUM=0:IS_STRING=#TRUE
 ELSE
  NUM=A:STR="":IS_STRING=#FALSE
 ENDIF
END

Oh, that boolean returning 3? ""==var==3... cool

interesting