| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
POINTER ( variable )
Finds the address in RAM where a variable is stored.
The POINTER function finds the given variable in RAM and returns the address of its data. The returned address does not point to the leading bytes which name the variable (or for arrays, that give the dimensions). It useful to pass the address of a variable to an ML program so it does not need to search for it, and also your BASIC code won't need to convert the value inside the variable into high and low bytes. POINTER is also useful for loading/saving variable data to a file or REU. POINTER does not return the bank where the variable is stored. On the C128, this is always in BANK 1. On the Plus/4, it doesn't matter; there is only one bank as far as BASIC is concerned (need to verify this!). If you are religous about defining all variables before any are used, you can even assign the value of POINTER to another variable. Then you can pass that variable to your ML program or use it to load/save the data. This is dangerous with arrays because whenever you create a scalar (non-array) variable, all they arrays get moved around in memory. POINTER is less useful with strings. The address returned will point to the string descriptor. The descriptor tells the length of the string and is followed by another two bytes (also called a pointer) which tell where the actual characters of the string can be found. Also, string data gets shuffled around when BASIC performs garbage collection or the string is assigned a new value. POINTER does not work at all with user-functions (see DEF). For arrays, you must specify an element in the array. If you want to load/save an entire array, use the first ("zeroth") element. See examples. If the variable does not exist, or is a reserved variable, POINTER returns zero. If you omit variable, supply a literal value, or user-function name, then SYNTAX ERROR is generated. Examples:
© H2Obsession, 2014 |