| home
| contents
| previous
| next page
| send comment
| send link
| add bookmark |
TH.CPP
on-line help
/*-------------------------------------------------------------------*
T help reference program
File: th.cpp
Usage: th [nosave]
by: Stephen R. Schmitt
*-------------------------------------------------------------------*/
#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <string.h>
#define LEFT 3
#define TOP 3
#define RIGHT 78
#define BOTTOM 24
typedef enum
{
false = 0,
true = 1
}
boolean;
union scancode
{
int ch;
char c[2];
};
/*-------------------------------------------------------------------*
Data Section
*-------------------------------------------------------------------*/
char *Message[] = {
"abs standard function",
"",
"usage: abs( <expn> : int|real ) : int|real",
"",
"remarks: Function returns the absolute value of <expn>.",
" The return type has same type as <expn>.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"and keyword",
"",
"usage: <boolean expn> and <boolean expn>",
"",
"remarks: Operator returns a boolean value:",
"",
" x y x and y",
"",
" false false false",
" false true false",
" true false false",
" true true true",
"",
"",
"",
"",
"arccos standard function",
"",
"usage: arccos( <expn> : real ) : real",
"",
"remarks: Function returns the real arc cosine of <expn>",
" in units of radians. The value of <expn> must",
" be in the range -1.0 to +1.0 or a run-time",
" error will occur. ",
"",
"",
"",
"",
"",
"",
"",
"",
"arcsin standard function",
"",
"usage: arcsin( <expn> : real ) : real",
"",
"remarks: Function returns the real arc sine of <expn>",
" in units of radians. The value of <expn> must",
" be in the range -1.0 to +1.0 or a run-time",
" error will occur. ",
"",
"",
"",
"",
"",
"",
"",
"",
"arctan standard function",
"",
"usage: arctan( <expn> : real ) : real",
"",
"remarks: Function returns the real arc tangent of <expn>",
" in units of radians in the range of",
" -pi/2 to pi/2.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"arctanxy standard function",
"",
"usage: arctanxy( <x> : real, <y> : real ) : real",
"",
"remarks: Function returns the real arc tangent of <y>/<x>",
" in units of radians in the range of -pi to pi.",
" If both <x> and <y> are 0.0 a run-time error will",
" occur.",
"",
"",
"",
"",
"",
"",
"",
"",
"array keyword",
"",
"usage: array( <size>{, <size> } ) of <type spec>",
"",
"remarks: Keyword is used for specifying a data",
" type as an array of <type spec>. Array indices,",
" <size>, must be constant integer expressions.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"assert keyword",
"",
"usage: assert <boolean expn>",
"",
"remarks: Keyword is used to conditionally terminate a",
" program. If <boolean expn> is false the program",
" halts.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"boolean keyword",
"",
"usage: var <name> : boolean",
"",
"remarks: Standard data type specifier. Boolean data can",
" have a value of either true or false.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"case keyword",
"",
"usage: case <expn> of",
" value <const>{, <const>} :",
" <declarations and statements>",
" {value <const>{, <const>} :",
" <declarations and statements>}",
" [value :",
" <declarations and statements>]",
" end case",
"",
"remarks: Case <expn> and each <const> must be of matching",
" type of int, string, char, or enum. One value not",
" having a <const> may be placed at the end of the",
" sequence of case values as a default branch.",
"",
"ceil standard function",
"",
"usage: ceil( <expn> : real ) : int",
"",
"remarks: Function returns the smallest integer greater",
" than or equal to <expn>.",
" See also: floor, round",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"char keyword",
"",
"usage: const <name> : char := \'<literal char>\' ",
" var <name> : char ",
"",
"remarks: Standard data type specifier for characters",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"chr standard function",
"",
"usage: chr( <expn> : int ) : char",
"",
"remarks: Function returns a character corresponding",
" to the ASCII code of <expn>.",
" See also: ord",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"close standard function",
"",
"usage: close( <stream> : int ) : boolean",
"",
"remarks: Function closes the file associated with",
" <stream>. Returns true on success or else false.",
" See also: open",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"const keyword",
"",
"usage: const <name> : <type spec> := <constant expn>",
"",
"remarks: Keyword is used to declare a constant. The",
" <constant expn> may not include any names of",
" variables.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"continue keyword",
"",
"usage: continue [ when <boolean expn> ]",
"",
"remarks: Used to jump to the start of the nearest",
" enclosing for or loop statement. Jump is",
" immediate unless the optional when condition",
" is included.",
"",
"",
"",
"",
"",
"",
"",
"",
"cos standard function",
"",
"usage: cos( <expn> : real ) : real",
"",
"remarks: Function returns the cosine of <expn>. The",
" value of <expn> is assumed to be in units of",
" radians.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"cosh standard function",
"",
"usage: cosh( <expn> : real ) : real",
"",
"remarks: Function returns the hyperbolic cosine of <expn>.",
" The value of <expn> is assumed to be in units of",
" radians.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"cursor standard procedure",
"",
"usage: cursor( <type> : int )",
"",
"remarks: Sets the cursor <type> according to the following:",
"",
" no cursor - 0",
" normal cursor - 1",
" solid cursor - 2",
"",
" See also: locate",
"",
"",
"",
"",
"",
"decreasing keyword",
"",
"usage: for decreasing <name> := <begin>...<end> do",
" <declarations and statements>",
" end for",
"",
"remarks: The keyword indicates that the for loop counter",
" decrements.",
" See also: for",
"",
"",
"",
"",
"",
"",
"",
"div keyword",
"",
"usage: <integer expn> div <integer expn>",
"",
"remarks: Operator returns the quotient for integer ",
" division. The result type is integer.",
" See also: mod",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"end keyword",
"",
"usage: end loop",
" end for",
" end if",
" end case",
" end program",
" end <name>",
" end record",
" end union",
"",
"remarks: Used to mark the end of logic statements and",
" subprograms.",
"",
"",
"",
"enum keyword",
"",
"usage: type <name> : enum( <item> {, <item> } )",
"",
"remarks: Used to define an enumerated data type. Values",
" are accessed using the form:",
"",
" <name>.<item>",
"",
"",
"",
"",
"",
"",
"",
"",
"eof standard function",
"",
"usage: eof( <stream> : int ) : boolean",
"",
"remarks: Function returns true if the end of the file",
" corresponding to <stream> has been reached. The",
" value of <stream> is normally obtained using the",
" open function.",
"",
"",
"",
"",
"",
"",
"",
"",
"erealstr standard function",
"",
"usage: erealstr( <expn> : real,",
" <format width> : int,",
" <fraction width> : int,",
" <exponent width> : int ) : string",
"",
"remarks: Function returns a string of the form:",
"",
" {blank}[-]digit.{digit} e sign digit {digit}",
"",
" corresponding to <expn>. Widths are",
" increased automatically if necessary.",
" See also: frealstr, realstr, intstr",
"",
"",
"exit keyword",
"",
"usage: exit [ when <boolean expn> ]",
"",
"remarks: Used to exit from the nearest enclosing for or",
" loop statement. Exit is immediate unless the",
" optional when condition is included.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"exp standard function",
"",
"usage: exp( <expn> : real ) : real",
"",
"remarks: Function returns the base e raised to the",
" value of <expn>.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"false keyword",
"",
"usage: <name> := false",
"",
"remarks: Boolean constant; opposite of true.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"floor standard function",
"",
"usage: floor( <expn> : real ) : int",
"",
"remarks: Function returns the largest integer less than",
" or equal to <expn>.",
" See also: ceil, round",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"for keyword",
"",
"usage: for [decreasing] <name> : <begin>...<end> do",
" <declarations and statements>",
" end for",
"",
"remarks: The for statement repeats the list of",
" <declarations and statements> for each value in the",
" range <begin>...<end>. The identifier <name> must",
" be declared as an integer outside the loop. The",
" value of <name> is incremented, or decremented if",
" the optional keyword decreasing is used, before",
" repeating the loop. The continue and exit",
" statements can be used for control within the",
" loop. Declarations made within the loop are not",
" visible outside the loop.",
"frealstr standard function",
"",
"usage: frealstr( <expn> : real,",
" <format width> : int,",
" <fraction width> : int ) : string ",
"",
"remarks: Function returns a string of the form: ",
"",
" {blank}[-]digit{digit}.{digit} ",
"",
" corresponding to <expn>. Blanks are added as",
" needed to right justify the string. Widths are",
" increased automatically if necessary.",
" See also: erealstr, realstr, intstr",
"",
"",
"function keyword ",
"",
"usage: function <name>[(<param>{, <param>})] : <type spec> ",
" <declarations and statements> ",
" end <name> ",
"",
" in which <param> is: ",
"",
" [var] <name>{, <name>} : <type spec> ",
"",
"remarks: A function must return a value using a return ",
" statement. Declarations within the function ",
" definition are only visible within the function. ",
" The use of var in a parameter list means that ",
" the parameter is to be passed to the function by",
" reference rather than by value.",
"get keyword ",
"",
"usage: get [:<stream>,] <get item> {, <get item>} ",
"",
" in which a <get item> is one of: ",
"",
" a. <name> - variable reference ",
" b. <name> : * - line input ",
" c. <name> : <width> - string input ",
"",
"remarks: If <stream> is omitted, input is from the",
" console. The <name> of <get item> must correspond",
" to a variable. Form (a) can be an integer, ",
" real number, or a string. Forms (b) and (c)",
" must be for a string variable.",
"",
"getexp standard function ",
"",
"usage: getexp( <expn> : real ) : real ",
"",
"remarks: Function returns the exponent, base 10,",
" of <expn>. If <expn> equals 0.0, zero is",
" returned.",
" See also: setexp",
"",
"",
"",
"",
"",
"",
"",
"",
"getkey standard function ",
"",
"usage: getkey : int ",
"",
"remarks: Function returns an integer value corresponding ",
" to the key that was pressed. If a character key",
" was pressed, the ASCII code is returned.",
" If a function key was pressed, a value equal to ",
" the scan code plus 256 is returned.",
" The key is not echoed to the video display. ",
" See the user's manual for a table of key codes.",
"",
"",
"",
"",
"",
"goto keyword ",
"",
"usage: goto <label name> ",
"",
"remarks: This keyword causes an immediate jump to ",
" the location of <label name>. Program execution ",
" may not jump from one subprogram to another. ",
" See also: label",
"",
"",
"",
"",
"",
"",
"",
"",
"if keyword ",
" ",
"usage: if <boolean expn> then ",
" <declarations and statements> ",
" {elsif <boolean expn> then ",
" <declarations and statements>} ",
" [else ",
" <declarations and statements>] ",
" end if ",
" ",
"remarks: The <declarations and statements> are executed in",
" the first branch in which the <boolean expn> is ",
" true. Optional elsif branches must be placed ",
" ahead of the single optional else branch. ",
" Declarations within each branch are not visible ",
" outside the branch. ",
"include keyword",
" ",
"usage: include <filename>",
" ",
"remarks: This keyword is used to include an additional file",
" in a program at the statement location.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"index standard function ",
"",
"usage: index( <string>, <pattern> : string ) : int ",
"",
"remarks: Function returns the value of the location of the ",
" first occurrence of <pattern> in <string>. If no",
" match is found, a negative number is returned. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"int keyword ",
"",
"usage: var <name> : int ",
" const <name> : int := <integer expn> ",
"",
"remarks: Standard data type specifier. Integer data can ",
" have values in the range given in the user's manual.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"intreal standard function ",
"",
"usage: intreal( <expn> : int ) : real ",
"",
"remarks: Function returns the real number value ",
" equivalent to <expn>.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"intstr standard function ",
"",
"usage: intstr( <expn>, <format width> : int ) : string ",
"",
"remarks: Function returns a string of the form:",
"",
" {blank}[-]digit{digit} ",
"",
" corresponding to <expn>. Blanks are added as",
" needed to right justify the string. The width",
" is increased automatically if necessary. ",
" See also: erealstr, frealstr, realstr ",
"",
"",
"",
"",
"label keyword ",
"",
"usage: label <name> : ",
"",
"remarks: This keyword is used to declare a marker for a ",
" goto statement. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"length standard function ",
"",
"usage: length( <expn> : string ) : int ",
"",
"remarks: Function returns the number of characters in ",
" <expn>. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"ln standard function ",
"",
"usage: ln( <expn> : real ) : real ",
"",
"remarks: Function returns the natural logarithm ",
" of <expn> which must have a value greater than",
" zero or a run-time error will occur. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"locate standard procedure ",
" ",
"usage: locate( <row>, <column> : int ) ",
"",
"remarks: Procudure positions the text mode cursor. ",
" The normal ranges are: ",
"",
" row : 0 to 24 ",
" column : 0 to 79 ",
"",
" (see your system manual) ",
"",
"",
"",
"",
"",
"log10 standard function ",
"",
"usage: log10( <expn> : real ) : real ",
"",
"remarks: Function returns the base 10 logarithm ",
" of <expn> which must have a value greater than",
" zero or a run-time error will occur. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"log2 standard function ",
"",
"usage: log2( <expn> : real ) : real ",
"",
"remarks: Function returns the base 2 logarithm",
" of <expn> which must have a value greater than",
" zero or a run-time error will occur. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"loop keyword ",
"",
"usage: loop ",
" <declarations and statements> ",
" end loop ",
"",
"remarks: This keyword marks the beginning and end of an",
" infinite loop. Declarations within the loop",
" are not visible outside the loop. Statements",
" in the loop are executed until terminated by",
" an exit statement. A continue statement may",
" also be used for control within the loop.",
"",
"",
"",
"",
"max standard function ",
"",
"usage: max( <expn>, <expn> :int|real ) : int|real ",
"",
"remarks: Function returns the maximum of two <expn>s. ",
" If both are integers, an integer is returned; ",
" otherwise a real number is returned. ",
" See also: min",
"",
"",
"",
"",
"",
"",
"",
"",
"min standard function ",
"",
"usage: min( <expn>, <expn> :int|real ) : int|real ",
"",
"remarks: Function returns the minimum of two <expn>s. ",
" If both are integers, an integer is returned; ",
" otherwise a real number is returned. ",
" See also: max",
"",
"",
"",
"",
"",
"",
"",
"",
"mod keyword ",
"",
"usage: <integer expn> mod <integer expn> ",
"",
"remarks: Operator returns the remainder for integer",
" division. The result type is integer. ",
" See also: div",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"nand keyword",
"",
"usage: <boolean expn> nand <boolean expn>",
"",
"remarks: Operator returns a boolean value:",
"",
" x y x nand y",
"",
" false false true",
" false true true",
" true false true",
" true true false",
"",
"",
"",
"",
"nor keyword",
"",
"usage: <boolean expn> nor <boolean expn>",
"",
"remarks: Operator returns a boolean value:",
"",
" x y x nor y",
"",
" false false true",
" false true false",
" true false false",
" true true false",
"",
"",
"",
"",
"not keyword ",
"",
"usage: not <boolean expn>",
"",
"remarks: Operator returns a boolean value: ",
"",
" x not x",
"",
" false true",
" true false",
"",
"",
"",
"",
"",
"",
"open standard function ",
"",
"usage: open( <filename>, <mode> : string ) : int ",
"",
"remarks: Function opens a file for reading or writing and ",
" returns the file's stream number. The <mode> ",
" is \"r\" for reading from, or \"w\" for writing to. ",
" If the file cannot be opened, zero is returned. ",
"",
" A standard printer can be opened using: ",
"",
" open( \"prn\", \"w\" ) ",
"",
" Device codes lpt1 or lpt2 can be used instead.",
"",
"",
"or keyword ",
"",
"usage: <boolean expn> or <boolean expn>",
"",
"remarks: Operator returns a boolean value:",
"",
" x y x or y",
"",
" false false false",
" false true true",
" true false true",
" true true true",
"",
"",
"",
"",
"ord standard function ",
"",
"usage: ord( <expn> : char ) : int ",
"",
"remarks: Function accepts a character and returns its",
" corresponding ASCII code. ",
" See also: chr",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"pred standard function ",
"",
"usage: pred( <expn> : int|<enum type> ) : int|<enum type> ",
"",
"remarks: Function accepts an integer or enumeration",
" value and returns the previous value. ",
" See also: succ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"procedure keyword ",
"",
"usage: procedure <name>[(<param>{, <param>})] ",
" <declarations and statements> ",
" end <name> ",
"",
" in which <param> is: ",
"",
" [var] <name>{, <name>} : <type spec> ",
"",
"remarks: A procedure may return after reaching the end of",
" the list of its statements or when a return",
" statement is reached. Declarations within the",
" procedure definition are only visible within it.",
" The use of var in a parameter list means that",
" the parameter is to be passed by reference.",
"program keyword ",
"",
"usage: program",
" <declarations and statements> ",
" end program",
"",
"remarks: A program statement defines the start and end of ",
" the main program. Statements can call functions or ",
" procedures. Declarations are only visible within ",
" the program statement. ",
"",
"",
"",
"",
"",
"",
"put keyword ",
"",
"usage: put [:<stream>,] <put item>{, <put item>}[...] ",
"",
" in which a <put item> is: ",
"",
" <expn>[:format width[:fraction width[:exponent width]]]",
"",
"remarks: If <stream> is omitted, output is to the console. ",
" A new line is started at the end of the list of ",
" <put item>s unless ellipses \"...\" are appended. ",
"",
"",
"",
"",
"",
"putch standard procedure ",
"",
"usage: putch( <expn> : char, ",
" <foreground>, <background> : int ) ",
"",
"remarks: This procedure puts a character at the location",
" of the video cursor using the selected video",
" textmode <foreground> and <background> colors.",
" See the user's manual for a table of color codes.",
"",
"",
"",
"",
"",
"",
"",
"putline standard procedure ",
" ",
"usage: putline( <x1>, <y1>, <x2>, <y2>, <color> : int )",
" ",
"remarks: This procedure draws a straight line from",
" <x1>, <y1> through <x2>, <y2> in the selected <color>.",
" The endpoints of the line must be within the",
" limits for the current graphics mode.",
" See the user's manual for a table of video color codes.",
"",
"",
"",
"",
"",
"",
"",
"putpixel standard procedure ",
"",
"usage: putpixel( <x>, <y>, <color> : int ) ",
"",
"remarks: This procedure places a video dot at location ",
" <x>, <y> in the selected <color>. The location ",
" must be within the limits for the graphics mode. ",
" See the user's manual for a table of video color codes.",
"",
"",
"",
"",
"",
"",
"",
"",
"putstr standard procedure ",
"",
"usage: putstr( <expn> : string, ",
" <foreground> : <background> : int ) ",
"",
"remarks: This procedure puts a string at the current",
" location of the video cursor using the selected",
" video textmode <foreground> and <background> colors.",
" See the user's manual for a table of video color codes.",
"",
"",
"",
"",
"",
"",
"",
"rand standard function ",
"",
"usage: rand : real ",
"",
"remarks: Function returns the next value of a sequence of ",
" pseudo random real numbers approximating a ",
" uniform distribution within the range 0.0 to 1.0 ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"randint standard function ",
"",
"usage: randint( <low>, <high> : int ) : int ",
"",
"remarks: Function returns the next value of a sequence of ",
" pseudo random integers approximating a uniform ",
" distribution in the range <low> to <high> ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"randomize standard procedure ",
"",
"usage: randomize ",
"",
"remarks: Procedure sets the pseudo random seed used by ",
" functions rand and randint to a machine ",
" generated random value. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"randseed standard procedure ",
"",
"usage: randseed( <new seed> : int ) ",
"",
"remarks: Procedure sets the pseudo random seed used by ",
" functions rand and randint to <new seed> ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"real keyword ",
"",
"usage: var <name> : real ",
" const <name> : real := <expn> ",
"",
"remarks: Standard data type specifier for real numbers",
" which can have values in the range given in ",
" the user's manual.",
"",
"",
"",
"",
"",
"",
"",
"",
"realstr standard function ",
"",
"usage: realstr( <expn> : real, ",
" <format width> : int ) : string ",
"",
"remarks: Function returns a string of the form: ",
"",
" {blank}[-]digit{digit}.{digit} ",
"",
" or of the form: ",
"",
" {blank}[-]digit.{digit} e sign digit{digit} ",
"",
" depending on the magnitude of <expn>. Blanks are",
" added as needed to right justify the string.",
" See also: erealstr, frealstr, intstr",
"record keyword ",
" ",
"usage: record ",
" <item>{, <item>} : <type spec> ",
" {<item>{, <item>} : <type spec>} ",
" end record ",
"",
"remarks: Keyword is used to declare a record data type. ",
" To access elements of a record type, use the ",
" item selector \".\" between a variable name ",
" and the item identifier. ",
"",
"",
"",
"",
"",
"repeat standard function ",
"",
"usage: repeat( <string> : string, <expn> : int ) : string ",
"",
"remarks: Function returns <expn> copies of <string> joined ",
" together into a single string. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"return keyword ",
"",
"usage: return [<expn>]",
" ",
"remarks: Keyword causes a return from a function or",
" procedure. A function must return a value.",
" The type of <expn> must be compatible with a",
" function's return type. ",
"",
"",
"",
"",
"",
"",
"",
"",
"round standard function ",
"",
"usage: round( <expn> : real ) : int ",
"",
"remarks: Function returns the integer nearest to <expn>.",
" See also: ceil, floor",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"scroll standard procedure ",
"",
"usage: scroll( top, bottom, left, right, ",
" foreground, background, ",
" rows_to_scroll : int ) ",
"",
"remarks: Procedure scrolls a text mode window where: ",
"",
" top, bottom, left, right : region to scroll ",
" foreground : new foreground color ",
" background : new background color ",
" rows_to_scroll : + up, - down, 0 for all ",
"",
"",
"",
"",
"setexp standard function ",
"",
"usage: setexp( <expn> : real, <exp> : int ) : real ",
"",
"remarks: Function returns the value of <expn> with the ",
" exponent, base 10, changed to <exp>. If <expn>",
" equals 0.0, zero is returned. The value of",
" <exp> must be within the range shown in the",
" user's manual.",
" See also: getexp",
"",
"",
"",
"",
"",
"",
"setvideo standard procedure ",
"",
"usage: setvideo( <expn> : int ) ",
"",
"remarks: Procedure sets the system's video mode to <expn>.",
" See the user's manual for a table of video mode codes.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"sign standard function ",
"",
"usage: sign( <expn> : real ) : int ",
"",
"remarks: Function returns the sign of <expn> as an ",
" integer -1 or +1. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"sin standard function ",
"",
"usage: sin( <expn> : real ) : real ",
"",
"remarks: Function returns the sine of <expn>. The value of",
" <expn> is assumed to be in units of radians. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"sinh standard function ",
"",
"usage: sinh( <expn> : real ) : real ",
"",
"remarks: Function returns the hyperbolic sine of",
" <expn>. The value of <expn> is assumed to be in",
" units of radians.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"sqrt standard function ",
"",
"usage: sqrt( <expn> : real ) : real ",
"",
"remarks: Function returns the square root of <expn>.",
" The value of <expn> must be non-negative or a",
" run-time error will occur.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"string keyword",
"",
"usage: string[(<integer expn>)]",
" ",
"remarks: Standard type specifier. The value of",
" <integer expn> specifies the maximum length of",
" the string which can be no larger than the limit",
" shown in the user's manual.",
"",
"",
"",
"",
"",
"",
"",
"",
"strint standard function ",
"",
"usage: strint( <expn> : string ) : int ",
"",
"remarks: Function returns the integer equivalent to",
" <expn>.",
" See also: strreal",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"strreal standard function",
"",
"usage: strreal( <expn> : string ) : real",
"",
"remarks: Function returns the real number equivalent",
" of <expn>.",
" See also: strint",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"succ standard function ",
"",
"usage: succ( <expn> : int|<enum type> ) : int|<enum type> ",
"",
"remarks: Function accepts an integer or enumeration value ",
" and returns the next value. ",
" See also: pred",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"tan standard function ",
"",
"usage: tan( <expn> : real ) : real ",
"",
"remarks: Function returns the tangent of <expn>. The value",
" of <expn> is assumed to be in units of radians. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"tanh standard function ",
"",
"usage: tanh( <expn> : real ) : real ",
"",
"remarks: Function returns the hyperbolic tangent of",
" <expn>. The value of <expn> is assumed to be in ",
" units of radians.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"true keyword ",
"",
"usage: <name> := true ",
"",
"remarks: Boolean constant; opposite of false. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"type keyword ",
"",
"usage: type <name> : <type spec> ",
"",
"remarks: Declares a named type for the <type spec>. ",
" Normally, <type spec> is one a user defines using",
" an array, record, union, or enum declaration.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"union keyword ",
"",
"usage: union ",
" <item>{, <item>} : <type spec> ",
" {<item>{, <item>} : <type spec>} ",
" end union",
"",
"remarks: Keyword is used to declare a data type.",
" To access elements of a union type, use the",
" item selector \".\" between a variable identifier",
" and the item identifier.",
"",
"",
"",
"",
"",
"var keyword ",
"",
"usage: var <name>{, <name>} : <type spec> [:= <expn>]",
"",
"remarks: It must precede each variable declaration and",
" is also used to declare that a parameter in a",
" subprogram's parameter list is passed by",
" reference.",
"",
"",
"",
"",
"",
"",
"",
"",
"videomode standard function ",
"",
"usage: videomode : int ",
"",
"remarks: Function returns an integer corresponding to the ",
" current video mode. See the user's manual for a ",
" table of video mode codes. ",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"videotype standard function ",
"",
"usage: videotype : int ",
"",
"remarks: Function returns an integer corresponding to the ",
" systems's video display type. See the user's manual",
" for a table of video type codes.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"watch standard procedure ",
"",
"usage: watch( <expn> ) ",
"",
"remarks: Displays the current value of <expn> on the",
" debug screen when in debug mode.",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"when keyword",
"",
"usage: exit [ when <boolean expn> ]",
" continue [ when <boolean expn> ]",
"",
"remarks: Used to set a conditional jump in a for or",
" loop statement.",
" See also: for, loop",
"",
"",
"",
"",
"",
"",
"",
"",
"xor keyword",
"",
"usage: <boolean expn> xor <boolean expn>",
"",
"remarks: Operator returns a boolean value:",
"",
" x y x xor y",
"",
" false false false",
" false true true",
" true false true",
" true true false",
"",
"",
"",
"",
"LIMITS ",
"",
" max integer = 2147483647",
" min integer = -2147483648",
"",
" max real mag = 1.797693e+308",
" min real mag = 2.225074e-308",
"",
" max exponent = 308",
" min exponent = -307",
"",
" max string length = 255",
"",
" max array elements = 4096",
"",
"",
"SYMBOLS ",
"",
" arithmetic operators:",
"",
" := + - * / ^",
"",
" comparison operators:",
"",
" = ~= < <= > >=",
"",
" other:",
"",
" & , . ... : ( ) \\ %",
"",
"",
"",
""
};
int Last_i = 0;
int Last_j = 0;
/*
* function declarations
*/
int language();
void put_word(int item);
void help_message(int item);
int get_key();
void double_box_window(int left, int top, int right, int bottom,
int background, int foreground);
/*-------------------------------------------------------------------*
Code Section
*-------------------------------------------------------------------*/
void main(int argc, char *argv[]) // command line
{
char *user_screen;
int user_lin, user_col;
union scancode key;
if (argc == 2)
{
if (!strcmp(argv[1], "nosave")) // match?
{
// this is used in call from editor
while (key.c[0] != 27) // Esc key
{
if (language() == 27)
break;
key.ch = get_key();
}
_setcursortype(_NORMALCURSOR);
}
else
{
printf("\n usage: turhelp [nosave]\n");
printf("\n nosave - prevents restoring user screen\n");
printf("\n use Esc key to exit.\n");
}
}
else
{
// when used as a dos command
user_screen = new char[4000]; // allocate storage
user_col = wherex(); // user screen data
user_lin = wherey();
gettext(1, 1, 80, 25, user_screen);
while (key.c[0] != 27) // Esc key
{
if (language() == 27)
break;
key.ch = get_key();
}
_setcursortype(_NORMALCURSOR); // restore user screen
window(1, 1, 80, 25);
puttext(1, 1, 80, 25, user_screen);
gotoxy(user_col, user_lin);
delete user_screen;
}
}
/*
* "language" shows language elements
*
* returns: nothing
*/
int language()
{
union scancode key; // keyboard input
int item; // message index
int i, j; // loop counter
int rows = 20; // in help display
int columns = 5; // in help display
int width = 14; // of displayed word
// create window
double_box_window(LEFT, TOP, RIGHT, BOTTOM, LIGHTGRAY, BLACK);
_setcursortype(_NOCURSOR);
gotoxy(34, 1);
cputs(" language: ");
gotoxy(30, BOTTOM - TOP + 1);
cputs(" Press Esc to exit ");
// write menu
for (i = 0; i < columns; i++)
{
for (j = 0; j < rows; j++)
{
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
}
}
// initialize
i = Last_i;
j = Last_j;
textcolor(WHITE);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
// process
do
{
key.ch = get_key();
if (key.c[0] == 0) /* Function key */
{
switch (key.c[1])
{
case 72: /* UP arrow */
textcolor(BLACK);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
j--;
if (j < 0)
j = rows - 1;
textcolor(WHITE);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
break;
case 80: /* DOWN arrow */
textcolor(BLACK);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
j++;
if (j > rows - 1)
j = 0;
textcolor(WHITE);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
break;
case 75: /* LEFT arrow */
textcolor(BLACK);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
i--;
if (i < 0)
i = columns - 1;
textcolor(WHITE);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
break;
case 77: /* RIGHT arrow */
textcolor(BLACK);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
i++;
if (i > columns - 1)
i = 0;
textcolor(WHITE);
gotoxy(4 + width * i, 2 + j);
item = columns * j + i;
put_word(item);
break;
default:
break;
}
}
else if (key.c[0] == 13) /* Enter key */
{
Last_i = i;
Last_j = j;
help_message(item);
goto language_exit;
}
}
while (key.c[0] != 27); /* Esc key */
language_exit:
return((int) key.c[0]);
}
/*
* "put_word" puts the first word in a message on the help selection
* display.
*
* returns: nothing
*/
void put_word(int item) // message index number
{
int i; // loop counter
char word[16]; // print buffer
for (i = 0; i < 16; i++)
{
word[i] = Message[item * 16][i];
if (word[i] == ' ')
break;
}
word[i] = NULL;
cputs(word);
}
/*
* "help_message" shows the help message for the selected item
*
* returns: nothing
*/
void help_message(int item) // message index number
{
// create window that matches caller's
double_box_window(LEFT, TOP, RIGHT, BOTTOM, LIGHTGRAY, BLACK);
gotoxy(32, 1);
cputs(" Press any key ");
gotoxy(30, BOTTOM - TOP + 1);
cputs(" Press Esc to exit ");
// write message
for (int i = 0; i < 16; i++)
{
gotoxy(4, 2 + i);
cputs(Message[16*item + i]);
}
}
/*
* "get_key" obtains a two byte character code from the keyboard
*
* returns: the scancode of the key
*/
int get_key()
{
union REGS r; // register structure
r.h.ah = 0;
return int86(0x16, &r, &r);
}
/*
* "double_box_window" create window with a double box frame
*
* returns: nothing
*/
void double_box_window(int left, int top, int right, int bottom,
int background, int foreground)
{
register int i; // loop counter
window(left, top, right, bottom);
textattr(background*16 + foreground);
clrscr();
gotoxy(2, 1);
putch(201); // left, top corner
for (i = 3; i < right - left; i++)
putch(205); // horizontal
putch(187); // right, top corner
for (i = 2; i < bottom - top + 1; i++)
{
gotoxy(2, i);
putch(186); // left vertical
gotoxy(right - left, i);
putch(186); // right vertical
}
gotoxy(2, bottom - top + 1);
putch(200); // left, bottom corner
for (i = 3; i < right - left; i++)
putch(205); // horizontal
putch(188); // right, bottom corner
}
| home
| contents
| previous
| next page
| send comment
| send link
| add bookmark |
Copyright © 2004, Stephen R. Schmitt