The Chaprola Language Commands

Basic Definitions of the Chaprola Language


[Number] ::=  A number, e.g. 25,  10.45,  1E7

[Text] ::= An alphanumeric string, e.g. abcdefg, 4.x

[Ri] ::= The variables of the Chaprola Language

[Vi] ::= A number or an R-variable

[Start] ::= A number that is truncated to an integer, the value of which determines a starting character position.

[Length] ::= A number truncated to an integer which is the length of a character string specified by the command.

[SNi] ::= This is a statement number between 1 and 1999.

Expressions Used in the Chaprola Language


[Vi]  [ LT/EQ/LE/GT/NE/GE ]  [Vj]    For numerical Comparisons

EQUAL "[text]" [Vj = start] [Vk = length] EQUAL [Vi = Start 1] [Vj = start 2] [Vk = length]

LEGAL [Vj = Start] [Vk = length]

BLANK{S} [Vj = Start] [Vk = length]

EOF {is set when the READ command is executed}

FOERR {is set when the OPEN command is used}

Statements of the Chaprola Language


(Note: All Statements may be preceeded by a unique statment number.
 CALL  
        CALL [Statement Number]
 DEBUG 
        DEBUG ON
        DEBUG OFF
 FIND  
        FIND [Rj] FROM [Start 1] [Length] Using [Start 2]
                 Note: [Start 1] is within the secondary file
                       [Start 2] is within the primary file
 GET   
        GET [Rj] FROM [Starting Location] [Length]
 GOTO  
        GOTO [Statement Number]
 IF    
        IF [Vj] [Logical Operator] [Vj] (any number of Chaprola Commands);
 INSERT
        INSERT [Character Value] [Start]
 LET   
        LET [Rj] = [Vj] [+,-,*,/] [Vj]
 MOVE  
        MOVE [Start 1] [Start 2] [Length]
        MOVE "[text]" [Start] [Text Length]
        MOVE BLANKS [Start] [Length]
 OPEN  
        OPEN [Filename] [Length]
 PRINT 
        PRINT 0 [Length]
        PRINT 1 [Length]
        PRINT 2 [Length]
 PUT   
        PUT [Rj] INTO [Start] [Length] [Format] [Digits]
 READ  
        READ [Record Number] or [R-variable]
              Note: The [record number] is within the secondary file.
 RETURN
        RETURN
 STOP  
        STOP
 WRITE 
        WRITE [Record Number] or R-variable
              Note: The [record number] is within the secondary file.

CALL [Statement Number]

The CALL command is to goto a subroutine and carry out the specified commands and then return to the same place in the program from where it was sent. Up to nine CALLs can be used without a RETURN but there must be one return for every CALL.

Example:

CALL 100 STOP 100 [Any Number of Commands] RETURN

This series of Commands is the basic format for the CALL command. When statement number 100 is called the program skips everything that is between the call statement and the statement number. When the computer has completed its task and comes to the RETURN statement the program will return to the program at the last Call statement that was executed. It is possible for the user to use up to nine CALL statements without a return but remember that it will take nine returns to close all the CALL statements.

DEBUG ON or DEBUG OFF

This command aids in the debugging of a program, it allows the user to keep track of the R-variables. In long programs this is helpful. The debug file is designated upon the initial entry to SCIENTRY or CHAPRPG. It will place the Chaprola program line number the variable name an equals sign and then the value in exponential form into the designated file. The DEBUG OFF reverses the DEBUG ON statement. When a Chaprola program is initially executed the DEBUG status is off.

If the DEBUG command is to be used then there is an extra step in the compiling that needs to be done. When CHAPCOMP is run you are asked for an input file an output file and a third word. If an x is placed in the third word position then the compiler will number all of the lines. This is the line number that the DEBUG command uses. If this is not done, then the debug file will list all the line numbers as zero because the computer is not keeping track of the numbers. Another note, the number option in the compiling stage slows down the computer in the execution of that program. Once the program is debugged then the program should be recompiled without the line number option so that it will run faster.

The debug file is a file that is designated at the beginning of execution in programs like SCIENTRY and CHAPRPG.

FIND [Rj] FROM [Start 1] [Length] Using [Start 2]

The FIND command is to search through the records in a data file looking for a specific string of characters. [Start 1] is the location within the Secondary Data File that is being searched to find the string. [Length] is the length of both strings, make sure that they are of equal length. If they are not it makes it more difficult to manipulate the data after it is found. [Start 2] is the reference string that the computer is using to compare to the string in [Start 1]. There are two limitations, one the file that is being searched must be sorted to the field that is being used and secondly the strings must be identical or the Find command will not consider them equal.

There is one note that must not be forgotten. When the find command is used the data file must be sorted to that string of characters, if it is not the command will not work correctly. Another note is that when the program has found a match then it will continue the program. This can be a problem if there are more than one matching strings. The computer does not find the first match in chronological order.

Example

FIND R20 FROM -25 10 USING 15

This command will place the record number that it finds an exact match to what is at character position 15 for a length of 10 looking in the secondary record at character position -25. The file must be sorted to the field that the program will be looking into.

GET [Rj] FROM [Starting Location] [Length]

The GET command is used to get numerical data from a file so that numerical manipulation can occur with the LET command. It looks for a number at a location of [Starting Location] for a length of [Length] and can be in any numerical format. It places the value into the register specified. Remember that when the GET command is used the computer only retrieves the information. To return the information the PUT command is used.

Example

GET R7 FROM 26 6 This gets a number from location 26 for a length of 6 and places it into register 7. An error will occur if the location contains anything other than blanks or a real number.

GOTO [Statement Number]

This command tells the computer to goto a specific line in the program specified in [Statement Number]. If the statement number is not the first thing encountered in a line then the program will not compile correctly.

Example

GOTO 17 This will send the computer to statement number 17 and read nothing that is in between the goto statement and the statement number.

IF [Vj][Logical Operator][Vk](any number of Chaprola Commands) ;

This command takes two variables or character strings and compares then in accordance to the logical operator. The result of the comparison is either true or false. If the result is true then the program will execute any number of Chaprola commands that is then ended by a semi-colon (;). Any number of IF statements are ended by one semi-colon. If the logical operator is false then the program skips to the next semi-colon. There are six relational expressions that can be used for comparisons of numbers.

LT Less Than GT Greater Than LE Less Than or Equal to GE Greater than or Equal to EQ Equal to NE Not Equal To

The other forms of the IF statements compare either character strings or will check system set errors.

IF LEGAL [Start] [Length] ................... ; IF BLANK [Start] [Length] ................... ; IF NOT BLANK [Start] [Length] ............... ; IF EQUAL [Start 1] [Start 2] [Length] ....... ; IF EQUAL " text " [Start] [Length] .......... ; IF FOERR .................................... ; IF EOF ...................................... ;

IF LEGAL [Start] [Length] ...... ;

The LEGAL operator is used if you want to know if the character string in [Start] is a legal number. If the number is less than or equal to 1E-07 or has any characters or special symbols that might disqualify it as a real number. If the field is a real number then whatever Chaprola statements that follow the IF statement will be executed. If the character string is not a real number then the program will skip to the next semicolon.

Example

IF LEGAL 20 7 GET R27 FROM 20 7 ;

This statements checks in Character Position 20 for a length of 7 to see if the string of characters is a valid number. If the string is a valid number then the GET command will be executed so that the number is placed into register 27. There are some letters that are used to designate special types of numbers. The "b" is used to signal octal numbers. For example 558b is a legal number.

IF BLANK [Start] [Length] ...... ;

The BLANK operator is used to see if a field is empty or not. If the field is empty, then the logical operator is true and what-ever is after the if statement will be executed. If there is any character in the field then the program will skip to the next semicolon.

Example

IF BLANK 100 25 GOTO 100 ;

If character position 100 for a length of 25 is blank the GOTO statement will be executed.

IF NOT BLANK [Start] [Length] ... ;

The NOT BLANK operator is the opposite of the BLANK operator. If there is any character in the field designated by [Start] and [Length] then the logical operator is set at true and whatever Chaprola verbs are before the semi colon will be executed. NOT is a self defined verb in Chaprola and can be used in conjunction with some of the commands.

Example

IF NOT BLANK 26 1 MOVE "7 1SCRATCH SCRATCH SCRATCH" 6023 32 ;

This statement is the basis for a menu driving program. The statement is checking character position 26 for a length of 1 to see if the position is blank. If the field is blank then it will execute the MOVE command which is setting up the computer for changing display, data and procedure files. SCRATCH is a filename that was chosen for example only.

IF EQUAL [Start 1] [Start 2] [Length] ... ;

The EQUAL operator is used to compare two character strings. For the IF statement to be true the character strings must be exactly the same. If they are not then the IF statement will be false and the program will skip to the next semi colon.

Example

IF EQUAL 25 -50 25 WRITE 32000 ;

This command will compare location 25 which is in the Primary data file to location -50, in the Secondary data file for a length of 25. If the two character strings are identical then the computer will write the contents of the secondary memory area to the end of the secondary file.

IF EQUAL "[text]" [Start] [Length] ....;

This form of the EQUAL is to compare a programmer given text string in quotations to a field designated by [Start] and [Length]. It is an EQUAL operator and there for the strings must be exactly the same.

Example

IF EQUAL "F" 26 1 GOTO 1200 ;

This command will take character position 26 for a length of 1 and compare it to the character string given. If the two are equal, then the computer will GOTO statement number 1200 and execute as many number of commands as there are until there is a RETURN statement.

IF FOERR .................;

The FOERR operator is actually a variable that is set by the system when it opens a file with the OPEN command. The FOERR would be false if there was no problem during the opening of the file but if there was a problem in opening the file then the value would be true thus executing what was after the IF and before the semicolon.

Example

IF FOERR RETURN ;

This statement will, if there is a problem executing the OPEN statement, return to the last CALL statement executed.

IF EOF .................;

The EOF operator is set at false unless in the process of a READ command the computer encounters an end of file, in which case the IF statement would be true.

Example

IF EOF GOTO 120 ;

This statement will, when the EOF flag is true, execute the GOTO statement. This happens when a record number is called with the READ statement and there is no such record number or the end of a record is reached.

INSERT [Character Value] [Start]

The INSERT command is to insert an ASCII character from 1 to 255 in a file for any given reason. It could be used to form feed between pages if the report that is being generated is longer than one page or to halt for ribbon changes. It will place the special character in the position [Start] and only takes one space.

Some examples of the codes that might be needed; 10 Line Feed 12 Form Feed 13 Return

Example

Insert 12 5079 PRINT 0 1

This will insert a form feed character into character position 5079 so that when the PRINT 0 command is used this will make the print file go to the next sheet of paper on the printer.

LET [Rj] = [Vj] [+,-,*,/] [Vk]

The let command is to assign a value to an R-variable or do one simple mathematical operation with a combination of variables and numbers.

Examples:

To set R12 to a value of 6.25 Let R12 = 6.25 Let R12 = 0.625E+1 To multiply R12 by 4.0 and place the value in R16 Let R16 = R12 * 4.0

If a complex equation needs to be carried out it must be broken down into a series of commands.

Example:

(R3*(R1-R2)/R4)+R5=R6 LET R7 = R1 - R2 LET R8 = R3 * R7 LET R9 = R8 / R4 LET R6 = R9 + R5 OR LET R7 = R1 - R2 LET R1 = R3 * R7 LET R2 = R1 / R4 LET R6 = R2 + R5

The R-variables within the computer are 64 bit quantities in a format that makes it easy for the computer to execute arithmetic equations. This format though varies from machine to machine. This is why the GET and PUT instructions must be used to load and finally store them into a register. It is advisable when getting a number from a field to use the IF LEGAL statement to see if the number is a legal one.

MOVE [Start 1] [Start 2] [Length]

The MOVE command will take a string of characters starting at a character position [Start 1] for a length of [Length] and move the character position of [Start 2]. If a length of zero is specified then nothing will be moved. Be sure that you specify a length. [Start 1],[Start 2], and [Length] can either be numbers supplied in the program or they may be an R-variable. [Start 1] may also be a string of characters,[text],in a set of quotation marks (").

Examples

MOVE 12 -30 8

This command will move an eight character string from character position 12 in the primary data record, denoted by a positive number, to character position -30 which is in the secondary data record.

MOVE R3 5001 20

This command will move a string of 20 characters from a position that is held in R3 and move it to the user buffer at character position 5001.

MOVE "7" 6023 1 MOVE " 1" 6026 5 MOVE "TESTFILETESTFILETESTFILE" 6031 24

The first line in this series of commands sets the IVAL to 7 which means that you are going to change the display, data and procedure files. The second command makes the new files start at record number 1. The third line is the display, data and procedure files in that order. What is entered is the first eight letters of the file name which corresponds to the file type with the correct suffix. Remember that an error may occur if the file is not defined and compiled.

This set of commands is the basis for generation of menu programs these statements can be combined into one command if you have a single user system. To have a choice of what screen display, use these commands in conjunction with an IF command.

This could be done all at once; MOVE "7 1TESTFILETESTFILETESTFILE" 6023 32

MOVE BLANKS

MOVE BLANKS [Start] [Length]

This command will move a character string of blanks clearing whatever is in the area of [Length] beginning at [Start]. This is being used for clearing menu screens or for clearing fields within a primary or secondary data file or to clear any portion of the user buffer.

Example

MOVE BLANKS 48 1

This will place a blank in character position 48 for a length of one.

MOVE BLANKS 1 48

This will place a string of blanks starting in character position one for a length of 48, clearing everything that had previously been there.

OPEN [Filename] [Length]

The OPEN command allows the user to open a Secondary File in order to make changes or in order to retrieve information. The Secondary file must already be defined and must have a fixed record length specified by [Length]. If the system has a file opening error then FOERR will be set to true, the program will continue to execute unless a serious error is encountered. If the length of the file is unknown you may set the length to zero and the computer will open the file retrieving the record length.

This is not suggested for it slows the execution of the program.

With the OPEN command there are very powerful commands that are possible. With the OPEN command it is possible to define and delete files. To define a file, When designating the filename place a plus sign (+) in front of the filename within the quotation marks. To delete a filename, When designating the filename place a minus sign (-) in front of the filename within the quotation marks.

Examples

OPEN "TESTFILE" 0

This will open the file TESTFILE and will find out the length of the file for you.

OPEN "TESTFILE" 96

This will open the same file but the program will be faster because the program does not have to find out the record length for you.

PRINT 0 [Length] PRINT 1 [Length] PRINT 2 [Length]

PRINT 0 [Length] This command takes the information in location 5001 for a length of [Length] and places it in the specified print file in CHAPRPG or SCIENTRY. A line feed is placed at the end of a PRINT 0 string.

PRINT 1 [Length] This command halts the program temporarily and prints the contents of 5001 for a length of [Length] to the operator's console and waits for a character to be entered from the keyboard. If the character entered is the stroke of the break key the program is terminated. If any other key is hit the program will continue but note that this command is to be used only in CHAPRPG it is not to be used in SCIENTRY.

PRINT 2 [Length] This command is similar to the PRINT 1 command except that it waits for a line of information to be entered from the keyboard and then a carriage return before the program will continue execution. The PRINT 2 command can only accept eighty characters and if there is any information in the buffer location 5001 it will be overwritten. The command writes the line that is entered to 5001. This command is only to be used in CHAPRPG and is not to be used in SCIENTRY.

PUT [Rj] INTO [Start] [Length] [Format] [Digits]

This command takes the value of a specified register and places it into a specific location [Start] for a length of [Length]. It takes the number and puts it in a specified format. The formats are as follows;

I The integer format gives only the numbers before the decimal truncating anything after the decimal. This command does not round the number at all. If 0 is placed in the [Digit] then the number will be an integer with blanks in front of the number. If a 1 is put into the [Digits] then the number will be preceded with 0's. F The floating point format will place the value in a decimal format with the number of digits after the decimal specified in [Digits] E The exponential format gives the value in scientific notation thus 125.75 would be 1.2575E+02, that is, if the value of 4 is put into [Digits]. If 2 is put into [Digits] then the number would be 1.25E+02 and it would not round. D The dollar format will place a dollar sign at the beginning and will place commas every three digits. it will also give two places after the decimal point but this is not automatic , a 2 must be put into the [Digits] for the cents to be printed. This is a useful command for check writing programs.

Examples: R3 contains the number 4.673224E+3

PUT R3 INTO 5028 9 D 2 The location 5028 will contains $4,673.22

PUT R3 INTO 1019 9 F 3 The location 1019 will contains 4673.224

PUT R3 INTO -305 9 I 0 The location -305 will contains 4673

PUT R3 INTO 200 9 I 2 The location 200 will contains 4.67E+3

READ [Record Number]

This command only pertains to the Secondary Data File. Once a Secondary File is open none of the information is in the Secondary File Memory Area. To be able to read a record you must use the READ command and specify which record you wish to read. The [Record Number] may be specified as a R-Variable or as a number. It is useful to follow the READ command with an IF EOF command to make sure that the READ command is possible. Remember that a READ statement can only be used if the Secondary Data File has been opened with the OPEN command.

Examples

READ 7 This reads record number seven of the Secondary Data File and load its contents into the memory.

READ R6 This will read the record number previously specified in R6. Make sure that this number is an integer and a legal number. It is useful to use the registers if it is unknown which record you wish to open when you are programming.

STOP

The STOP command is used to designate the end of the program and is useful in setting off subroutines that are executed through the use of the CALL statement.

WRITE [Record Number]

This command refers only to the Secondary File. What this is designed for is to write the record that is in the memory to the Secondary File so that any changes that were made would be recorded. The [Record Number] can be designated by an R-Variable by putting in the number at the time of the programming or by adding the new record to the end of the file. To create a new record all the programmer needs to do is input a record number that is larger than the actual number of records in the file. Since the maximum number of records a file can have is 32000 it is suggested that if you wish to add the record to the end of the Secondary FIle that the maximum number be used.

Examples

WRITE 32000 This takes the information that is in the Secondary File Memory Area and place it at the end of the Secondary Data file that is open.

WRITE R7 This writes the contents of the Secondary File Memory Area to the record number designated by the value of R7.

WRITE 38 This writes the contents of the Secondary File Memory Area to the Data file in record number 38.