| 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 |
Note the 'token' is really the character codes of the keyword.
ST
Get I/O status byte.
This reserved variable returns the KERNAL's I/O status byte corresponding to the last (non-screen, non-keyboard) communication (such as CMD, GET#, INPUT#, OPEN, or PRINT#). The meaning is a device-specific combination of bit values (see table below), but it is important to note that for RS-232 devices, the ST value will be zeroed once it is accessed; in other words you should save ST in a user variable if you want to perform multiple operatons on the value (like test multiple bits seperately and/or print the value). In general, any non-zero value means some kind of "error" or other special condition has been detected (like "end of file"). Also note the "real" deviceStatus maintained by the KERNAL is just a byte with value 0 to 255, but when reading ST, BASIC will interpret this as a signed byte for some obscure reason... This means if the the (unsigned) byte has a value of 128 or more (i.e., bit 7 is set), ST will report a deviceStatus of -128 to -1. Due to the way signed bytes work, you can easily convert ST into an unsigned value of 0 to 255 with (for example) S = ST AND 255 (be sure you have at least one space between ST and AND or BASIC will parse it as S = S TAN D 255 causing a SYNTAX ERROR). Note bit values listed as '128' will by default be -128, but if you convert deviceStatus into an unsigned number it will be +128.
Unfortunately, the ST variable does not tell you when the RS-232 transmit buffer is empty! It does tell you when the receive buffer is empty, but this usually isn't very important because BASIC GET# will simply fetch an empty string if it is. In order to know if the transmit buffer is empty (so you can safely CLOSE a "file" without loosing data), you need to test if bit 0 of the secret variable "enable" is clear [i.e., test ( value AND 1 ) = 0]. Here is the location of that secret variable for some machines:
Like all BASIC variables, only the first two characters of the name are significant. So you may also use (and early documentation shows) STATUS if you prefer (note the "ATUS" characters are superfluous). Like most BASIC reserved variables, attempting to assign a value to it or supply an argument will generate SYNTAX ERROR. Example (for cassette):
Example (for disk):
Example for RS-232 on C64:
© H2Obsession, 2014 |