Varsort 2

by C. L. Stone

 

 

Issue 12

Nov/Dec 84

Next Article >>

<< Prev Article

 

 

... a utility for indexing variables

This is the second of two Variable utility programs. The first VARSORT1 which you will need to use this program appeared in issue 11.

This is a program which takes the sorted variables put to disc by VARSORT1, allows you to add a 30 letter description of their use and then print them to screen, paper or disc.

A description of the program follows:

 

GET THE VARIABLES

 

Line 100 begins by dimensioning the string variables used in this program. 'AN' is then made equal to 10 (this is the length of the individual variable strings within the long string). The screen is made full width, and a channel opened for input from the keyboard. 

Line 110 assigns various well used routines to variable names.

Line 120 assigns variables to the colours used. The numbers used are the numbers to be POKEd into the registers.

Line 1000 sets the Graphics mode to 0, clears the cursor, POKES in the colours, sets a TRAP sending the program to the MENU on detecting any fault and empties A$. 

Line 1010 sets D$ to equal "D: XXX.DAT", sets the print position and prints the heading Title and underlines it. 

Line 1015 begins by a precautionary closing of channel 1, opens channel 1 for input from the above program and prints a couple of messages on screen.

Line 1020 waits for an input from the keyboard, this will be contained in 'A'. 'A' is checked and if 155 (RETURN) then the program goes on to line 1035.

Line 1025 adds the character represented by the ATASCII number in 'A' to A$.

Line 1030 sends the program back to line 1020 for another character.

Line 1035 - when RETURN was detected in line 1020 it signified that the file had been fully loaded and this line then closes the channel.

Line 1040 clears the cursor, clears the screen, prints the heading title and draws a line. 

Line 1045 makes 'COUNT' equal to the length of A$ divided by the length of the individual string as represented by 'AN'. 'LI' (the screen line number) is set to 5, 'PO1' (the screen print position) is set to zero, 'COL' (the screen column number) is set to 1.

Line 1046 starts a loop `A' running from 1 to `COUNT'. 'PO' (representing the position of the individual variable string within the long string, changed on each pass - of course) is set to equal the pass through the loop times the length of the individual variable string.

Line 1047 sets the screen print position, prints the variable and adds 1 to the line counter.

Line 1048 checks 'LI', if 17 then 'COL' is checked, if 1 then 'LI' is reset to equal 5, 'COL' to equal 2, 'PO1' to equal 14 and the program sent to line 1060. 

Line 1050 checks 'LI', if 17 then 'COL' is checked, if 2 then 'LI' is reset to equal 5,'COL' to equal 3, 'PO1' to equal 28 and the program sent to line 1060.

Line 1055 checks 'LI', if 17 then 'COL' is checked, if 3 then 'LI' is reset to equal 5, 'COL' to equal 1, 'PO1' to equal zero and the program sent to line 1072.

Line 1060 sends you back for another pass through the loop. When the loop is finished and the variables are printed on screen in three columns, the program passes on to line 1074.

Line 1072 prints a message at the bottom of the screen asking you to Press any Key for another page - this occurs only when the screen is full - pressing any key clears the screen and Line 1073 sends you back for another pass through the loop and so prints more variables. 

Line 1074 - when all variables are printed this line prints the total number and the length of the containing string.

Line 1075 prints a message at the bottom of the screen and goes to the Menu.

 

ADD DESCRIPTIONS

 

Line 2500 sets the graphics mode to 0, so clearing the screen in the process, POKEs the colours for this section, clears the cursor, empties B$.

Line 2505 establishes the title for this section, centres, it prints it, skips a line and draws a line.

Line 2510 starts a loop 'L' running from 1 to the length of A$ divided by the length of the individual string ('AN'), establishes 'PO' to represent the position of each individual string within the long string (A$), 'PL' to equal the position of the Individual String (composed of both variable and description) within 'B$'. The BREAK key is then disabled. 

Line 2515 causes the variable (and its number in the list) to be printed at roughly a third down the screen. 

Lines 2520 to 2525 ask you to enter a description of the variable on the screen.

Line 2530 prints a line of 30 dots and then takes the print position back to one space before the first dot and then asks for an input, which will be held in E$.

