Английская Википедия:IBM System/36 BASIC

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Unreferenced Шаблон:Infobox programming language IBM System/36 BASIC was an interpreter for the IBM System/36 midrange computer.

System/36 BASIC was first offered in 1983, and as such, contained many of the trappings that a BASIC program would have encountered in the time period of the IBM PC, the Commodore 64, the VIC-20, the TRS-80, or many other offerings of the Seventies and early Eighties. As such, S/36 BASIC uses conventions that are no longer standard in modern BASICs, such as line numbers, and does not support newer features such as Шаблон:Mono, procedures, properties, and so forth.

BASIC interpreters written in the Seventies tended to "do odd things odd ways". For example, on the Apple II, a programmer could embed a command into a program via PRINT, when prefaced by the character string Шаблон:Code. Шаблон:Mono and Шаблон:Mono could be used in various BASICs to examine memory content or change it, or even to create an ad hoc machine language program and then run it. System/36 BASIC tends to stay away from these odd conventions; however, the programmer could call for the Alarm (a buzzing sound made by the terminal) via Шаблон:Code.

BASIC statements are expected to be entered in capital letters, and while the operator can press Cmd2 to use lowercase, the BASIC interpreter will convert non-comment keywords into uppercase.

So that BASIC could be useful in a midrange computing environment, IBM added extensions to the language that were specific to the hardware and software conventions of the IBM System/36 Family, such as the Шаблон:Mono file, support for indexed, direct, and sequential disk files, the ability to open and close multiple printer files, and LOAD/SAVE from libraries on the fixed disk.

Statements, functions, and commands

These core BASIC statements, functions, and commands were used:

 DATA
 DIM
 END
 FOR...NEXT
 GOSUB...RETURN
 GOTO
 IF...THEN
 INPUT
 LET
 ON...GOTO
 PRINT
 PRINT USING
 READ
 REM
 STOP
  
 ASC()
 RND()
 SIN()
 COS()
 TAN()
 TAB()
 SQRT()
 LOG()
 
 LIST

More advanced IBM-supplied statements included:

 ON ERROR       Allows error trapping
 OPTION         Permits program-wide properties such as Base 1 or Base 0 array indexing, long or short precision, etc.
 OPEN           Allows a file or device (formatted workstation, printer) to be opened
 CLOSE          Closes a file or device
 WRITE          Outputs to a file or device
 REWRITE        Changes a record or display format
 APPEND         Adds to a file
 DELETE         Deletes a record from a file
 IMAGE          Defines the format of a record using COBOL-like syntax
 FORM           Defines the format of a record using RPG-like syntax
 DEF FN..FNEND  Defines a function
 CHAIN          Loads and passes control to another BASIC program
 
 PRINT #255:          Prints to the (default) printer file
 PRINT NEWPAGE        Clears the screen
 PRINT #255: NEWPAGE  Advances to the next page on the printer file
 
 AIDX()         Refers to the ascending index of an array, which is an array of relative sorted pointers to array elements
 DIDX()         Same as AIDX but uses a descending index
 SRCH()         Used to find a value in an array by retrieving the match pointer         
 SRCH$()        Used to find a string value in a string array by retrieving the match pointer
 RENUMBER       A command used to renumber the lines within a program
 LOAD           A command used to load a program from a library on the fixed disk
 SAVE           A command used to save a program to a library on the fixed disk
 OFF            A command used to exit the interactive BASIC session
 LISTP          A command used to list the current program to the printer

Шаблон:Code is an error-trapping statement that allows BASIC to suspend an error that might otherwise stop a BASIC program from running and perform an error-handling routine instead. Variants include suffixing Шаблон:Mono, and other error types to a statement and immediately trap these errors.

Шаблон:Mono allows the BASIC program to meet special criteria. Sometimes BASIC did not have very much user space (since all S/36 programs are limited to 64K) and the area called "code space" which contains the current user program must reside within the user space. Therefore, users could choose Шаблон:Code which causes BASIC to compute with double-precision (long) numerics, or Шаблон:Code which provides more space and single-precision (short) numerics. Some programmers prefer matrix mathematics where the lowest-numbered index is 0, others prefer 1. Шаблон:Code and Шаблон:Code accomplish this. There are other uses for Шаблон:Mono.

