Suss out the symbols Trouble with your variables? Jonathan Harston shows how to list the little varmints. When debugging a program you often want to know the names of all the variables that have been created. Not only does it give you a clue as to where an error may be, it also shows if you've accidently invented a variable with a typing error. Well, VLIST will give you that useful list of variables. Type in the listing and check it with Get it Right! and then save it using any name except VLIST. When run, it generates the code for the routine which is saved by copying the command line printed at the end of the program. You can issue the command by entering: *VLIST or, if you are using tape: */VLIST The program won't work if you are using a second processor and gives the error TUBE if you are. Otherwise, all the currently defined variables will be listed. Due to the way the variables are stored, they will be listed alphabetically by the first letter. Real variables are just listed by name, aligned into columns 10 characters wide. Integer variables will have their hexidecimal value printed. Strings will be displayed as a string of characters with CHR$(&nn) for characters less than 32 and greater than 126. Arrays of any kind are displayed showing the dimension sizes - as in the DIM command. How it works Variables are stored as linked lists - which means that each block of data about a variable also contains a pointer to the start of the next block. There's one list for each letter of the alphabet, upper case and lower case. Pointers to the start of the lists are stored in page 4, from &482 to &4F4, with a pointer to PROC nmes at &4F6 and one to FNs at &4F8. PROC and FN names are stored the first time they are called, along with thier address in memory. Each block of data consists of the following: Offset Meaning 0 to 1 Address of next entry, or zero if at the end of the list 2 to n The variable name not including the initial first letter, but including any $, % or (. n+1 zero byte, end of name marker. n+2 to n+2+m Data of the variable. The program goes through a loop following all the lists of the variables until an end of list marker is found. As each variable entry is found, the name is printed out, preceded by the starting character, until a non-alphanumeric character is found. Depending on this final character, the program decides what data to print out. Real variables just have their name and enogh spaces printed to move to the next column of 10. This part also deals with printing the names of functions and procedures. For integer variables, first there's a check to see if this is an integer array. If not, the value ifs printed out in hexidecimal. For arrays, the dimensions are printed out in hexadecimal. There wasn't enough room to squeeze in a decimal printout routine here and still fir the program in the CFS buffer, so hexadecimal was used instead. For strings, there is a first check to see if it is an array. Otherwise, a loop goes through the string, sending each character to the pr_char routine which does some checking to decide how to print out the character. If the character is printable and the last one was also it is just output. Otherwsie a plus sign and a quote are printed before the character itself. If it's a control code or over 126 the routine prints +CHR$(&nn) where nn is the hexadecimal code of the character. In this case, if the previous character was a printable character, it first does a closing quote. In all, the string is displayed exactly as you could type it in from Basic. AA$="VLIST" BLUE$=CHR$(&84)+CHR$(&9D)+CHR$(&85) FILE$="(UnTitled)" FD$="DATA" HILIMIT LOLIMIT TIT$="DATA BASE" T$="" ZZ datastart end field$(&0014) fsize(&0014) fsflag mult pnt p%=&00000000 recflg rectot%=&00000000 start PROC_TITLE PROC_LINE PROC_OSC FN_YN Sample output after using *VLIST Micro User, July 1990