APPLICATIONSPROGRAMMATION ★ NEVADA COBOL (c) HISOFT ★

Coding - Hisoft - Nevada CobolApplications Programmation
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Cliquez sur l'image pour l'agrandir

Around 1966, Grace Hopper (who coined the phrase "bug", when she found that the reason for a program crash was a dead insect shorting out a relay) created a high level language for the American Department of Defence and called it Cobol; an acronym for Common Business Oriented Language. Its main advantage is that the program source code is very close to English, which makes it very easy to read and therefore de-bug. This, among other reasons is why Cobol is still widely used for writing business applications.

Unlike most implementations of Basic, which are interpreted, Cobol is compiled. The difference being, that interpreting a program means turning every instruction of the program into machine code as it is run, as opposed to turning the whole program into machine code before running it, as compiling does. The main difference between these two methods is speed. As no conversion work has to be done during the running of a compiled program, it executes much faster.

Cobol is available only for a few home micros, but due to the availability of CP/M on the Amstrad machines, it is now another language option, open to the serious Amstrad user. Although Cobol is faster than Basic, do not go and buy it thinking that you will be writing super fast, graphics and arcade games. Cobol is a business language and has little or no support for graphics.

The implementation of Cobol available on the Amstrad, is Nevada Cobol. It is one of the more popular versions of the language, if not the most complete. Other versions, such as CIS and Microsoft have larger and more powerful instruction sets, but do cost many times more.

Cobol is quite a verbose language and at first sight seems over complicated. To demonstrate, a program to input and then print a person's name would be.

(Please note. The line numbers are only for de-bugging and are not used like Basic line numbers within the program.)

As you can see, this is a bit more long winded than it would be in Basic, but do not be intimidated. The start of the program (The IDENTIFICATION DIVISION), contains data for anyone looking at the source code and shows what the program is, and who wrote it. This is followed by the ENVIRONMENT DIVISION that contains more data for the programmer about what computer the software was written on and what hardware is needed to run it. This division may also have an input-output section containing details about any files to be used in the program. The above example also contains "file-control" that tells the computer facts about files to be used. This information includes the type of file (usually disc or printer) and for disc files, the type of file to be used, be it Sequential or Relative, the access type, be it sequential or random, as well as relative file key, and file status variable assignments.


Cobol differs from Basic in that all data used must be declared at the start of the program, in the next division, the DATA DIVISION. As well as defining all internal data, all files (disc, printer etc.) must also be defined in detail. This makes structuring of data clear and easy to read. The first part of the Data division only exists if there are any files and is, not unexpectedly, called the File section. As an example, a file that had records containing a name, a three line address and a post code would look like this.

The first two lines are the file definition and give more information about the file including the name to be used when accessing the disc. The number at the start of each line is a level number. The higher the number is, the lower the level. Above, the level NAME-AND-ADDRESS, which is a level 01, contains all the other data, and by the same token, all the data from the FORENAME to the SURNAME is contained within NAME. Therefore, referring to NAME would include the forename and surname! together with a separating space). The X(number) on most of the lines refers to the data to be held in each data name. The X tells the compiler that the data is alphanumeric, and could be replaced by such characters as 9,Z or . to denote numeric data, leading zero supression and a decimal point respectively. Other options include holding numbers in packed decimal or in binary form.