Line 2535 makes F$ equal to the variable at present on screen. E$ is added on to the end of F$ and E$ is emptied.

Line 2540 clears the screen and then prints near the top the contents of F$, At the bottom of the screen you are asked if an alteration is needed. 'N' would send you on to line 2545, but any other key will send you to line 2543 which clears F$ and sends you back to line 2515 to have another go.

Line 2545 makes B$ (at the position defined by variable 'PL') equal to F$ and then goes back for another pass through the loop. This continues until the loop is finished and all the variables now have a description tagged on to the end and are all placed in the long string (B$). The program then goes to the 'Press any Key for Menu' subroutine.

 

MENU

 

Line 3000 sets the Graphics mode to 0, POKEs the colours for this section, dears the cursor, establishes the title for this section, centres it, prints it, skips a line and draws a line.

Line 3002 sets 'AN' to equal 10, 'BN' to equal 40 and places the print position at the start of the sixth line. 

Lines 3005 to 3030 print the items on the Menu. The positions of these lines, after the initial POS. instruction is controlled by the first two characters in each line being an Escape-Tab and an Escape-Shift-Down Arrow. 

Line 3035 skips a line and draws a line and then asks for you to input the number of your choice.

Line 3040 awaits an input just the press of a key. 

Line 3045 makes this input (by deducting 48) equal the numbers shown, if they don't match then the program simply goes back to the start of the MENU. 

Line 3050 sends the program to the line number as contained in 'D'.

 

PRINT ON SCREEN

 

Line 4000 sets the Graphics mode to 0, POKEs the colours, clears the cursor, prints the heading and draws a line.

Line 4005 sets 'COUNT' to equal the length of B$ divided by 'BN' (i.e., the number of variables and descriptions) and sets 'LI' to 5.

Line 4010 starts a loop 'A' running from 1 to 'COUNT', makes 'PO' equal to 'A' times 'BN.

Line 4015 sets the print position, prints the variables plus their descriptions (as defined by 'PO') and adds 1 to 'LI'.

Line 4020 checks 'LP, if 19 then 'LP is reset to 5, a message printed at the bottom of the screen - Press any Key. Upon doing so the screen clears and line 4025 sends the program back for another pass through the loop. 

Line 4030 - when the loop is done and the variables all printed you are asked to press any key for the Menu.

 

PRINT OUT?

 

Line 5000 sets a TRAP for line 5005, prints (on the MENU and above the item Printer) a request to input the title that you wish the printed copy to bear. The program then skips line 5005.

Line 5005 is the error line, requesting you to check the printer. and then sends the program back to the start of the MENU section.

Line 5010 asks you to Please Wait. The title is then printed to paper.

Line 5015 starts a loop 'A' and 'PO' is again set

Line 5020 then prints the variable, a gap, and then the description to paper.

Line 5025 goes back for another pass through loop 'A'

Linu 5030 rings the Bell and then goes back to the Menu.

Line 6000 sets a TRAP to go to MENU. As in the print section. a request is printed above the item 'Disc' on the Menu asking you to enter the Filename under which you wish to save to disc. This input is held in DD$.

 

FILENAME SUBROUTINE

 

Line 6005 sets D$ to equal D then DD$ is added to that The filename is then checked and if found to have two D:'s or a number where a letter should be the program will return to the Menu.

Line 6010 asks you to Please Wait, rings a bell, opens a channel to write to disk using the filename you have input, prints the data to disk, closes the channel, rings the bell and returns to the Menu.

 

SCREEN DISPLAY SUBROUTINE

 

Line 10000 creates a loop `B' which prints a blank line from line 22 to line 5 and then returns. 

Line 10020 is the 'Press any key for Menu' routine, which it prints at the bottom of the screen, waits for an input, pauses and returns.

Line 10040 prints a line of asterisks and returns. 

Line 10090 prints a blank line and returns.

Line 10100 prints, at the bottom of the screen, a 'Please Wait' message and then returns.

These two programs are very useful for sending in programs to magazines as readers find descriptions of variables used to be helpful. Also I hope that the utilities will enable you to analyse your own programs and maybe improve your programming techniques.

 

AtariLister - requires Java

top