File tree Expand file tree Collapse file tree
tests/basic/gwbasic/VARPTR_on_undefined_variables Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -515,6 +515,10 @@ def varptr_(self, args):
515515 name = arg0
516516 error .throw_if (not name , error .STX )
517517 indices , = args
518+ name = self .complete_name (name )
519+ if indices != []:
520+ # pre-allocate array elements, but not scalars which instead throw IFC if undefined
521+ self .arrays .check_dim (name , indices )
518522 var_ptr = self .varptr (name , indices )
519523 return self .values .new_integer ().from_int (var_ptr , unsigned = True )
520524
@@ -524,6 +528,7 @@ def varptr_str_(self, args):
524528 error .throw_if (not name , error .STX )
525529 indices = next (args )
526530 list (args )
531+ name = self .complete_name (name )
527532 if indices != []:
528533 # pre-allocate array elements, but not scalars which instead throw IFC if undefined
529534 self .arrays .check_dim (name , indices )
Original file line number Diff line number Diff line change 1+ [pcbasic]
2+ font =default
3+ quit =True
4+ run =TEST.BAS
5+ soft-linefeed =True
Original file line number Diff line number Diff line change 1+ 10 ' test VARPTR and VARPTR$ on undefined variables
2+ 20 OPEN "OUTPUT.TXT" FOR OUTPUT AS 1
3+ 30 ON ERROR GOTO 1000
4+ 100 PRINT #1 , VARPTR (A)
5+ 110 PRINT #1 , VARPTR (B(9 ))
6+ 120 PRINT #1 , VARPTR (C(12 ))
7+ 200 PRINT #1 , VARPTR$ (D)
8+ 210 PRINT #1 , VARPTR$ (E(9 ))
9+ 220 PRINT #1 , VARPTR$ (F(12 ))
10+ 300 CLOSE
11+ 999 END
12+ 1000 PRINT #1 , "error:" err " in " erl
13+ 1010 RESUME NEXT
14+
Original file line number Diff line number Diff line change 1+ error: 5 in 100
2+ 5018
3+ error: 9 in 120
4+ error: 5 in 200
5+
6+ error: 9 in 220
7+
You can’t perform that action at this time.
0 commit comments