RPG II programs on the S/34 and S/36 could not call each other, but BASIC programs could, using the Шаблон:Mono statement. Шаблон:Mono passes control from the current BASIC module to the named module, bearing a list of arguments which can become variables in the new module when it is loaded.

Шаблон:Code allows the definition of a user function in BASIC which can be named and referred in the program. Шаблон:Mono is placed after the last statement in a function.

There are four ways to format BASIC input and output. First, unformatted; just Шаблон:Mono and Шаблон:Mono to your heart's content. Second, with Шаблон:Code, which in S/36 BASIC can incorporate a constant, a string variable, a line number, or a label. Third, with Шаблон:Code and Шаблон:Code, which place 5250-type display fields on the CRT in immediate mode. Fourth, by using a workstation file (opened with Шаблон:Code and so forth) and performing various combinations of Шаблон:Mono and Шаблон:Mono to that workstation file, using SDA-generated screen formats similar to those in other S/36 applications. Шаблон:Mono and Шаблон:Mono, as well as Шаблон:Code and Шаблон:Code, can direct BASIC to a line number or a label that contains the keyword Шаблон:Code.

An IMAGE statement contains decimals, commas, dollar signs, dashes, and pound signs ("#") in representation of the substituted numeric or alphameric values. Шаблон:Sxhl A FORM statement denotes the size of the variables to be read or written. To save a numeric value of .00 to 99,999.99, use this notation: Шаблон:Sxhl A label is a tag on a line as follows: Шаблон:Sxhl If desired, the statement Шаблон:Code can be used instead of Шаблон:Code.

Шаблон:Mono and Шаблон:Mono are already familiar to COBOL programmers and describe the actions taken to access S/36 disk files using BASIC. It isn't possible to access every single type of S/36 file because these include system files, libraries, and folders, but every user-created S/36 file with a fixed record length (only FORTRAN programs can use variable record lengths) will suffice. Disk files can be opened sequentially, by index, or relatively (by record number). If a file is delete-capable, records can be deleted using the Шаблон:Mono statement. To add a record, use Шаблон:Mono (with Шаблон:Mono specified in the Шаблон:Mono statement) and to update use Шаблон:Mono.

In S/36 BASIC, to print to the printer, a device file must be used. A default printer file called #255 always exists when BASIC is started. It has a printer name of BASIC255 and opens the device that is the default printer for the terminal that begins a BASIC session. If desired, it is possible to create a different printer file numbered between 1 and 254. Use Шаблон:Code and so forth to do this, specifying columns or device ID or other parameters as needed. The Шаблон:Mono keyword can be used to trap the page overflow condition for the printer.

Some versions of BASIC allow the programmer to sort an array. S/36 BASIC doesn't provide a function for this, but it does provide an interesting remedy. The programmer can define an array with the same number of elements as the target array and use AIDX or DIDX to create an ascending or descending index. Each element of the new array will contain a number representing the ordinal sorted position of the target array, so if AMERICA is the sixth element of array Шаблон:Mono but first in alphabetical order, then setting Шаблон:Code would cause Шаблон:Code to contain the value 1.

Writing a BASIC program is much more fun than rewriting the same program each time you use it, therefore the authors of BASIC allow programmers to Шаблон:Mono their program code to a library member and to Шаблон:Mono it when changes are made.

Шаблон:Code causes the current module to be saved as a subroutine member (type R) named Шаблон:Mono in a user library named Шаблон:Mono.

Note that System/36 files are not part of libraries. If a disk file is named Шаблон:Mono, then an Шаблон:Mono statement like this one can work: Шаблон:Sxhl It doesn't matter which library is used to access file FNF001.

Шаблон:Mono is the S/36 BASIC command used to renumber statements. All internal references to statement numbers are immediately recalculated.

System/36 BASIC has a very dangerous command called Шаблон:Mono. Typing Шаблон:Mono followed by a filename deletes that file without a trace. It will work for every user file, unless there is a conflict of security or an in-use condition that blocks it.

System/36 BASIC has another dangerous command called Шаблон:Mono. The Шаблон:Mono command will make the current program source code inaccessible and it is not reversible. Always save an unlocked copy before using LOCK.

Incompatibility Between S/34 and S/36

System/34 BASIC and System/36 BASIC are very similar; however, machine code incompatibility makes it impossible to port a subroutine member BASIC program between these systems.

See also Square Root of 2 & PI π solution for solution published on mainframes during the 1980s & 1990s.

References

Шаблон:Reflist