________________________________________________________________ VPCalc Documentation, Part 2 ________________________________________________________________ @ => Substitute Log file for printer: The @ primitive command will use the last entered comment as a file name and open this file as a text file for echoing screen output as a substitute for the printer. See the W command for the format of file names. See the H command for activating the echo output. If a comment has not been entered, the file name NoName.VPL is used. The VPLOut procedure can be used to give an override file name for the @ command. If the file already exists, output will be appended to it. The start of the file and the start of appended data is identified with "YY/MM/DD HH:MM:SS.SS NewLog ---...---". If the file does not already exist, a new Log file will be created. Each time the @ command is given the selection status of this option is reversed. " => Start/Stop file name or comment: Comments can be entered anywhere on the command line. The comment is started with a " mark. The comment is ended with a " mark or the end of the line. All spaces between the " marks become part of the comment. Comments are also used as file names, see the VPCIn, VPNIn, VPNOut, and VPLOut procedures. The item File: is put on the list by this "" command. % => Set FMB = x, FMB on list: The % primitive command is equivalent to FMB = x, where x is the currently active item. FMB stands for Floating Modulo Base. The / primitive command and the PowM(X' Y) function use FMB from the list. / => x = x Mod FMB, FMB on list: The / primitive command replaces x with x modulo FMB, where x is the currently active item and FMB is an item on the list. If FMB is not on the list, it is added to the list with a value of zero. If FMB is zero, the value of x is not changed. $ => Restart: This reinitializes the program, the same as reloading from disk, except total running time is not reset, the history of previous operator entries is not cleared, the echo to printer or log file state is not changed, and the help menus are not automatically displayed. The parameters set by the D, E, M, T, U, and V commands are reset to their nominal values, and all items on the list are deleted except X and it is cleared. This also reset the random number generator. > => Write configuration: Config.VPC: The file Config.VPC is written to disk. It contains the VPCalc commands that will restore the configuration of VPCalc to its current state. < => Read configuration: Config.VPC: The file Config.VPC is read and run as a VPCalc code file. This will restore the configuration of VPCalc to its configuration when the file was written by the > command. ] => Write entry history: Hist.VPT: The file Hist.VPT is written to disk. This is a text file and contains a copy of the current history of operator entries. [ => Read entry history: Hist.VPT: The file Hist.VPT is read and used to restore the history of operator entries with the history when the file was written by the ] command. The current history is not cleared, but some or all of it may be lost since only 20 entries are saved. F1 => Hot Help: The function keys, F1 through F10, are not true primitive commands. They are meant to be used during the keying in of an input line. Press the F1 key and the following help menu will pop-up: ------------------------------------------------------------------------------ - ---------------------- Help ----------------------- | F1 => This help menu | | F2 => Quit and exit to operating system* | | F3 => Restore previous input* | | F4 => Restore previous input and accept* | | F5 => Active control characters for editing | | F6 => Status | | F7 => Primitive op codes | | F8 => Infix operators | | F9 => Procedures supported | | F10 => Functions supported | | ESC => Exit Help (* active on Command: line) | --------------------------------------------------- ------------------------------------------------------------------------------ - F2 => Quit and exit to operating system: The F2 key will cause the program to exit back to the operating system, but a reprieve message is displayed first. F3 => Restore previous input: The F3 key normally will restore the command line to the value of the previously executed command line. After the B, K, or X command is executed, this key will restore the command line with the learned line. If the learned line changes, when it executes, the previous value of the learned line will be restored by this key. F4 => Restore previous input and accept: The F4 key is the same as F3 except that the previous command is executed without the Enter key being required. F5 => Help with input key control: Press the F5 key and the following message will appear: ------------------------------------------------------------------------------ - The active control characters for editing (^ = Ctrl, BS = Backspace): 0) Down or Up => Retrieve history of previous operator entries 1) ^Right or ^F => Jump to beginning of next word 2) ^Left or ^A => Jump to beginning of previous word 3) Right or ^D => Retype the character at current position 4) Left or ^S => Back up a space and delete if inserting 5) Del or ^G => Delete the character at current position 6) BS or ^H => Delete the character to left of cursor 7) End or ^X => Jump to end of input 8) Home or ^E => Jump to beginning of input 9) ^End or ^Y => Clear input from current position to end 10) ^Home or ^B => Clear input to left of cursor 11) PgDn or ^T => Clear word to right 12) PgUp or ^W => Clear word to left 13) Ins or ^V => Toggle insert mode 14) Enter or ^M => Accept the entire input as is 15) ^Enter or ^J => Accept input, truncate if not at beginning or end 16) F2 => Quit and exit to operating system 17) F3 => Restore previous input 18) F4 => Restore previous input and accept 19) F5 => This menu: Help with input key control >>>> PRESS ESC TO EXIT HELP <<<< ------------------------------------------------------------------------------ - F6 => Status: Press the F6 key and the "Status" message (see PAGE 1) will appear. F7 => Primitive op codes: Press the F7 key and the "Primitive op codes" message (see PAGE 4) will appear. F8 => Infix operators: Press the F8 key and the "Infix operators" message (see PAGE 4) will appear. F9 => Procedures supported: Press the F9 key and the "Procedures supported" message (see PAGE 5) will appear. F10 => Functions supported: Press the F10 key and the "Functions supported" message (see PAGE 5) will appear. ESC => Interrupt a long process, Restore previous value and accept as input or Exit Help: The ESC key is not a true primitive command, it is meant to be used after the program has been asked to perform a task that is taking longer than the operator is willing to wait. If not at the command input line, press the ESC key once and the message *** INTERRUPT: To continue Press RETURN Key; To Abort Computation Press ESCAPE Key; To Set SoftAbort Flag Press SPACE Bar. will appear. If the SPACE bar is pressed, the message SoftAbort flag set by operator! will appear. If instead the ESC key is pressed again, the message Computation aborted by operator! will appear, and if auto display is on, the value of the currently active item will be displayed, followed by the Command: prompt. If the ESC key is pressed during the display of a value, the same messages will appear, but if the second ESC is pressed, the trailing part of the value "E+xxx (xx) [xx]" is still displayed correctly. Pressing ESC twice during execution of the Z command causes all item on the list not yet displayed to be displayed to a small precision. When the SoftAbort flag is set, the variable SoftAbort is put on the list and is set to a value of 1.0. Its purpose is to allow the operator to flag a VP Code file that it should gracefully terminate its operation. During the keying in of an input line the ESC key is the same as F4, the previous command is executed without the Enter key being required. During Help, the ESC key is used to exit Help. Down or Up => Retrieve history of previous operator entries: The history of up to 20 previous operator entries are saved and can be retrieved by using the up and down arrow keys. Press one of these keys and the following help menu will pop-up: ------------------------------------------------------------------------------ - --------- History of Previous Operator Entries --------- | z | |.restore( | |.save( | | run("b | | vpcin( | | b=456 | | c=789 d=321 e=789 f=888 | |.a = (12,345 + 2 * b * (c + d) / Sin(e + f)) ^ 2 | | ] | --> Press ESC, Enter, Up, Down, PgUp, PgDn, Ins, Del <-- ------------------------------------------------------------------------------ - While this menu is up, use the Up, Down, PgUp, and PgDn keys to select a previous entry and then use the Enter key to accept it. The previous entry accepted will be put on the Command: prompt line, and then it can be edited before it is executed. The ESC key will remove the menu without changing the Command: prompt line. The Del key will delete the selected entry. The Ins key will toggle the locked status of an entry. When an entry is locked it cannot be deleted or scrolled of the top of the list. A small square þ will be displayed to the left of a locked entry. At most 18 of up to 20 entries can be locked. This leaves room for at least the last 2 entries from the Command: line. Infix operators - Infix operators +, -, *, /, ^, @, #, %, \, &, |, <, =, >, <=, <>, and >= are the operators that appear between operands in an expres- sion. Infix operators do not change the value of their operands, but produce a single result that can be used to further complete the evaluation of the expression that contains the infix operator. The infix operator precedence classes, from highest to lowest, are: 1) ^ 2) *, /, @, #, %, \, & 3) +, -, | 4) <, =, >, <=, <>, => Operators of the same class are evaluated from left to right. Thus (2 * 10)^2 = 20^2, but 2 * 10^2 = 2 * 100. Also, A + B * C = A + (B * C). A = X + Y => Set A to X plus Y: Addition operator. A = X - Y => Set A to X minus Y: Subtraction operator. A = X * Y => Set A to X times Y: Multiplication operator. A = X / Y => Set A to X divided by Y: Division operator, error if y = 0. A = X ^ Y => Set A to X to the power Y: Exponential operator. This operator operates differently depending on whether Y is an exact integer. If Y is an exact integer, the peasants' method is used in which up to 2 * Log base 2 of Y multiplies of powers of X are done to compute the result. If Y is not an exact integer, the result is computed by Exp(Y * Ln(X)). An error message is generated in three cases: 1) X is < 0 and Y is not an integer. 2) X = 0 and Y is < 0. 3) X = 0 and Y = 0. A = Y @ X => Set A to ATan2(Y over X): ArcTangent of Y over X operator. Used to find the Polar coordi- nates angle coordinate of the Cartesian coordinates (X, Y). If the degree mode is set, the answer, A, will be in the range -180 < A <= 180. If the radian mode is set, the answer will be in the range -Pi < A <= Pi. If both X and Y are zero, an answer of zero will be given. A = X # Y => Set A to Mag(X' Y) = SqRt(Sq(X) + Sq(Y)): Magnitude of (Y, X) operator. Used to find the Polar coordinates radius coordinate of the Cartesian coordinates (X, Y). A = X % Y => Set A to Mod(X' Y) = X Modulo Y: Modulo operator. X % Y = X - (Int(X/Y) * Y). Where Int(X/Y) is the integer part of X/Y. The sign of X % Y is equal to the sign of X. An error message is generated if Y = 0. A = X \ Y => Set A to GCD(X' Y) = Greatest Common Divisor: Greatest common divisor operator. Uses the oldest algorithm in the book, Euclid's algorithm (see Euclid's Elements, Book 7, Proposi- tions 1 and 2). Only the integer parts of X and Y are used in the computation. For example, the GCD of 12 and 18 is 6. A = X & Y => Set A to 1 if X and Y are not 0, else set A to 0: Logical And operator. For all logical operations, 0.0 is consid- ered False and all other values are considered True. When the result of a logical operation is True, the value 1.0 will be produced. When the result of a logical operation is False, the value 0.0 will be produced. A = X | Y => Set A to 1 if X or Y, is not 0, else set A to 0: Logical Or operator. A = X < Y => Set A to 1 if X < Y, else set A to 0: Numerical Less-than operator. For all numerical equivalence operators, the operands are considered as real numbers and the result is either 1.0 (True) or 0.0 (False). A = X = Y => Set A to 1 if X = Y, else set A to 0: Numerical Equal-to operator. A = X > Y => Set A to 1 if X > Y, else set A to 0: Numerical Greater-than operator. A = X <= Y => Set A to 1 if X <= Y, else set A to 0: Numerical Less-than-or-equal-to operator. A = X <> Y => Set A to 1 if X <> Y, else set A to 0: Numerical Not-equal-to operator. A = X >= Y => Set A to 1 if X >= Y, else set A to 0: Numerical Greater-than-or-equal-to operator. Procedures - Procedures are invoked by a statement starting with a procedure name followed by its argument. Arguments are numerical expressions that are evaluated before the procedure is performed. Procedures do not change the value of their arguments. For the procedures Write and WriteLn, arguments are optional and may be literal like: WriteLn("Now is the time"). For the procedure Next, arguments are not allowed. AutoDisplay(X) => Set Auto display on if X <> 0, else off: Same as the A primitive op code, but instead of being a toggle, sets Auto display on if X <> 0, and sets it off if X = 0. ClearHist => Clear history of previous operator entries: The history of up to 20 previous operator entries are saved and can be retrieved by using the up and down arrow keys. The ClearHist procedure removes all operator entries currently saved and makes this memory available to the calculator. Even though no argument is needed for this and some other procedures, it is usually better to use the parentheses, e.g., ClearHist() or ClearHist( to prevent unexpected results if the procedure name is misspelled. Diag(X) => Set diagnostic mode on or off: The diagnostic mode is turned on if X <> 0 and is turned off if X = 0. When the diagnostic mode is on, all command line executions will be timed by the computer clock and the time spent executing the command will be displayed. The timing data is displayed as: T = xxx.xx DT = x.xx sec. Start execution . . . T = xxx.xx DT = xx.xx sec. End of execution The DT value on the End of execution line is the time spent executing the command. The DT on the Start execution line is the time spent waiting for the operator to compose the command line. The T values are the total running time since the program was started and can only be reset by terminating and reentering the program from DOS. EchoScreen(X) => Echo screen to printer/Log file, on or off: Same as the H primitive op code, but instead of being a toggle, sets Echo screen to printer/Log file on if X <> 0, and sets it off if X = 0. InputLines(X) => Set number of input lines (1, 2, 3, or 4): Sets the number of lines in the command input field to X. This allows control of the length of the input field to 70, 150, 230, or 250 characters. The integer part of X is used, X larger than 4 implies 4, smaller than 1 implies 1. The length of the input field will always be large enough to hold the previous command line for the F3 function. LogFile(X) => Substitute Log file for printer, on or off: Same as the @ primitive op code, but instead of being a toggle, sets Substitute Log file for printer on if X <> 0, and sets it off if X = 0. LX => LT => Restore LastTop to top of the list: This sets the current active item equal to the value of the item named LastTop. If LastTop does not exist, it is created with a value of zero. Normally, before each command line is executed the value of the current active item is saved on the list in an item named LastTop. If a command line is entered that changes the value of the current active item, it can be restored to its previous value if the LX or LT procedure is performed immediately. This procedure should be entered on a command line by its self to prevent LastTop from being changed before it is retrieved. The value of the current active item, Top, is not saved in LastTop if: 1) The command line is: LX 2) The command line is: LT 3) The command line is: LastTop= 4) The command line is: empty, i.e, only 5) The SaveTop option is turned off by SaveTop(0). Next => Move to next item on the list (no argument): This changes which item on the list is the active item from the current active item to the next item from top to bottom. If X is the active item, which is always at the bottom of the list, the top item will become the active item. A command line with the single command Next followed by several F4 function keys will move through the whole list one item at a time. Note, this procedure does not take an argument. ReadN(F) => Read file F = "ccc...c", F is optional: This will use the argument F = "ccc...c" as a file name and read this file as a VPCalc formatted number and assign it to the item with the name stored in the file. This is the name it had when it was written. It is assumed that the file was created by the W command or the WriteN(F) procedure. See the W command for the format of file names. If no argument is given, and a comment has not been entered, the file name NoName.VPN is used. As files are input, the most significant bit of each byte read is set to zero to allow the files to be created or modified by a text editor that uses these upper bits as flag bits. The ReadN proc differs from the J command in that the J command does not use the name stored in the file, but assigns the value read to the current active item. The ReadN command will not change the current active item unless an = sign is not found in the file or the name found is the same as the current active item. Restore/Save => Restore or Save Configuration, History, & List: Save will write the entry history file Hist.VPT like the ] command, write the configuration file Config.VPC like the > command, write each items on the list to a separate file (Save0000.VPN, Save0001.- VPN, ...), and write a VPCalc code file Restore.VPN that can be run by VPCalc to restore all of the saved items. Restore will read the entry history file Hist.VPT like the [ command, read the configuration file Config.VPC like the < command, and run the Restore.VPN restore file to read in each items that was on the list at save time. Restore does not clear the entry history or the list before it executes, so they may grow larger than they were at save time. Run(F) => Run VPCalc code from file F, F is optional This will use the argument F = "ccc...c" as a file name and read and run this file as a VPCalc code file. If no argument is given, defaults are like ReadN(F). To see examples of how VPCalc primitives, procedures, and functions are used, inspect the ---.VPC files (type or print). It will be noted that they are in plain DOS text. SaveTop(X) => Set "save top value in LastTop" on or off: This sets the "save top value in LastTop" option on if X <> 0, and sets it off if X = 0. ScientificN(X) => Force scientific notation on iff X <> 0: Normally numbers with less than 14 significant digits to the left and less than 14 to the right of the decimal point are displayed in fixed notation (e.g., 12.34). If the ScientificN(X) procedure is executed with X <> 0, all numbers will be displayed in scientific notation (e.g. 1.234 E+1 [14]). The normal method is restored after the ScientificN(X) procedure is executed with X = 0. SetD(X) => Set max decimal digits in display: The SetD(X) procedure sets the maximum number of decimal digits to display to the evaluated value of X. If this is set larger than the number of digits set by the M command minus the number of digits set by the T command, the smaller value will be used to determine the number of digits to display. This maximum only applies when the display is in scientific notation. The values set by the M and T commands are always carried as a multiple of seven (7), but the value set by the SetD(X) procedure can be any integer >= two (2). If this maximum is in effect, the last digit will not be rounded. SetMax(X) => Set max decimal digits allowed in mantissa: The SetMax(X) procedure sets the max decimal digits allowed in the mantissa of any value to the evaluated value of X. If X is not a multiple of 7, then the next higher multiple of 7 is used. VPCIn(F) => Enter file name F = "ccc...c" for J command: This establishes the file name of the VPCalc code file that will be read by the next J command. If the ("") is missing, the file name input with the last " comment command will be used. VPLOut(F) => Enter file name F = "ccc...c" for @ command: This establishes the file name of the VPCalc log file that will be opened by the next @ command that opens a file. If the ("") is missing, the file name input with the last " comment command will be used. VPNIn(F) => Enter file name F = "ccc...c" for I command: This establishes the file name of the VPCalc number file that will be read by the next I command. If the ("") is missing, the file name input with the last " comment command will be used. VPNOut(F) => Enter file name F = "ccc...c" for W command: This establishes the file name of the VPCalc number file that will be written by the next W command. If the ("") is missing, the file name input with the last " comment command will be used. Write(X) => Output X, (X may be "ccc...c", X is optional): The Write(X) procedure outputs the evaluated value of X to the console. The H and @ commands and the EchoScreen(X) and LogFile(X) procedures can be used to echo this output to the printer or the Log file. WriteLn(X) => Write(X) and a line feed: The WriteLn(X) procedure is the same as the Write(X) procedure except that the output generated is followed by an end-of-line indicator. WriteN(F) => Write X to file F = "ccc...c", F is optional): This will use the argument F = "ccc...c" as a file name and write the current active item as a VPCalc formatted number exactly like the W command. See the W command for the format of file names. If no argument is given, and a comment has not been entered, the file name NoName.VPN is used.