ML Variables
Programming Features - ML Variables
The ML Variables are a way for BASIC to get certain information about the BBS environment, as well as to define the way the BBS operates. Thus, you can read the information in these variables, as well as assign values to them.
All ML variables begin with an "!" exclamation point, followed by two digits. They can be used in expressions just like BASIC variables. Assigning a value to an ML variable follows the same format as the POKE command; the format is "!XX,value". The range of possible values for all ML variables is 0 to 255. If the program tries to set an ML variable to a value outside of this range, an error will result. Some variables are READ ONLY, as will be indicated in the following listing. And finally, some variables have multiple elements and are addressed like BASIC arrays, and an error will result if an index outside of the allowable range is used.
Example: 1000 !04,0:.01:!04,13:if!40<5then1000
In the example above, the following occurs:
- Set ML Variable !04 to 0, where !04 is the end-of-line character used when reading in from the disk.
- Perform the .01 command, (reads in a disk line).
- The second !04 then sets the End of Line character back to the normal carriage return character.
- The line then tests !40, which is the number of characters read in during the last disk input, to see if at least 5 characters were read in. If not, then the loop repeats.
The table below summarizes the ML Variables:
| Var | Description |
|---|---|
| !00 | Carrier detect mode.
If this is less than 128, then the regular carrier detect timeout is enabled (i.e. the timeout timer will run). Otherwise, the carrier detect timeout is disabled. See the !11 variable for information on the carrier timeout. |
| !01 | Status variable.
Contains the status after input commands like .00 and .02 (also the @8 function). The values are as follows: 0 = OK, 1 = aborted by CTRL/P, 3 = pause by CTRL/S, 4 = aborted by CTRL/X, and 255 = carrier lost. |
| !02 | General input/output character.
Contains the character returned by commands like the .00 and .07 commands. Any other time, this will contain random data. |
| !03 | Maximum column number for word wrap.
When the user is typing in a line and the cursor goes beyond this column number, a word wrap will engage if word wrap mode is on. A word that is wrapped (up to 15 characters) is placed in a special word wrap buffer and will be "typed in" by the computer at the next input. |
| !04 | End of line character.
The .01 command or the @5 function will read in a line of data until this character is reached, unless the maximum line length is reached, or !15 is set. See also .01 and !15. |
| !05 | Translation mode.
This is used to set the translation mode of the BBS. If it is set to 0, then the current mode is ASCII translation. When in ASCII mode, the system uses the most basic set of characters for input and output and performs the necessary conversion from ASCII to PET ASCII and vice versa. Setting this variable to 1 means Graphics mode (either Commodore or ANSI) will be used. This mode takes advantage of all color and graphics on the system. Setting this variable to 2 means simulated ASCII mode (i.e. if in Graphics mode, any input will be limited to alphabetic, numeric, and common ASCII symbol characters). Setting this variable to 2 will allow you to keep Graphics users from entering color control characters and special graphics. See the !18 variable for information on ANSI mode. |
| !06 | Case constraints on input.
If this is set to a non-zero value, then all alphabetic characters entered (when .02 or @8 is used) will be converted to uppercase. |
| !07 | Word wrap mode.
If this is not zero, word wrap mode is engaged for line input. See !03 |
| !08 | Reserved for future use. |
| !09 | Character output mask.
If not 0, this character will be printed instead of what is typed when inputting a line (the .02 command or the @8 function). This is used when the password is entered (asterisks are printed). |
| !10 | Line feed mode.
This is active only for ASCII translation mode. If this is not zero, then a line feed (ASCII 10) will be printed after each carriage return (ASCII 13). See the !05 variable for information on the translation mode. |
| !11 | Carrier timeout flag.
If this is set to zero, then the carrier detect timeout timer will be on hold. If set to 1, then the timer will count to 255 if carrier is not detected. Since the carrier is checked every 1/60 of a second, a timeout will occur after approximately 4.25 seconds of no carrier. This variable will contain 255 if a timeout has occurred. |
| !12 | Local mode.
Setting this to 1 will disable all modem input and output. This allows the BBS to be used in local mode without characters being sent to the modem. Setting this to 0 allows modem input/output to continue. |
| !13 | Inactivity timeout flag.
If this is not zero, then it means that a timeout occurred because of inactivity on the part of the user. A user gets approximately 2 minutes before a timeout will occur. |
| !14 | File number for disk input.
This used for many disk commands and functions including .01, @5, and .12. |
| !15 | End of line mode.
If this variable is not zero then the disk input routine will ignore the !04 end of line character and will fill the input buffer until the end of the file is reached, or until the maximum number of characters (length of TX$) has been reached. |
| !16 | Seq file abort disable.
If this is not zero, then the next sequential file read (with the .12 command) will not be abortable by either the spacebar or CTRL/P keys. After the file is read, this will be reset to zero. |
| !17 | Number of pager pauser lines.
If this is zero, then the page-pauser will not be active. If not zero, then this value is used during a sequential file read (the .12 command) as the number of lines for the page-pauser. For example, if !17 is set to 15, then the BBS will pause and wait for a character after every 15 lines printed when the .12 command is used. |
| !18 | ANSI mode.
This is only active for Graphics translation mode. If this is set to a non-zero value, then ANSI translation mode is enabled. See the !05 variable for information on the translation mode. When in ANSI mode, the system acts just as if the system is running in Commodore Graphics mode, except that all output is converted to the appropriate ANSI codes. |
| !19 | MCI disable mode.
If this is not zero, then MCI's will be disabled for one line of output. This is always reset to 0 after every output command. |
| !20 | Caller log buffer status flag.
This read-only variable indicates the status of the caller log temporary buffer. If it is zero, then the buffer is empty. If it is 1, then the buffer has some contents in it. If it is greater than 1, then the buffer is full and needs to be dumped to disk. This is for use only be the regular caller log routines. |
| !21 | Variable-killer stack number.
This read-only variable indicates the current level of "nested" variable kills. If no .18 commands are currently in effect, then this will be set to 0. As each .18 command is issued, then this will increase by one. |
| !22 | Network file transfer timeout timer.
When a network file transfer is initiated, this is to be set to 128 plus the number of minutes for the timeout timer. The timer will start as soon as the variable is set. Setting this variable to zero turns off the timer. If the timer runs for the full length of time, then the current file transfer will be aborted. |
| !23 | Non-SwiftLink BPS timer table.
This table of 18 bytes holds the timer values used by the Non-SwiftLink systems when sending and receiving the individual bits of data. There are 6 bytes for each BPS rate (300, 1200, and 2400 respectively), and of the 6 bytes there are 2 bytes each for the output bit time, input bit time, and half-bit time, respectively. Each of the two bytes is a 16-bit value arranged in low byte, high byte order. Thus, the table is as follows: 300 BPS output bit time, 300 BPS input bit time, 300 BPS half-bit time, 1200 BPS output bit time, etc. To access any individual byte of the table, just index !23 like an array (i.e. !23(0) would be byte 0 of the table). |
| !24 | Carrier type.
Holds the value which is compared to the computer's hardware register to see if the carrier is detected. This value is determined by Setup when you set the carrier type. |
| !25 | Carrier status.
This read-only variable will be non-zero if carrier is detected, and zero if there is no carrier. |
| !26 | SwiftLink/Non-SwiftLink flag.
Read-only variable; If this is 0, then the system is a Non-SwiftLink system. If it is 1, then the system is using the SwiftLink cartridge |
| !27 | Term buffer mode.
If this is not zero, then all characters printed to the screen will also be put into the term buffer. The parameters of the buffers are established by the !28, !29, and !30 variables. Output is diverted to file number 3 (normally screen output). This is used by the Plusterm program. |
| !28 | Term buffer pointer.
This is a 16-bit address in low byte, high byte format which points to the next open character in the term buffer. !28(0) is the low byte, and !28(1) is the high byte. This is used by the Plusterm program. |
| !29 | Term buffer bottom pointer.
This is a 16-bit address in low byte, high byte format which is the address of the first byte of the term buffer. This is used by the Plusterm program. |
| !30 | Term buffer top pointer.
This is a 16-bit address in low byte, high byte format which is the address of the last possible byte of the term buffer (i.e. the buffer pointer cannot go beyond this point). This is used by the Plusterm program. |
| !31 | Current BPS rate.
This read-only value in the range 0 to 7 indicates the current BPS rate of computer to modem communication. Possible values are: 0 = 300, 1 = 1200, 2 = 2400, 3 = 4800, 4 = 9600, 5 = 14400, 6 = 19200, 7 = 38400. |
| !32 | Input buffer empty flag.
If this read-only variable is 0, then the modem input buffer is currently empty. Otherwise, there are still characters waiting in the modem input buffer. |
| !33 | X-Modem file conversion mode.
If this is not 0, then the file being transferred will be converted from standard ASCII to PET ASCII. |
| !34 | Number of tries for X-Modem CRC mode.
This sets the number of times that the system will attempt to engage CRC (Cyclical Redundancy Check) at the beginning of an X-Modem file transfer. |
| !35 | Punter block size.
This sets the number of bytes for the Punter file transfer blocks. |
| !36 | File type for transfer.
This value is the file type of the current file transfer. If it is 1 or 3, then the file is a PRG file. If it is 2, then the file is a SEQ file. |
| !37 | Current protocol type.
The current protocols set this read-only value to 0 for Punter, and 1 for X-Modem. |
| !38 | File transfer timeout flag.
If this is not zero at the end of a transfer, then it means a carrier-detect timeout occurred during the transfer. Also, it could mean a Network file transfer timeout. |
| !39 | End of transfer status.
If this is not zero at the end of the transfer, it means the transfer was aborted. |
| !40 | Number of input characters.
For keyboard input (.02 or @8) or disk input (.01 or @5), this value is the number of characters read in during input. |
| !41 | Alternate output file mode.
If this is not zero, then screen output for the BBS is diverted to file number 3 (usually the screen or the printer). Only the regular BBS output commands are affected, so the BASIC PRINT command will not be affected. |
| !42 | Day of the month.
This read-only variable will contain the day of the month calculated from the most recent @16 function. See the @16 function for more information. |
| !43 | Month of year.
This read-only variable will contain the month of the year calculated from the most recent @16 function. See the @16 function for more information. |
| !44 | PM/AM Flag.
When the @11 function is used to get the time, this read-only variable will be 0 if the time is currently AM, otherwise the time is PM. |
| !45 | Current time hour.
When the @11 function is used to get the time, this read-only variable will contain the hour (1 to 12). See the @11 function for more information. |
| !46 | Not used |
| !47 | Character output delay.
This sets the delay between characters to allow slower systems to keep up with the output of Color 64. A value of 0 means no delay, while 255 means maximum delay. |
| !48 | Fast garbage collect mode.
Garbage collection is the term used for the computer's method of managing the memory used by string variables. As each new string is added to memory, it is simply plopped into memory at the next open space. As strings are removed from memory, though, the space they occupied just sits there unused. Because of this the amount of open space for new strings slowly decreases, and the computer will eventually have to "collect" all the garbage strings just sitting in memory. This process can take up to a couple minutes on a system with lots of variables, so this mode was designed to allow an alternative (and faster) routine to be used. Fast garbage collect mode is turned on by setting !48 to a non-zero value. Before executing each command, the computer will automatically check to see how much memory is open for strings. If it drops below 256 bytes, the routine will execute a fast version of the garbage collection routine used by the computer. Garbage collection delays which could have lasted minutes will last only seconds. The fast garbage collect can handle a maximum of 2048 strings, and if there are more the !48 variable will be set back to 0. This is to avoid lengthy delays by having two conflicting garbage collection routines working at the same time. You should have !48 on when using routines that read in a lot of string data (the directory regenerate routine uses this variable). |
| !49 | Boot device numbers.
A read-only table of 3 values, !49(0) to !49(2), which holds the device numbers for the Boot drive, Program drive, and External drive, respectively. See also !50, !51, and the function @30. |
| !50 | Boot drive numbers.
This is a read-only table of 3 values, !50(0) to !50(2), which holds the drive numbers for the Boot drive, Program drive, and External drive, respectively. See also !49, !51, and the function @30. |
| !51 | Disk swapping flag.
This is a read-only flag defined through the boot maker programs when you answer the question for if you need to swap the Program and Boot disks for floppy drive systems. If this is 0, then no disk swapping is necessary, otherwise this will be non-zero. See also !49, !50, and the function @30. |
| !52 | Most recent find location.
This read-only variable will contain the value of the most recent @2 or @25 find function executed. This can be used to avoid having to assign the value of the function to a temporary variable. This will be 0 if you use the find functions to find the actual number of finds, rather than the location of a find. |
| !53 | Flag - 2Mhz during Fast Garbage Collect.
The setting of this variable determines whether the system will attempt to enter 2-megahertz mode on 128 computers when doing the Fast Garbage Collect (FGC) routine. This variable is set in line 150 of the √sys.loadml program when the ML is installed. If it is 1, then the computer will try to use 2Mhz mode when in the FGC routine. This has no effect for C64 users or systems using the TurboMaster CPU, but this feature will automatically be used for C128 users. If you notice that this setting is causing a problem when the system is running, then you may need to change the √sys.loadml program to set this variable to 0. This way, the system will never attempt to enter 2Mhz mode. Also, regardless of the setting of this variable the screen will always be blanked during a FGC. See also the variable !48 for more information on Fast Garbage Collect. |
** Note that there are additional undocumented ML variables in use. See “Undocumented / Unknown ML Variables, Commands and Basic Shortcuts” in the Appendices.
Next Section: ML Functions