To return the address in memory of the variable or file control block (FCB).
VARPTR is usually used to obtain the address of a variable or array so it can be passed to an assembly language subroutine. A function call of the following form:
is usually specified when passing an array, so that the lowest-addressed element of the array is returned.
All simple variables should be assigned before calling VARPTR for an array, because the addresses of the arrays change whenever a new simple variable is assigned.
VARPTR (#file number) returns the starting address of the GW-BASIC File Control Block assigned to file number.
VARPTR (variable name) returns the address of the first byte of data identified with the variable name.
A value must be assigned to variable name prior to execution of VARPTR, otherwise, an "Illegal function call" error results.
Any type variable name may be used (numeric, string, or array), and the address returned will be an integer within the range of 32767 to -32768. If a negative address is returned, it is added to 65536 to obtain the actual address.
Offsets to information in the FCB from the address returned by VARPTR are shown in the following table:
Offsets to FCB Information
The mode in which the file was opened: 1 Input only 2 Output only 4 Random I/O 16 Append only 32 Internal use 64 Future use 128 Internal use
Diskette file control block.
Number of sectors read or written for sequential access. The last record number +1 read or written for random files.
All Frank Sinatra recordings, All Beatles albums, All solo albums from John Lennon, Paul McCartney, George Harrison and Ringo Starr, All Beatles songs, List of Platinum selling albums, Database with hits from 1950 to 1999.
Sought after DLL files, Nutworks magazine (retro), Worldwide ISO and TLD codes, File extensions database, The Hackers dictionary, Free software for the Atari, Amiga and Macintosh, Nokia smartphone, PocketPC, List of all BASIC programming language commands, List of all DOS commands, Free Advanced Bash-Scripting Guide (Linux-Unix)