Jazz LRM: Section 1, Introduction

A Jazz Program.. 1

Jazz Program Elements. 1

Comment 1

Program.. 2

Statement 2

Keyword. 2

Statement Blocks. 3

User-defined names. 3

Punctuation. 4

Operators. 4

Constants. 5

Invalid Characters. 5

Formal Syntax Descriptions. 6

 

The function of this page is to introduce the basic syntax of Jazz, defining terms like “Program”, “Statement” etc. You need to understand this section before reading any of the actual statement definitions.

A Jazz Program

Here is a simple Jazz program, after Jazz Workbench has processed it. Jazz checks for errors, and colours the elements of the program: -

*# Last Updated by Robertb at 9/05/2014 12:30:14 p.m.

PROGRAM Custrept;

DEFINE Customer TYPE (VSAM) DATA(

        CustomerID CHAR(10) KEY ,

        Name CHAR(40),

        Address CHAR(70),

        Balance DECIMAL(6,2));

PROCESS Customer WHERE Customer.Balance > 1000; [Not interested in small creditors

    PRINT (Customer.Name, Customer.Address, Customer.Balance);

END PROCESS Customer;

Jazz Program Elements

Comment

Comments will be coloured Green, by the Jazz workbench. Like blanks, they have no meaning in your Jazz program, but may function as a separator. There are two kinds of comment: -

a.         Whole-line comments.  Any line starting with “*” is a comment line.  “*#” indicates a System Comment, like the automatically-inserted line at the top of the program.  System Comments may be deleted and replaced when you save your program again, so you should not write your own comments starting with “*#”.  Other than this, you can write whatever you like in a comment.

b.         Partial-line comments.  Write “[“ to have this and the following characters to the end of line, or to a closing “]” character, treated as comment. For example,

      PROCESS Customer WHERE Customer.Balance > 1000; [Not interested in small creditors

You can write a closed comment anywhere that a blank would be valid. For example    

      PROCESS Customer WHERE[larger customers only]Customer.Balance > 1000;        

Program

A Program is a group of Jazz statements starting with a PROGRAM statement. Jazz objects can also start with DEFINE, SCREEN, or SUBPROGRAM.

Statement

A Statement is one or more lines of code that means something to Jazz.  Statements start with a keyword, except in the case of the assignment statement. There are five statements in the example Jazz program, beginning with the keywords PROGRAM, DEFINE, PROCESS, PRINT, and END.

 

Each statement must start on a new line. If necessary the Jazz Workbench will split your code into multiple lines: for example

       Program Prog1; Process File1;

will become

       PROGRAM Prog1;

       PROCESS File1;

 

Semicolons indicate the end of a statement. It they’re omitted Jazz may put them in for you (which helps to show how Jazz has interpreted your program), or Jazz may think that the text continues the first statement. Often this leads to error messages, and so it is best to write the semicolons yourself to make explicit where the statement ends. Only comments can appear on the rest of the line following a semicolon, anything else will be treated as the start of another statement, and the line will be split by the workbench.

Keyword

A Keyword is a word that has special meaning to Jazz. PROGRAM, DEFINE, PROCESS, PRINT, and END are all keywords, as are TYPE, VSAM, DATA, CHAR, KEY, DECIMAL and WHERE. There are several kinds of keywords: Statement Keywords (Program, Define, etc), Option Keywords (Type, Where), or Item keywords.  The Jazz workbench will colour keywords blue, and statement keywords will also be bold.

 

Keywords are recognized in context: for example Type is an option of the Define statement.  However if you write             Program Type

then “Type” is the name of your program, not an error. On the other hand if you write

            Program Program1 Type CICS

then the word “Type” here is an error because Jazz is looking for a keyword that is either an option of the Program statement, or a new statement. Type is neither.

 

You only need to write enough of the keyword to make it unambiguous.  Thus you could write

                Prog Program1

and Jazz will recognize this as the PROGRAM keyword and expand it for you.  

 

You can also use synonyms: for example “List” is a synonym for PRINT.  If you write

                List (customer.name, ….),

Jazz will change this to

       PRINT (customer.name, ….),

 

Like keywords, you can abbreviate synonyms and Jazz will expand them for you.

Statement Blocks

Within a program there are often groups of related statements. For example, the program above contains

PROCESS Customer WHERE Customer.Balance > 1000; [Not interested in small creditors

     PRINT (Customer.Name, Customer.Address, Customer.Balance);

END PROCESS Customer;

Basically this means

PROCESS Customer [modified by Options like WHERE

    Various statements defining what you want to do with each record

END PROCESS; [Here we finish processing this record (perhaps updating it, calculating totals, etc.

 

A block is a group of statements that starts with a Jazz statement and finishes with an END statement. You’ll see these with statements like PROCESS and FOR that imply loops, and with statements like IF that control other statements. Statement blocks may contain inner blocks, for example

Process Record1;

    Process Record2 Where Record2.KeyValue = Record1.KeyValue;

        do something

    End Process Record2;

End Process Record1;

User-defined names

These are the names that you give to objects – like the name of your program, files, screens, fields, and so on. In the program above user-defined names are

                Custrept, Customer, CustomerID, Name, Address, and Balance

 

When a name is defined it appears in normal colour (black), but when you refer to it appears in “Reference Colour”, normally turquoise. For example,

               PRINT (Customer.Name, Customer.Address, Customer.Balance)

Also, references will be qualified: for example you probably wrote

                Print (Name, Address, Balance)

and the workbench changed this to say “Customer.name” etc.

 

User-defined names

a.         Must start with a letter: A to Z, or a to z

b.         Can then continue with any letter, number, or -

c.         Must not start with “Jz” or $. Jazz uses jz as a prefix for some generated field names, and $ for Jazz-defined (“built-in”) names like $Today, so this rule prevents conflicts.

d.         Must be less than 25 characters in length. In some circumstances, like program names, the maximum length is 8 characters.

e.         Must not end with a hyphen, and must not start with a number or hyphen. Thus both

                        2nd, AName-

            are invalid.

 

Although we wouldn’t suggest that you do it deliberately, you can use COBOL and Jazz keywords as field names (and other user-defined names) in your programs. For example: -

DEFINE Table TYPE(SQL)DATA

      Field1 SMALLINT,

      Field2 DATE,

      Field3 CHAR(5),

      Field4 INTEGER,

      After   DATE);

Here both “Table” and “After” are COBOL reserved words, but this is valid Jazz, as is

PRINT (Table.After);

User names will be recognized with or without capitals, and the workbench will change references to the original case.

External Names

Some user names are External Names, i.e. names that are used outside your program by the operating system and/or other external objects. In the sample program above there the program name “Custrept” and the file name “Customer” are external names.  External names follow the rules above for other user names, but also have some additional rules: -

·         They can’t be longer than 8 characters.

·         They must not contain a hyphen

·         They may not be a COBOL reserved word

Punctuation

Punctuation means characters like “,”, “(“, “)”, etc that break up your program to make it more meaningful to Jazz and more readable to you. We’ll deal with punctuation later, except to note that there is a very common type of statement syntax: -

Keyword (item, item, item, … item)

You’ll see this both with statements (for an example, see the Print statement above), and also with options.           

 

Typically each item starts with a field name, and then may have some options following the field name. A comma ends this item and starts the next item.  Sometimes the item-option itself is complex, in which case you will see the Keyword(item, item, item, …) syntax repeated within the item.

 

Where the Jazz workbench detects that punctuation is needed to make sense of your program but you’ve left it out, then it will insert it. For example

Print name address balance

will become

PRINT (record1.name, record1.address, record1.balance);

Operators

These are characters like “=”, “+”, “-“, “>”, and two-character sequences like “+=”, that have meaning within arithmetic or comparison expressions like

NewBalance = Balance + Payment

IF NewBalance > 1000 Then …

We’ll deal with these later.

Constants

These are values that don’t change.  There are two basic kinds, numbers and strings. Examples are

'Robert Barnes'

123

 

Numbers come in two types, integers like 123, and decimal numbers like 456.78. A number may have up to 18 digits.

 

A string constant consists of characters surrounded by single quote marks (').  For example:

'JONES'

'123.90'

'CUSTOMER'

' '

 

The length of the string is limited to the space available on the line displayed at the computer terminal.

 

There are three kinds of string constants,

·               Normal, or character string, constants like those above.

·               Hexadecimal string constants.

·               Bit string constants.

 

A hexadecimal string is prefixed with “X” and contains hexadecimal characters only, i.e. the characters “1234567890abcdef”.  The letters may be capital or lower case.  Examples:-

X'89AB'

X'c1c2'

Each group of two hexadecimal characters represents one byte, so a hexadecimal string must have an even number of characters between the quotes.

 

A bitstring represents the values of consecutive binary digits, and consists of  ones and zeros surrounded by single quote marks (') and beginning with the letter B. For example:

B'0101010101'

 

The length is limited to the space available on the line displayed at the computer terminal.

 

To specify a character string that contains a single quote mark, use two consecutive single quote marks, for example:

'O''Day'  prints  O'Day

Note that this is single-quote “O” single-quote single-quote “Day” single-quote, it does not use the double-quote character.

Invalid Characters

You can write anything you like within a character string constant, or a comment. However if you write characters like “#”, “%”, etc within a Jazz program then Jazz will consider them invalid. Also, “words” like “1st”, “22nd” etc are invalid: they do not start with A to Z, yet they are not numbers.

Formal Syntax Descriptions.

We’ve tried to keep this document light and easy to read, while still defining what you need to know, but sometimes we need to give a precise description of a format. When we need to precisely describe a statement, or part of a statement, you’ll see something like this: -

The DEFINE statement has this form: -

DEFINE record-name

      [Type option]

      DATA (data-list)

      [record-validity option]....

      [trigger option]....

      [record-title option]

      ;

 

Some of the sections are enclosed in [ and ].  This does not mean “Comment” here, this means that this part of the statement is optional. Thus “[Type option]” shows you that a DEFINE statement MAY have a Type option, but it doesn’t have to. However it MUST have the DATA option, and the final semicolon.

 

A section within [ … ] can itself contain an optional section. 

 

Where the option is followed by “….”, then there may be several occurrences of the option. Thus a DEFINE statement: -

·         Has at most one TYPE option

·         Must have one DATA option

·         May have any number of Record-Validity options.

and so on.

 

Where options are alternatives we indicate this in the formal descriptions with “|”, meaning “or”. Thus in the description of validity options (part of a data description) you’ll see

            [RANGE(value1, value2) | MAX(value) | MIN(value) ]

In other words, you may give RANGE or MAX or MIN, but you can only give one of these options.

 

Generally options may appear in any order, but there are some exceptions which are noted.

 

Following a description like that of the DEFINE statement above you’d expect to see definitions of each element, for example record-name, Type option, Data(data-list), record-validity option, trigger option, and record-title option in this case.  These in turn may require further levels of definition.