The number in the brackets is just shorthand. Instead of a ten character data name being defined by PIC XXXXXXXXXX, you can put PIC X(10). The data name FILLER is commonly used in Cobol and is recognised by the compiler as memory that must be reserved (in this case for a space between the two names), but which does not have to be specifically referenced. There is also a VALUE verb that could be used to fill any data names with specific data at the start of the program. The variable FRED, is an 88 level, which is an exception to the rule of level numbers, and will be explained later.
As you can see, there is only one address line mentioned, although there should be three. This is due to the OCCURS statement. It is similar to a Basic subscript and means that the data may be referred to in the main code as ADDRESSiX), where X is the line of the address that you are referring to.
This File section is followed by a WORKING-STORAGE SECTION. This has exactly the same structure (without the FD's) and defines all the data to be used within the program (the same is a variable is Basic).

After all the data has been defined, the actual program code is entered in the final program division, called the PROCEDURE DIVISION. Apart from the actual instructions, there are SECTION and PARAGRAPH headers. These are two levels of label used by Cobol. A section may contain many paragraphs and is shown as a label followed by the word SECTION. The compiler can differentiate between labels and program statements by their position.
A label will start in the A field whereas program statements start in the B field. In Nevada Cobol, the A field is columns 6 to 9 of the line and the B field is columns 10 to 70. Most other versions of Cobol however, use columns 8 to 11 and 12 to 72 respectively. A nice feature of Nevada Cobol, is that it looks at the first line of your program and decides which format you are using, and allows either.

The code can refer to labels by way of two statements. These are GO TO and PERFORM which act like GOTO and GOSUB in Basic. The GO TO statement transfers control of the program to the relevant part of the program as does the PERFORM statement, but with the latter, the following happens. If a SECTION was PERFORMed, then the program continues until either the end of that SECTION, or an EXIT statement is encountered. At this point, control of the program returns to the statement after the PERFORM. If a PARAGRAPH was PERFORMed, then control returns at the end of that PARAGRAPH.

Descisions may be made in Cobol using the IF verb. IF statements may be nested to form quite complicated structures.

IF statements can be made more readable by "88 levels" in the DATA DIVISION. For example, the above IF statement could be written as:-

Where the DATA DIVISION contains:-

"88 level's" are used a great deal in Cobol and as you can see they make programs more readable as there is less logic to wade through.
Most of the other cobol verbs are very self explanatory. Maths are done using the ADD, SUBTRACT, DIVIDE and MULTIPLY statements in the following format.

In Cobol, the answer to any mathematical function is held in the second data-name unless the GIVING verb is used to direct the answer elsewhere.
Putting any information onto the screen is done with the DISPLAY verb. In the form DISPLAY 'TEXT" or DISPLAY data-name. By contrast, to use a printer, you must create a file, which must be defined in the ENVIRONMENT and DATA divisions. Then you must OPEN it, WRITE to it and then CLOSE it when you have finished (see example).

The Nevada Cobol package has one feature that I found annoying. Whereas other Cobol implementations produce a listing file when they are compiled that contains line numbers and a list of errors, Nevada source codes must be first passed through a program called "RENUMBER" to give it line numbers, as in the example program above, and then compiled. The compiler then tells you where the errors are and you must write them down and refer to the source code. If you have a printer then using control P to get an error listing is invaluable. Finally, although the manual shows an extensive list of error messages, most errors seem to be treated as "syntax errors" which makes de-bugging a slower business than it should be.

To sum up, if you want to write your own applications for your 464 (with disc) or 664, or just want a version of Cobol on your machine, then Nevada Cobol is very adequate and at only £39.95, compared with several hundred pounds for other versions, it constitutes very good value for money.

Steven Godwin, ACU #8509

★ PUBLISHER: HISOFT
★ YEAR: 1985
★ CONFIG: 128K + CP/M
★ LANGUAGE:
★ LiCENCE: COMMERCIALE
★ AUTHOR: Ellis Computing

★ AMSTRAD CPC ★ DOWNLOAD ★

File:
» Nevada  COBOL  v2.1DATE: 2013-08-04
DL: 313
TYPE: ZIP
SiZE: 42Ko
NOTE: CPM 2.2 bootloader/Extended DSK/40 Cyls
.HFE: Χ

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Littérature » Programación con el lenguaje COBOL
» Littérature » Lenguaje COBOL con Programación Estructurada
» Applications » Hisoft Art / Hisoft - Art in Pascal
» Info » Hisoft
» Applications » Coding - Hisoft - Lisp
» Applications » Hisoft Hardcopy (Schneider Aktiv)
Je participe au site:
» Vous avez des infos personnel, des fichiers que nous ne possédons pas concernent ce programme ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 533 millisecondes et consultée 2669 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.