Chaprola Language Examples


 CALL and RETURN

Call 100 100 Return

This series of Commands is the basic format for the CALL command. When statement number 100 is called the program skips everthing that is between the call statement and the statement number. When the computer has completed it's task and comes to the RETURN statement the program will return to the program at the last Call statement that was exicuted. 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

FIND

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 feild that the program will be looking into.

GET

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

GOTO 17

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

IF

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 exicuted 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.

IF BLANK 100 25 GOTO 100 ;

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

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

This statement is the basis for a menu driving program. The statment is checking character position 26 for a length of 1 to see if the position is blank. If the feild is blank then it will exicute the MOVE command which is setting up the computer for changing display data and proceedure files.

IF EQUAL 25 -50 25 WRITE 32000 ;

This command will compare location 25 to location -50 for a length of 25. If the two character strings are identicle then the computer writes the contents of the secondary memory area to the end of the secondary file.

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 statment number 1200.

IF FOERR RETURN ;

This statement, if there was a problen executing the OPEN statment will return to the last CALL statement executed.

IF EOF GOTO 120 ;

This statment will when the EOF flag is true will execute the GOTO statement. This happens when a record number was called with the READ statement and there was no such record number.

INSERT

Insert 12 5079

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

LET

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 done 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 exicute arithmatic equasions. 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 that when getting a number from a feild that the IF LEGAL statment be used to see if the number is a legal one.

MOVE

MOVE 12 -30 8

This command will move an eight character string from character position 12 in the primary data file, 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 and 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 this statements can be combined into one command if you ar using a single user system. To have a choice of what screen display use the commands in conjunction with an IF command.

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

MOVE BLANKS

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 everthing that had previously been there.

OPEN

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 you will have given the record length thus making the program faster.

PRINT

PUT

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

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

READ R6 This will read the record number 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.

WRITE

WRITE 32000 This will take 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.