Jbase Programmers Reference Manual: Part No: 42-M-JAPRM-20.1 1991 - 1997 James Anthony Computing. All Rights Reserved
Jbase Programmers Reference Manual: Part No: 42-M-JAPRM-20.1 1991 - 1997 James Anthony Computing. All Rights Reserved
Acknowledgements
jBASE, jBC, jED, jSHELL, jLP, jEDI, jCL, jQL, j1, j2 and j3 are trademarks of James Anthony Computing.
UNIX is a registered trademark of X/Open Co. Ltd.
REALITY is a trademark of MDIS plc.
PICK is a trademark of Pick Systems Inc.
All other trademarks are acknowledged.
ii
Table of Contents
Copyright....................................................................................................................i
Acknowledgements..............................................................................................ii
Table of Contents .................................................................................................... iii
Using the Manual .................................................................................................. xiii
Summary of Chapters....................................................................................... xiii
Notation Conventions .......................................................................................xiv
Errata and Comments ..............................................................................................xv
iii
Dimensioned Arrays .......................................................................................2-39
Dynamic Arrays..............................................................................................2-40
File Handling..................................................................................................2-41
Locking Mechanisms......................................................................................2-41
jBC Statements.....................................................................................................2-43
@(Col, Row) ..................................................................................................2-43
@(ScreenCode) ..............................................................................................2-43
ABORT ..........................................................................................................2-44
ABS( ) ............................................................................................................2-45
ALPHA( ).......................................................................................................2-45
ASCII( )..........................................................................................................2-46
ASSIGNED( ) ................................................................................................2-46
BITCHANGE.................................................................................................2-47
BITCHECK....................................................................................................2-47
BITLOAD ......................................................................................................2-48
BITRESET .....................................................................................................2-48
BITSET ..........................................................................................................2-49
BREAK ..........................................................................................................2-49
CALL .............................................................................................................2-50
CASE..............................................................................................................2-51
CHAIN ...........................................................................................................2-51
CHANGE .......................................................................................................2-52
CHAR( ) .........................................................................................................2-52
CHDIR( )........................................................................................................2-53
CHECKSUM ( ) .............................................................................................2-53
CLEAR...........................................................................................................2-53
CLEARFILE ..................................................................................................2-54
CLOSE ...........................................................................................................2-54
COMMON .....................................................................................................2-55
COL1( ) & COL2( )........................................................................................2-55
COLLECTDATA...........................................................................................2-55
CONTINUE ...................................................................................................2-56
CONVERT .....................................................................................................2-56
CONVERT( ) .................................................................................................2-57
COS( ) ............................................................................................................2-57
COUNT( ) ......................................................................................................2-58
CRT ................................................................................................................2-58
DATA.............................................................................................................2-58
DATE( ) .........................................................................................................2-59
DCOUNT( ) ...................................................................................................2-59
DEBUG ..........................................................................................................2-60
DEFC..............................................................................................................2-60
DEL................................................................................................................2-61
DELETE.........................................................................................................2-61
DELETELIST ................................................................................................2-62
DIMENSION .................................................................................................2-62
DTX( )............................................................................................................2-63
EBCDIC( ) .....................................................................................................2-63
ECHO.............................................................................................................2-63
ENTER...........................................................................................................2-64
EQUATE........................................................................................................2-64
EXECUTE......................................................................................................2-65
EXIT( )...........................................................................................................2-66
EXP( ) ............................................................................................................2-67
EXTRACT .....................................................................................................2-67
FIELD( ).........................................................................................................2-67
FIND ..............................................................................................................2-68
FINDSTR .......................................................................................................2-69
iv
FOOTING...................................................................................................... 2-69
FOR ............................................................................................................... 2-70
GETCWD( ) .................................................................................................. 2-71
GETENV( ) ................................................................................................... 2-71
GETLIST ....................................................................................................... 2-71
GOSUB.......................................................................................................... 2-72
GO{TO} ........................................................................................................ 2-73
GROUP( ) ...................................................................................................... 2-73
HEADING ..................................................................................................... 2-74
ICONV( )....................................................................................................... 2-74
IF.................................................................................................................... 2-75
IN................................................................................................................... 2-75
INDEX( ) ....................................................................................................... 2-76
INPUT ........................................................................................................... 2-76
INPUTNULL................................................................................................. 2-77
INS................................................................................................................. 2-78
INSERT ......................................................................................................... 2-78
INT( )............................................................................................................. 2-79
LEN( )............................................................................................................ 2-79
LN( ) .............................................................................................................. 2-80
LOCATE ....................................................................................................... 2-80
LOCK ............................................................................................................ 2-81
LOOP............................................................................................................. 2-81
MAT .............................................................................................................. 2-82
MATCH{ES} ................................................................................................ 2-82
MATBUILD .................................................................................................. 2-83
MATPARSE .................................................................................................. 2-84
MATREAD.................................................................................................... 2-84
MATREADU................................................................................................. 2-85
MATWRITE.................................................................................................. 2-86
MATWRITEU............................................................................................... 2-87
MOD( ) and REM( ) ...................................................................................... 2-87
NOT( ) ........................................................................................................... 2-88
NULL............................................................................................................. 2-88
NUM( ) .......................................................................................................... 2-88
OCONV( ) ..................................................................................................... 2-89
ON...GOSUB, ON...GOTO ........................................................................... 2-90
OPEN............................................................................................................. 2-91
OUT ............................................................................................................... 2-91
PAGE............................................................................................................. 2-92
PERFORM..................................................................................................... 2-92
PRECISION................................................................................................... 2-92
PRINT............................................................................................................ 2-93
PRINTER ON|OFF|CLOSE........................................................................... 2-93
PRINTERR.................................................................................................... 2-94
PROCREAD .................................................................................................. 2-94
PROCWRITE ................................................................................................ 2-94
PROGRAM.................................................................................................... 2-95
PROMPT ....................................................................................................... 2-95
PUTENV ....................................................................................................... 2-95
PWR( )........................................................................................................... 2-96
READ ............................................................................................................ 2-96
READLIST .................................................................................................... 2-97
READNEXT.................................................................................................. 2-98
READT .......................................................................................................... 2-98
READU ......................................................................................................... 2-99
READV ....................................................................................................... 2-100
READVU..................................................................................................... 2-101
REGEXP...................................................................................................... 2-102
v
RELEASE ....................................................................................................2-102
REMOVE.....................................................................................................2-103
REPLACE ....................................................................................................2-104
RETURN......................................................................................................2-104
REWIND......................................................................................................2-105
RND .............................................................................................................2-105
RQM.............................................................................................................2-105
RTNDATA...................................................................................................2-105
SELECT .......................................................................................................2-106
SENTENCE .................................................................................................2-106
SEQ( ) ..........................................................................................................2-107
SIN( )............................................................................................................2-107
SLEEP ..........................................................................................................2-108
SORT( )........................................................................................................2-108
SOUNDEX( ) ...............................................................................................2-109
SPACE( )......................................................................................................2-109
SQRT ...........................................................................................................2-109
STOP ............................................................................................................2-110
STR( )...........................................................................................................2-110
SUBROUTINE ............................................................................................2-110
SYSTEM ......................................................................................................2-111
TAN( )..........................................................................................................2-113
TIME( ) ........................................................................................................2-113
TIMEDATE( )..............................................................................................2-113
TRANSABORT ...........................................................................................2-114
TRANSEND.................................................................................................2-114
TRANSQUERY ...........................................................................................2-114
TRANSTART ..............................................................................................2-115
TRIM( ) ........................................................................................................2-115
TRIMB( ) .....................................................................................................2-116
TRIMF( )......................................................................................................2-116
UNASSIGNED ............................................................................................2-116
UNLOCK .....................................................................................................2-116
WEOF ..........................................................................................................2-116
WRITE .........................................................................................................2-117
WRITELIST.................................................................................................2-118
WRITET.......................................................................................................2-118
WRITEU ......................................................................................................2-119
WRITEV ......................................................................................................2-119
WRITEVU ...................................................................................................2-120
XTD( )..........................................................................................................2-121
vi
Hints and Tips ....................................................................................................... 3-9
Branching......................................................................................................... 3-9
Grouping Commands ....................................................................................... 3-9
Readability....................................................................................................... 3-9
TIME and DATE ............................................................................................. 3-9
Validating Date and Time.............................................................................. 3-10
Long Statements............................................................................................. 3-10
Concatenation ................................................................................................ 3-10
Spooler Hold File Numbers ........................................................................... 3-10
jCL Commands.................................................................................................... 3-11
Input Buffer Commands................................................................................. 3-11
Output Buffer Commands .............................................................................. 3-11
Data Movement Commands........................................................................... 3-11
Input/Output Buffer Operations ..................................................................... 3-11
Jump and Branch Operations ......................................................................... 3-11
Conditional Operations .................................................................................. 3-12
File Operations............................................................................................... 3-12
Arithmetic Operators ..................................................................................... 3-12
Processing...................................................................................................... 3-12
Terminal and Printer Output .......................................................................... 3-12
Debugging...................................................................................................... 3-13
Exiting ........................................................................................................... 3-13
jCL Command Syntax ......................................................................................... 3-14
( ) ................................................................................................................... 3-14
[ ] ................................................................................................................... 3-15
+..................................................................................................................... 3-15
-...................................................................................................................... 3-16
A .................................................................................................................... 3-17
B .................................................................................................................... 3-18
BO.................................................................................................................. 3-19
C .................................................................................................................... 3-19
D .................................................................................................................... 3-20
DE.................................................................................................................. 3-20
DEBUG ......................................................................................................... 3-21
F..................................................................................................................... 3-21
F;.................................................................................................................... 3-21
F-CLEAR....................................................................................................... 3-22
F-DELETE..................................................................................................... 3-23
F-FREE .......................................................................................................... 3-23
F-KLOSE....................................................................................................... 3-24
F-OPEN ......................................................................................................... 3-24
F-READ......................................................................................................... 3-25
F-UREAD ...................................................................................................... 3-26
F-WRITE ....................................................................................................... 3-26
FB .................................................................................................................. 3-27
G, GO or GOTO ............................................................................................ 3-28
GO B.............................................................................................................. 3-29
GO F .............................................................................................................. 3-30
GOSUB.......................................................................................................... 3-30
H .................................................................................................................... 3-31
IBH ................................................................................................................ 3-32
IBN ................................................................................................................ 3-33
IBP................................................................................................................. 3-34
IF.................................................................................................................... 3-35
IF (Multivalued)............................................................................................. 3-36
IF (with Mask) ............................................................................................... 3-37
IF E ................................................................................................................ 3-39
IF S ................................................................................................................ 3-39
IFN................................................................................................................. 3-40
vii
IH ...................................................................................................................3-41
IN ...................................................................................................................3-43
IP ....................................................................................................................3-43
IT....................................................................................................................3-44
L .....................................................................................................................3-45
M ....................................................................................................................3-46
MS..................................................................................................................3-46
MV .................................................................................................................3-47
MVA ..............................................................................................................3-49
MVD ..............................................................................................................3-49
O.....................................................................................................................3-50
P .....................................................................................................................3-50
RI....................................................................................................................3-51
RO ..................................................................................................................3-52
RSUB .............................................................................................................3-53
RTN................................................................................................................3-53
S .....................................................................................................................3-54
STOFF............................................................................................................3-55
STON .............................................................................................................3-55
T .....................................................................................................................3-55
TR...................................................................................................................3-57
U.....................................................................................................................3-58
X.....................................................................................................................3-59
List Processing Commands ..................................................................................3-60
PQ-RESELECT..............................................................................................3-60
PQ-SELECT...................................................................................................3-60
PQ and PQN Differences .....................................................................................3-62
Delimiters .......................................................................................................3-62
Buffers............................................................................................................3-62
Commands......................................................................................................3-62
Chapter 4 : jQL....................................................................................................4-1
Introduction............................................................................................................4-1
jQL Command Sentence Construction...................................................................4-2
Command Syntax .............................................................................................4-2
Reserved Words and Symbols..........................................................................4-2
Entering a jQL Command Sentence .................................................................4-3
Default Data Definition Records ......................................................................4-3
jQL Output (Reports) .......................................................................................4-4
jQL Commands ................................................................................................4-4
Throwaway Connectives ..................................................................................4-5
File Specifiers...................................................................................................4-5
Record List Clause ...........................................................................................4-5
Selection Criteria Clause ..................................................................................4-7
Sort Criteria Clause ........................................................................................4-10
Using Clause...................................................................................................4-11
Output Specification Clause ...........................................................................4-11
Format Specification Clause...........................................................................4-13
USING Clause................................................................................................4-15
Command Options..........................................................................................4-15
Macros............................................................................................................4-16
jQL Commands ....................................................................................................4-18
BSELECT Command .....................................................................................4-18
COUNT Command.........................................................................................4-18
EDELETE Command.....................................................................................4-19
ESEARCH Command ....................................................................................4-19
LIST Command ..............................................................................................4-20
LIST-LABEL Command ................................................................................4-21
viii
LISTDICT Command .................................................................................... 4-22
REFORMAT Command ................................................................................ 4-22
SELECT Command ....................................................................................... 4-23
SORT Command............................................................................................ 4-24
SORT-LABEL Command.............................................................................. 4-25
SREFORMAT Command .............................................................................. 4-26
SSELECT Command ..................................................................................... 4-27
File Definition Records ....................................................................................... 4-29
Record Structure ............................................................................................ 4-29
Sublists - V Code ........................................................................................... 4-29
Data Definition Records ...................................................................................... 4-31
Record Layout ............................................................................................... 4-31
Special Field-mark Counts............................................................................. 4-32
Default Output Specification ......................................................................... 4-32
Predefined Data Definition Records .............................................................. 4-33
Conversion Codes................................................................................................ 4-34
Field 8 Codes (Pre-process)........................................................................... 4-34
Field 7 Codes (Output) .................................................................................. 4-34
Field 7 Codes (Input) ..................................................................................... 4-35
Processing Code Summary ............................................................................ 4-35
Multiple Conversion Codes ........................................................................... 4-36
Print Limiter Clause....................................................................................... 4-36
Controlling and Dependent Fields ................................................................. 4-36
Selections....................................................................................................... 4-36
Sorts............................................................................................................... 4-36
TOTAL Connectives...................................................................................... 4-36
BREAK-ON Connectives .............................................................................. 4-37
A Code - Algebraic Functions ............................................................................. 4-38
Syntax Summary ............................................................................................ 4-38
Summary of Operands ................................................................................... 4-39
Summary of Operators ................................................................................... 4-40
Field Number (FMC) Operand ...................................................................... 4-40
N (Field Name) Operand ............................................................................... 4-41
Literal Operand.............................................................................................. 4-42
System Parameter Operands .......................................................................... 4-43
Special Operands ........................................................................................... 4-43
Format Codes................................................................................................. 4-44
Operators ....................................................................................................... 4-45
B Code - Subroutine Call .................................................................................... 4-47
C Code - Concatenation....................................................................................... 4-48
CALL Code - Subroutine Call............................................................................. 4-49
D Code - Date Conversion .................................................................................. 4-51
D1 / D2 Codes - Controlling and Dependent Fields ............................................ 4-53
F Code - Mathematical Functions........................................................................ 4-54
Syntax Summary ............................................................................................ 4-54
Push Operators............................................................................................... 4-55
Arithmetic Operators ..................................................................................... 4-56
Miscellaneous Operators................................................................................ 4-56
Relational Operators ...................................................................................... 4-57
Logical Operators .......................................................................................... 4-57
Multivalues .................................................................................................... 4-57
Format Codes................................................................................................. 4-58
G Code - Group Extraction.................................................................................. 4-59
L Code - Length................................................................................................... 4-60
MC Codes - Mask Character ............................................................................... 4-61
Summary........................................................................................................ 4-61
Changing Case ............................................................................................... 4-62
Extracting Characters..................................................................................... 4-62
Replacing Characters ..................................................................................... 4-63
ix
Converting Characters ....................................................................................4-63
Converting Numeric Values ...........................................................................4-64
MD Code - Mask Decimal without Justification..................................................4-66
MK Code - Mask Metric......................................................................................4-67
ML/MR Codes - Mask Decimal with Justification...............................................4-68
MP Code - Masked Packed Decimal ...................................................................4-70
MS Code - Mask Sequence ..................................................................................4-71
MT Code - Mask Time ........................................................................................4-72
P Code - Pattern Matching ...................................................................................4-73
R Code - Range Check.........................................................................................4-74
S Code - Substitute...............................................................................................4-75
T Code - Text Extraction .....................................................................................4-76
Tfile Code - Translation.......................................................................................4-77
U Code - User Exit...............................................................................................4-79
x
General............................................................................................................. 7-1
Internationalisation .......................................................................................... 7-1
jBC................................................................................................................... 7-1
jBTP................................................................................................................. 7-1
jCL................................................................................................................... 7-2
jQL................................................................................................................... 7-2
jLP Spooler ...................................................................................................... 7-2
List Processing................................................................................................. 7-2
Migration ......................................................................................................... 7-2
System Housekeeping and Tuning................................................................... 7-3
Tape Operation ................................................................................................ 7-3
Index .........................................................................................................................1
xi
xii
Using the Manual
Summary of Chapters
1 Introduction gives an overview of jBASE.
2 jBC details the functionality and benefits derived from working with jBC.
Describes the file and directory organisation and outlines the library of
functions available to the application programmer. Also offers some
advice to the jBC programmer that should help you to produce efficient
code.
3 jCL describes the components of the jCL language and lists the syntax and
usage for each command.
4 jQL describes the components of the jQL language and lists the syntax and
usage for each command.
5 List Processing describes the list processing capabilities of jBASE and lists the syntax
and usage for each command.
6 jBASE Editors describes the features and functionality of the jED and ED editors.
Particularly useful for programmers.
7 jBASE Commands lists the jBASE commands and indicates where they are documented.
8 Environment Variables describes the various environment variables that are used with jBASE and
gives details of their usage.
9 Migrating to jBASE gives details of how to convert applications written in other dialects of
BASIC to jBC and the Open Systems environment.
xiii
Notation Conventions
The manual uses the following conventions when describing command syntax :
BOLD TEXT Text in this format represents required user input. The exact characters as shown
should be entered at the keyboard.
Italic text In a syntax specification, italics show parameters that must be entered and supplied by
the user.
Within descriptive text, italics are used to add emphasis, or to show a term that has been
defined elsewhere.
CAPITALS CAPITALS indicate keywords, file names or constants.
{} Braces are used to surround optional parameters within command specifications.
... The use of ellipses indicates a command parameter that can be repeated as many times
as required.
<ENTER> Capitals surrounded by angled brackets refer to actual keys on the keyboard. A series
of keys inside angled brackets such as <CTRL A>, indicate that the combination of
keys should be pressed simultaneously.
arg | arg A vertical line separating arguments means that at least one, if not both arguments
must be provided.
code or variable This style of text represents code or variables.
xiv
Errata and Comments
If you have any comments regarding this manual or wish to report any errors in the documentation, please
document them and send them to the address below:
xv
Chapter 1: Introduction to jBASE
Introduction to jBASE
jBASE is an application development and database management system that enhances and extends the UNIX
Operating System. jBASE also allows existing applications to be easily migrated from other DBMSs, including
PICK and REALITY.
jBASE was designed to be, and is, Database Independent. jBASE offers built-in Client/Server abilities,
embedded SQL functionality, an easy-to-use Spooler, and an easy-to-use enquiry language. The Application
Language, jBC is a super-set of Dartmouth BASIC and is ideal for developing business applications. The
compiler can optionally produce C or C++ Source code from the original jBC (BASIC) Sources.
Run-Time Components
The run-time components are designed for freedom of choice, efficiency and ease of use.
They consist of:
The jBASE External Device Interface (jEDI), which provides database independence and distributed
processing capabilities;
jBASEs own family of NF2 file systems, namely j1 and j2 files;
The jBASE query language (jQL).
Development Components
The development tools are designed for highly productive development, simple migration and run-time
efficiency of resulting software.
They consist of:
A set of tools for easy migration to jBASE from existing environments;
The jBC Programming Language, which is a compiled language and a superset of Dartmouth BASIC
allowing structured programming. Note that the jbc compiler can be directed to produce C or C++
source code too;
A set of development editors and debugging tools;
The jBASE job control language (jCL).
Administrative Components
Being an enhancement and extension of the UNIX and the Windows family of Operating Systems, jBASE takes
advantage of all the administrative functionality of the host environment. However, there are some extra facilities
provided over and above those of the host environment.
They include:
The jBASE Spooler (jLP)
Utility programs such as jbackup and jrestore
jBC Environment
jBC will run on any standard UNIX system and with any standard shell or editor. An easy to use
jSHELL is also provided.
jBC allows the programmer to choose his working environment to suit. It works equally with the Bourne,
C or Korn shell. Kernel configuration is not required to use the jBC programming environment.
jBC programs can be written using any UNIX editor. A context sensitive screen editor (jED) is provided
that is designed specifically for jBC programmers and jBASE users.
Utilities are supplied to access database files created under jBASE.
The final size of executable code is minimised, and duplication avoided, by sharing external object
libraries between all application programs.
A file or directory may be specified to hold all the jBC source. The finished executables may be held in a
different file or directory if required.
A global user library may be used to hold globally accessible user routines.
jBC Programming
jBC source code may be written using any system editor. Users unfamiliar with UNIX editors may wish
to use the jED editor;
The jBC compiler can be used to produce intermediate object code or a UNIX executable file;
Makefiles can be used to simplify the compilation process, especially if many files are involved. Their
use will also make upgrading and software maintenance an easier task;
If the system allows, use should be made of linked libraries when calling subroutines and functions. This
will reduce the size of the compiled code that would otherwise be produced;
Applications accessing jBASE files should make use of the existing routines held in the /usr/jbc/lib
directory.
jBC Comparisons
With BASIC
Both jBC and BASIC languages are derived from Dartmouth Basic;
jBC is an enhanced variant of BASIC. It contains all the commands and constructs necessary for
compatibility with other versions of BASIC. It also provides full interaction with UNIX system and
database files;
jBC can be quickly modified to retain compatibility with any future enhancements to the BASIC
language or its derivatives;
On a UNIX system, the jBC compiler will produce code that will run many times faster than the same
BASIC code compiled and run on any other UNIX based RDBMS environment;
jBC can access jBASE, C-ISAM, and UNIX files as well as records and files of other databases;
jBC debug facilities are greatly superior to those provided with other versions of BASIC.
With 'C'
The jBC compiler uses all the features of the cc compiler;
The jBC compiler can compile 'C' source and object files, as well as jBC source code;
/usr
/jbc
/config This file contains various configuration files for systems such as background processing and the
j-file(s)lock daemon.
/dev All external devices on the current system are described here.
jbcmessages This file contains all jBC error messages and may be edited by the user.
/include Various include files required at compile time are stored here. This directory is not present on a
runtime only system.
/lib This directory contains all the libraries required for linking executing jBC compiled programs.
Shared or Dynamic libraries are also stored here.
/src This directory contains any source code files that are distributed with the current jBASE release.
It contains extended user exit support, templates for Makefiles and jEDI interface code.
/tmp This is a general purpose temporary directory for runtime use.
Shared Libraries
Shared libraries contain code for jBC or C functions that is not linked (joined) to the users jBC program until
runtime. A single system will only ever load this library into memory once and any executing jBC programs will
share it between them.
SVR3.2 Libraries
Under SVR3.2 shared libraries must be constructed with extreme care with all function addresses defined to the
system before their compilation. All jBC libraries on this version of UNIX have been defined as shared (unless
the particular flavour of UNIX does not support shared libraries). However libraries produced by the
programmer to store callable jBC subroutines cannot be defined as shared and each program calling a subroutine
will contain a copy of the subroutine code. This can make for large executable programs on such systems.
SVR4 Libraries
Under SVR4 shared libraries are more commonly referred to as Dynamic Libraries and are at the same time both
simpler to use and more sophisticated. Dynamic Libraries are very easy to produce and information concerning
addressing need not be supplied to the compiler. Hence not only are jBC libraries Dynamic but libraries
produced to hold jBC subroutines will be as well. Large applications sharing many subroutines benefit greatly by
executing on SVR4 systems.
Formatting
The jED editor and the jfb formatting tool contain formatting algorithms that most developers will find
acceptable. Two different formatting methods are available where the CASE construct is concerned as there are
two equally valid formats for this statement.
The default indentation will use four spaces as the indent level and start each line that is not a label at indentation
level 2 (Column 8). However, this may be changed should the internal standards of a particular organisation
differ from this. Labels are formatted to start in the first column of the source line. This gives the general
appearance shown here:
Label:
CRT "The first main line"
IF Variable = 10 THEN
CRT "Variable = 10"
END ELSE
BEGIN CASE
CASE A = 9
CRT "A = 9"
CASE 1
CRT "A is something else"
END CASE
END
LOOP
A = 10
WHILE A DO
A--
REPEAT
FOR I = 1 TO 5
CRT I
NEXT I
Options can also be specified after the file list by delimiting with a parenthesis mark in the format jfb file (A,P
For example, to list the file batch.b in sub-directory source to the printer, indenting by four spaces per level and
starting non-labelled code at 8 spaces from the left margin:
jfb -L4,2 -V source/batch.b
Structured Coding
The use of structured code is widely recognised to improve readability and maintenance of code. The jBC code
contains many structured statements that allow the programmer to avoid producing "spaghetti" code. In
particular the LOOP and FOR statements coupled with BREAK and CONTINUE, will avoid the need for the
GOTO statement within a looping construct. The use of CASE statements is also recommended.
The GOTO statement should be avoided at all costs, although there are some valid instances when it may be
useful such as branching to error routines that will never return.
Naming Conventions
The jBC compiler is a case sensitive compiler. All keywords within the language MUST be specified in upper
case. Identifier names, may however be specified in any combination of upper and lower case characters. Over
time we have found that the use of capitalised variable names greatly improves the readability of the code. Thus
we have adopted this as a standard technique. The term capitalisation refers to naming identifiers like this:
FileName; RecordName; StopFlag.
CATALOG Command
The jBASE CATALOG command should be executed from the application directory rather than using link
names and the application id should be used. The reasons for executing the CATALOG command from the
application directory and application id are that the .profile script will have set up the required environment
variables correctly and that the correct file permission will be used when creating and deleting UNIX
executables and directories. The format of the jBASE CATALOG command is as follows.
CATALOG SourceFilename Itemlist
When first invoked the CATALOG command will create a $HOME/bin directory into which the UNIX
executables will be placed. A $HOME/lib directory will also be created into which any subroutines will be
placed. The lib directory contains a jLibDefinition file, which describes how to build the subroutines into shared
libraries. The entries in the jLibDefinition file are described below:
libname naming convention for shared object files.
exportname export list of shared objects. Used as cross reference to find subroutine functions.
maxsize maximum size of a shared object library before creating another.
When the maximum size of a shared library object is reached then a new shared library object will be created by
the CATALOG command. The new shared library objects are named according to the definition of libname and
are numbered sequentially. For example:
libname=lib%a%n.so
where
%a = account or directory name
%n = number in sequence.
If subroutines were cataloged in the user account name, fred then the shared object libraries produced would be
named, libfred0.so libfred1.so libfred2.so and so on.
Note: To guard against libraries being cataloged incorrectly, perhaps under the wrong user account
name, the definition of libname should be changed to libfred%n.so. This will ensure that any shared
objects are created using the proper user account name.
The shared library objects, .so files, contain the UNIX executables for subroutine source code. The shared
library objects are linked at runtime by the jBASE call function, which utilises the dynamic linker programming
interface. The dynamic linker will link shared libraries at the start of program execution time, or when requested
by the jBASE call function. For example, each executable created using the jBASE compiler will be linked with
the jBASE jEDI library functions, libjedi.so, at compilation time. This shared library enables database record
retrieval and update and will be loaded into memory by the dynamic linker when an application executable starts
execution. However the shared library containing any subroutines required by the executing program will only
be loaded into memory when initially requested by the subroutine call. Only one copy of any shared library is
required in memory at any time, thus reducing program memory requirements.
The $HOME/lib directory also contains a directory where all the subroutine objects, .o files, are held. These are
required for making the shared library, .so files.
The $HOME/lib directory also contains an export list, .el file, built by the CATALOG command, which is used
as a cross reference when dynamically linking shared objects at run time.
The main application program executables are placed into the $HOME/bin directory.
RUN Command
The RUN command is used to execute compiled but uncataloged jBC programs. Whenever possible, you should
catalog your programs rather than RUN them - the RUN command is only maintained for compatibility with
older systems.
The format of the RUN command is as follows.
RUN SourceFilename ProgramName (options
Note: If the application performs a CHDIR() function, and the debugger needs to access a file in the
'current' directory by default, then it will attempt to access it in the directory specified by the CHDIR()
function and not the one from which the program was executed.
Other debug features are available through the JBCDEBUGGER environment variable. See the Environment
Variables chapter for more details.
Examples
menu -Jd
This command will start up the menu program and enter the debugger before executing the first command with a
message similar to:
Option -Jd seen on command line
Source MENU.PROCESSOR.b, Line 1, Level 2
jBASE debugger>
Normal debugging operations can now be carried out.
menu -Jd -Jp./invoices:./inv.routines:../src/mainlib
This command executes the menu program and enters debug. Any debug commands requiring reference to the
source, such as w, will then look for it in a directory other than the current one.
Debugger Commands
This section details all the commands available to the user from the jBC debug prompt.
References in the Command column to expr refer to an evaluated expression. Expressions are detailed after the
command table. The current file name and current line number are internal debugger variables. On entry to the
debugger these are set at the current program file name and line number about to be executed.
Many of the commands detailed here are not available when a program has been compiled with the limited
debugger. The limited debugger is linked to the program when the -J04 argument is used on the jbc command
line. The -JO4 options is normally only used on production release applications. The ? command will list all
commands available. All commands are available when the full debugger is in use.
Restrictions.
If you have a Command Level or Break/End Restart feature in effect, or the break key is disabled, the available
options are restricted to:
a Abort program
q Quit program
c Continue (may be allowed, depends on reason debug was entered)
end Terminate debugger.
o Log off.
Note that there are several ways in which the break key can be disabled. You can use commands such as
INHIBIT-BREAK-KEY or BREAK-KEY-OFF. In these cases, the debugger is never entered. Another way is to
execute a BREAK OFF statement within the program. In this case, the debugger will still be invoked if a run-
time error occurs - such as trying to read a record from a non-file variable.
Command List
?
Display a help screen showing all available debug commands and the program status.
>filename
Open and truncate the file filename and send it the current breakpoints and trace table entries. This can be used
in future to replicate the current environment by the use of the < command. Note that you may write debugger
scripts yourself with an editor rather than use the > command.
<filename
Open the file filename, then read and execute each line as if it has been entered at the keyboard. Any current
trace or breakpoint table entries are deleted then replaced by those recorded in filename.
!command
Spawn another process and execute the UNIX or jBASE command. The previous command thus used can also
be recalled and executed by the !! command.
<CTRL D>
Display the next 11 lines of source in the current file.
#text
Ignored, and so can be used as a comment line in debugger scripts later executed with the < command.
a{-nn} {mm}
Kills the jBC program and any parent process or program that called it. The program aborts with an exit code of
203, and the kill signal is sent to any parent process. The nn value is used to change the exit code, whilst the mm
value changes the signal number sent with the kill command. Operation of this command can be altered by
setting the Command Level Restart option - see the Systems Housekeeping chapter of the System Administrators
Reference Manual for more details.
b
Display all currently active breakpoints.
b {-t} nn{,file}
Set a breakpoint at line nn in the current file or that specified by the file modifier. If the -t option is specified
then the breakpoint will cause a display of all the trace variables rather than halting the program.
b {-t} varname
This form of the b command will cause the debugger to be entered whenever the contents of the specified
variable are changed.
c
Continue execution of the program.
d {-tbed} {*nn}
Delete breakpoint and/or trace table entries, and will normally prompt for confirmation. The t and b switches
refer to trace and breakpoints respectively. The * switch deletes all of the specified entries without prompting.
The nn switch deletes the entry nn in the given trace or breakpoint table, also without prompting. The d and e
switches respectively disable or enable the given entry without removing it from the table.
e name
Edit the file specified by name. This file is then the file used by other debug commands such as <CTRL>+D.
end
Synonym for 'quit''.
f {on|off}
A debug breakpoint is set for a filename change. This break can be set to on or off. If the program is continued
(C command) the debugger will be entered the next time the source file changes.
h {-rs{n}} {nn|on|off }
Displays a history of the source lines executed, and current status of the debugger commands used. The on and
off switches toggle the recording of lines executed, and when on, the nn value gives the number of executed lines
to display (1024 maximum). The -r switch displays in reverse order, and -s{n} shows n source lines.
l {-acf{nn}} text
Locate the string text in the current file. The switches used are: a to look for every occurrence; c to make the
search case insensitive; nn to limit the search to the next nn lines; f to start the search from the start of the file.
The command l/ will execute the previous locate.
m
Displays the current memory status. Shows space allocated by the function malloc().
n {nn}
Displays the next nn lines of source from the current file, which is automatically loaded by the debugger if the p
command has been used or it resides in the current working directory.
off
Enter o or off to log off. If you enter off (or OFF), the effect is immediate. If you enter o (or O), you will be
prompted for confirmation. The same restrictions apply as for the OFF command; if there are non-jBASE
programs active, OFF will only terminate jBASE programs until it encounters the first non-jBASE program -
probably the login shell..
p {pathlist}
Defines the list of directories and pathnames (delimited by :) that the debugger will then search to find source
codes. p without a pathlist displays the current Path.
q {nn}
Quit the program. nn is the termination status returned to any calling program.
r device
The debugger will take all input from, and send all output to, the specified device. Note that if the device is
another terminal (or Xterm shell), that you will need to prevent the target shell from interfering with the input
stream by issuing the sleep command to it. A large value should be used or the sleep should be issued
repeatedly in a loop.
s {-t{m}d} {nn}
Continue execution of jBC code in single line steps before returning to debug. The value nn changes the number
of lines executed before returning to debug. The -t switch is used to display the trace table after every line
executed, rather than wait for entry to debug. The d switch sets a delay before executing each line of code. m is
used to set the delay in seconds (default is 5 deci-seconds).
t {-fg} expr
Add the value specified by expr to the trace table. When debug is entered, all the values in the table are
displayed. The f switch is used to fully evaluate expr, whilst the g switch extends the display of expr to all levels.
v {-gmsrv} {expr}
Evaluate expr and display the result. The effects of the switches are: g to extend the display of expr to all data
areas. m to allow variable modification within expr. When a variable is modified with the m option binary
characters may be entered using the octal sequence \nnn. The sequence \010 would therefore be replaced by
CHAR(8) in the modified variable. The sequence \\ evaluates to the single character \ and a sequence such as \x
evaluates to the single character x (i.e. the \ will be lost).
w nn
Display a window of source code. The default is 9 lines with 3 before and after the current one. The value nn is
used to change this parameter.
Example 1
jBASE debugger> t NEXT.ID
t 1 : NEXT.ID
The variable NEXT.ID has been put into the trace table and the debugger has verified the entry. Whenever the
program goes into debug during this session, the variable contents will be displayed.
Example 3
jBASE debugger> s 5
Single step count exhausted
Source ST.XFER.b ,Line 5, Level 2
NEXT.ID : (NULL)
This command executes the next five program lines before re-entering debug to display a status message and the
traced variable contents. If any instruction is encountered that prints to the terminal screen, then this will do so
as normal, and the above debug output is then written on the following line.
Example 4
jBASE debugger> b 40
0040 20 * MAIN INPUT SCREEN *
b 0 : 40, ST.XFER.b
A breakpoint is set so that program execution halts and debug is entered at line 40. The debugger displays the
line in the source and shows the number of the breakpoint set; in this case breakpoint zero.
Example 5
jBASE debugger> d
t0 : s2 - delete (Y/N) n
t1 : NEXT.ID - delete (Y/N) n
b0 : 40 , ST.XFER.b - delete (Y/N) n
This command is used to delete trace and breakpoint table entries. When used in the simplest form as shown, the
debugger lists each trace table and breakpoint table entry in turn, and prompts for deletion. If the response
entered is no as above, then the next entry is displayed. If the response is Y to delete, then the debugger responds
with a message similar to:
t1 : \NEXT.ID - deleted
before presenting the next entry for deletion.
jBASE debugger>d -b 0
b0 : 40 , ST.XFER.b - deleted
The command used in this form has deleted the breakpoint b0 from the table. Note that no prompt is given
before deletion.
jBASE debugger>d*
The trace table and breakpoint table are deleted, without the user being further prompted.
Example 6
jBASE debugger>>stxfermb.dbg
The current trace table and breakpoint table entries together with the execution count set, and any comments are
written to the stxfermb.dbg file in the current directory. The file is created if it doesn't exist but if it does, the
previous contents are overwritten.
Example 8
jBASE debugger>d -tb*
t0 : s2 - deleted
b1 : NEXT.ID - deleted
b0 : 40 , ST.XFER.b - deleted
jBASE debugger>b
jBASE debugger>t
jBASE debugger>
The command deletes the trace table entries (t) and the breakpoint entries (b). The * option denotes that all
entries are to be deleted and no prompt is given.
The following b and t commands just return the debug prompt to show that the breakpoint and trace tables are
empty.
Example 9
jBASE debugger>< stxfermb.dbg
d *
p .
Source path :.
t s2
t0 : s2
t NEXT.ID
t1 : NEXT.ID
b 40 , ST.XFER.b
0040 20 * MAIN INPUT SCREEN *
b0 : 40 , ST.XFER.b
h OFF
History trace turned OFF
jBASE debugger>
The above command takes the contents of the stxfermb.dbg file and executes each debug command on screen
one after the other displaying the result. The final outcome is that all of the trace and breakpoint entries
previously saved to the file are reinstated.
Example 10
jBASE debugger> b
b0 : 40 , ST.XFER.b
jBASE debugger> t
t0 : s2
t1 : NEXT.ID
The b and t commands display the trace and breakpoint table contents.
Example 12
jBASE debugger> s
008 IF A = 45 THEN
009 FORM = "A string"
010 VAR2 = "Another string"
FORM : (NULL)
The command is given to execute one line of the program before re-entering debug. The variable FORM is in the
trace table, so its contents are automatically displayed on re-entry. The line number given is the position of the
counter and shows the program line number following the one just executed.
Example 13
jBASE debugger> s
Source ST.XFER.b , Line 10 , Level 2
FORM : A String
Another line of code has just been executed, this time it was line 9 and the program execution counter is now
pointing to line 10.
Example 14
jBASE debugger> m
Memory utilisation
Free space : Small blocks 10400,
Ordinary blocks 6796,
Total 17196
Used space : Small blocks 400,
Ordinary blocks 44168,
Total 44568
The system memory allocation is displayed on screen.
Example 15
jBASE debugger> a -9 111
Signal 9 sent to parent process 73
jBASE debugger termination , exit code = 111
Welcome to UNIX
login :
The a command is used to halt program execution with an error code of 111. In addition, signal 9 is sent to the
parent process. This could be the calling menu driver program, but in this case, as the program was started
directly from the shell, the effect is to log the user off.
Execution History
h {-rs{n}}{nn|on|off}
-r display lines in reverse order
-s{n} display n lines of source (default is 1).
nn limit the history buffer to nn lines of source
on|off toggle the saving of source lines executed
This command keeps track of the source command lines executed during a debug session. The last 1024 lines
are held in a circular buffer, and when full, the most recent command line displaces the oldest. It can be toggled
on or off, and it is normally switched off by default. The command and switches have no effect unless activated
by switching on.
Commands executed from subroutines and CHAINed programs will also be displayed.
h on
This will switch on the command line audit, and every line of code subsequently executed during the debug
session will be logged for reference, until the command is switched off or the debug session ends. The following
commands assume the command line history is switched on.
Locating Strings
l{-acf}{nn}text
-a show all occurrences (defaults to the first occurrence)
-c ignore the case of any text
-f start the search from the first line of the source
-nn limit the search to the next nn lines of source
text text to locate
This command locates text in the source file currently being executed and displays the line or lines of code
containing it. The file to be searched may be changed by using other debug commands such as e.
l Heading
Used in its simplest form, the command will search the source from the current line position, to the end of the
file, for the first occurrence of the text "Heading". If an exact match is found, then the line is displayed.
l -c Heading
The -c switch is used to ignore the case of the text. In this case, the first line found with the "Heading" text in any
variety of upper and lower case letters will be displayed.
l -a NAME
The -a switch is used to locate and display ALL the source lines containing the text "NAME" in upper case
letters only.
l -ac name
This command will display all lines of source code that contain the text name, with the characters being in any
combination of upper or lower case letters.
l -a22 NAME
The characters NAME will be searched for, and if located in the next 22 lines starting from the current one, each
line where it is found will be displayed.
l -f /usr/tutor/BP/INVOICE.b NAME
The -f switch is used to search from the beginning and display the first line found containing the characters
NAME from the file INVOICE.b held in the /usr/tutor/BP directory.
l -acf ./PAYMENTS.b money
The most complex form of the command as shown will search the PAYMENTS.b source, held in the current
directory, and display every line from it that has the text money in any variation of upper or lower case letters.
Display Variable
V{-gvmrs}
V ANS
The simplest form of the command will display the contents of the variable next to the variable name, in this case
ANS. This will only produce a display if the source is at level 1, or in the home directory. If the variable has not
been assigned, the value (NULL) is displayed. If the value assigned happens to be null, however, then a blank
(null) will be displayed next to the variable name.
Note: If your program contains the same variable name in both local and global common areas the
debugger will operate on each instance of the name in turn.
Syntactical Elements
argument A value or variable passed to a procedure or function at the
time of execution.
constant A value that does not change throughout the program.
expression A component part of a program that defines the computation
of a value.
function A function is a program unit in the C or jBC language. It is a
section of code that can be passed values and may return a
value.
identifier A string of characters used to identify or name a program
element that can be a variable, function statement or a higher
level unit of the program.
label A numeric or alphanumeric identifier associated with a line or
statement in the program, and used to refer to it from another
section of the program.
operand A quantity on which a mathematical or logical operation is
performed.
operator An entity that can be applied to one or more values or
operands to generate a result or resultant.
parameter This refers to data passed to a function, subroutine or
procedure.
resultant The value output as a result of the action of a function,
operator, expression or procedure upon given data.
statement A unit with which a program is constructed.
subroutine A self enclosed set of program statements that are not part of
the main program flow. Program execution control is
transferred to it and only on completion does control pass
back to the main program body.
value A string of numeric, alphabetic or alphanumeric characters
representing a quantity, data or information.
variable A string of characters used to identify a changeable value
stored within the computer.
Variables
A variable is a representation of data. The data stored in a variable can be either a string or a numeric, which can
change dynamically during a program.
Strings can be of any size including the NULL string of 0 bytes in length.
In many systems variables are "typed", I.E. It can only hold a certain type of data. The jBC language uses
"typeless" variables, allowing any kind of data to be stored within them. In addition, there are no limitations on
what may be stored in a byte within a variable. The full range of 8 bit values 0x00 to 0xFF may stored within
variables.
There is no limit to the number of variables that can exist within a jBC program.
A variable name identifies the variable and can be contain almost any sequence of ASCII characters, starting
with an alphabetic, apart from spaces, commas, underscores, hyphens and mathematical operators.
A jBC reserved word cannot be used as a variable name and the compiler will signal an error condition if it
detects the illegal use of a keyword.
Constants
A constant is similar to a variable except that it holds a value that remains unchanged throughout the execution
of a program.
The value of a constant may be either of a numeric or a literal string enclosed in quotation marks.
A string constant must be enclosed in single or double quotation marks, aString or the '/' , /aString/character.
Any of the delimiters will be included as part of the constant if the whole constant is enclosed between a
different delimiter.
Examples
EQUATE PI TO 3.14159265359
Sets the value of PI to 3.14159265359
Assigning Variables
An assignment statement is used to allocate a value to a variable. The value assigned can be a number, literal
string or any valid expression.
Syntax
variable = expression
variable is the reference that will be used within the program to access the expression assigned to it. The value
of expression is stored in memory and will be accessed directly whenever variable is referenced.
If during the execution of a jBC program, a variable is encountered which has not been properly assigned, then a
default value of zero is assigned to it, the debugger is entered, and an error message is displayed on the terminal:
Invalid or un-initialised variable -- ZERO used
VAR varname, Line lineno, Source filename
Examples
1. Number = 250
assigns the value 250 to variable Number.
2. Sum = 27 + 31 + 19
Reserved Words
Reserved words are words that cannot be used within a jBC program as an identifier, variable name, subroutine
labels or statement labels. The use of a reserved word will be shown when the program is compiled, and
compilation will fail.
jBC reserved words are :
ABORT CRT GETCWD MATREADU READP SYSTEM
ABS DATA GETENV MATVAR READPU TAN
ALPHA DATE GETLIST MATWRITE READT THEN
AND DCOUNT GO MATWRITEU READU TIME
ASCII DEBUG GOSUB MOD READV TIMEDATE
ASSIGNED DEFC GOTO NE READVU TO
AT DEL GROUP NEXT REGEXP TRANSABORT
BEGIN DELETE GT NOT RELEASE TRANSEND
BITCHANGE DELETELIST HEADING NULL REM TRANSQUERY
BITCHECK DIM ICONV NUM REMOVE TRANSTART
BITLOAD DIR IF OCONV REPEAT TRIM
BITRESET DO IN OFF REPLACE TRIMB
BITSET DTX INDEX ON RETURN TRIMF
BREAK EBCDIC INPUT OPEN REWIND UNASSIGNED
BY ECHO INPUTCLEAR OR RND UNLOCK
CALL ELSE INPUTERR OUT RQM UNTIL
CAPTURING END INPUTNULL PAGE RTNDATA USING
CASE ENTER INPUTTRAP PASSDATA RTNLIST VAR
CHAIN EQ INSERT PASSLIST SELECT WEOF
CHANGE EQU INT PERFORM SENTENCE WHILE
CHAR EQUATE IOCTL PERROR SEQ WITH
CHDIR EXECUTE LE PRECISION SETTING WRITE
CHECKSUM EXIT LEN PRINT SIN WRITELIST
CLEAR EXP LN PRINTER SLEEP WRITEP
CLEARFILE EXTRACT LOCATE PRINTERR SORT WRITEPU
CLOSE FIELD LOCK PROCREAD SOUNDEX WRITET
COL1 FIND LOCKED PROCWRITE SPACE WRITEU
COL2 FINDSTR LOOP PROGRAM SQRT WRITEV
COLLECTDATA FLOAT LT PROMPT STEP WRITEVU
COMMON FOOTING MAT PUTENV STOP XTD
CONTINUE FOR MATBUILD PWR STR
CONVERT FROM MATCHES READ SUB
COS FUNCTION MATPARSE READLIST SUBROUTINE
COUNT GE MATREAD READNEXT SYNC
Expression Evaluation
Expressions are evaluated according to the precedence of their operators but if an expression contains two
operands with the same precedence the expression to the left is evaluated first.
Expressions enclosed in parentheses are evaluated first and then treated as a single expression. Within the
parentheses, normal operator precedence applies.
Where parentheses are nested, then evaluation begins with the innermost parenthesised expression, followed by
the others in turn.
Examples
12+4+16/4+36/9 evaluates to 24
6*8/12-3*2^4+"7" evaluates to -37
(2^3+1)/(27/(9/3)) evaluates to 1
1
String formatting does not have an operator as such but is implied by its context. This rather unsatisfactory situation is forced upon jBC in order to maintain compatibility with older dialects of the
language. It is a non associative operator, which means it may not be combined with itself.
Logical Operators
Logical operators are used to perform Boolean tests on relational or arithmetical expressions.
The logical operators available in jBC are:
AND & are used to perform a logical AND
OR ! are used to perform a logical OR
A logical expression operates on the outcome result being TRUE or FALSE.
An expression that evaluates to be zero or NULL is considered FALSE, whilst all other outcomes are considered
to be TRUE.
Logical operators have lowest precedence in any expression, and so any relational or arithmetic operation is
performed first when used in a logical expression.
The result of a logical operation can be summarised:
Operation Result
X AND Y TRUE if X is true and Y is true.
FALSE if X is false, or Y is false.
X OR Y TRUE if X is true or Y is true.
FALSE if both X and Y are false.
The NOT function can be used to invert the result of the expression.
String Expressions
Strings may be referred to or built up as a string expression, which could be one of:
variable: A = "abcd1234"
constant: "ABCD1234"
Concatenation: "ABCD":"1234"
substring: A [5,4] (evaluates to 1234)
String Concatenation
Data strings are concatenated by using the CAT operator. The CAT and ':' operators are functionality equivalent.
Concatenation of two strings appends the second string to the first. Concatenation of a series of strings is done in
order from left to right, and parentheses may be used to make a particular operation take precedence.
General String
S[start#,extract#] = expression
S is the original string variable, and start# gives the starting character position, whilst extract# gives the number
of characters to extract from the string.
E.g. A="abcdef" ; X=A[3,2] assigns characters cd to X
Dynamic Array
S{<{field#{,value#{,subval#}}}>}{[start#,extract#]}=expr
S is the original dynamic array. If referenced, field#, value# and subval# refer to the array's field, value and
subvalue position respectively, whilst start# gives the starting character position in the array element, and
extract# gives the number of characters to extract from it.
E.g. D001<2,3>[3,2] will extract the third and fourth characters from the third value in the second field of the
file record D001. If D001 holds 'GE123^F]123]ABCDEF^29' then the characters CD will be extracted and
assigned.
Dimensioned Array
S(row#{,col#}){<{field#{,value#{,subval#}}}>}
{[start#,extract#]}=expr
S is the original dimensioned array. If referenced, row#, and col# refer to the array's row and column position
respectively. If referenced, field#, value# and subval# refer to the array's field, value and subvalue position
respectively, whilst start# gives the starting character position in the array element, and extract# gives the
number of characters to extract from it.
Relational Expressions
A relational expression compares values or expression resultants to provide an outcome of true (1) or false (0). It
consists of a relational operator applied to a pair of literal or arithmetic expressions.
RELATIONAL OPERATORS
Symbol Operation
= EQ Equal to
> GT Greater than
< LT Less than
>= GE Greater than or equal to
<= LE Less than or equal to
# < > NE Not equal to
MATCH(ES) To use pattern matching
Relational operators have a lower precedence than arithmetic and string operators, and so are performed after
these within a complex expression.
An arithmetic relational expression consists of two numerics or numeric expressions separated by a relational
operator.
All other combinations of a pair of string or numerics within a relational expression are treated as a string
relational expression. In this case, numerics are treated as string values.
The null string as part of a relational expression is treated as being less than zero.
Program Layout
Blank Lines
A blank line within the jBC source code is one where no characters appear apart from the carriage-return,
linefeed continuation characters.
Whitespace
Whitespace characters are used to separate words, commands and statements on a program line. It can be entered
using the SPACE BAR or TAB KEY.
Presentation
The presentation of source code can greatly improve the appearance and readability of a program.
Recommended programming style is shown in the Programming Advice section of the jBC Language Overview
chapter of this manual.
Blank lines in the source program are ignored by the jBC compiler.
Spaces on a source program line are also ignored by the compiler unless they are part of a literal string.
Example
! Example of formatted code
CrtJim: ;* CRT subroutine
CRT "Hello Jim" ;* Display the message
IF Day = 14 AND Month = 7 THEN ;* Special?
CRT "Happy Birthday!" ;* Greetings
CRT "29 Again!" ;* Hmmm!
END
RETURN ;* To caller
Execution
A comment should start with one of the following tokens:
REM ! *
The comment character should be placed at the start of a line or statement and is ignored by the jBC compiler.
The special comment line !! is used in conjunction with the jfb listing program. When the program is listed
using jfb the !! comment will cause a page throw to be inserted in the listing. This can be useful for hard copy
listings as it enhances the presentation of the code.
Example
REM This part of the code is to overcome
* the problem we have with different terminal
* types.
! START OF MAIN PROCESSING
NAME = RECORD<4,2> ;* Get name from record
Line Continuation
It is possible to continue jBC statement sequences or comments over more than one line.
This is done by using the \ character or the ... ellipsis sequence at the end of a line. The line is then seen as one
continuous line by the compiler. This is useful for formatting code lines that are hard to read on a single line.
Program Files
Applications written with the jBC language would generally be composed of three distinct parts:
Source Code
Run-time Executable Code
Libraries containing common functions and subroutines
Variable Formatting
Numeric values in variable assignments, expressions or CRT, PRINT and INPUT@ statements can be formatted
using format strings. This will produce a formatted output display of the raw data string.
Multiple format strings can be applied to a variable expression, and if used, will be applied from left to right.
The syntax of this construct is as follows:
Syntax
VARIABLE "{f}{}{,}{d}{fieldwidth}"
f This character specifies the field justification. L
specifies left, and R specifies right justified within the
field.
The character appends a character to the front of
the field and takes up one position in the specified field
width. The actual character output will depend on your
locale setting - see the Internationalisation chapter in
the System Administrators Manual.
, This puts in a , as a separator for thousands. It takes up
one position in the specified field width.
d This is a single digit giving the number of decimal
places to display.
fieldwidth Gives the width of the field in which the value is held,
and can be padded out by:
#... or #n fill with spaces given
%... or %n fill with zeroes given
*... or *n fill with asterisks given
Pattern Matching
Pattern matching functionality is provided allowing comparisons between string variable contents. This
compares the string contents to a specified pattern or patterns, with the outcome being 1 (true) if the patterns
match, or 0 (false) if the patterns are different.
Pattern matching is performed by using the MATCHES or MATCH operators.
The specified pattern for matching can contain any combination of the following within quotes:
n is an integer that gives the number of alphabetic characters in
{n}A
the pattern.
{n}N n gives the number of numeric characters in the pattern.
The use of 0 as the value of n implies any number of the specified character, including a null
value.
Date Conversions
Dates are generally required in differing formats, and so an internal date format is used to store them on disk. As
this is simply a number, a conversion code is required to format it to the required output display. The codes are
also used to format strings.
Date conversion codes available are:
Code Effect
D{y}{d} The y value is the single digit 0 - 4 and
specifies the number of digits in the year
field. Default value is 4.
The d value is a single non-numeric
character used to delimit the day, month and
year fields. If omitted, the month is given in
alpha character format, otherwise the month
is in two digit numeric format.
DI This is the opposite of the above conversion,
and when used to format a date output, will
convert a date to internal format.
DD, DJ, DM, DMA, These codes convert the day, month and year
DQ, DW, DWA, DY components of dates to and from internal
DAY formats.
The conversions can be used with the ICONV and OCONV functions (see later). The OCONV function converts
internal formats to output formats. The ICONV statement converts external (Output) formats to internal form.
Program Flow
The following commands and constructs, are used to change the execution path of the linear program flow by
branching to another part of the current or even another program. The branches can be unconditional as with the
GOTO and GOSUB statements, or conditional on the result of an expression as with the IF statement.
GOSUB
The GOSUB command is used to branch to a local subroutine, which is identified by the line label used. When a
RETURN statement is encountered in the subroutine, the program is transferred back, and execution continues at
the line following the GOSUB.
ON .... GOSUB
This construct is used to conditionally branch to one of a list of local subroutines depending upon the value of a
variable or expression. The variable or expression resultant must be an integer in the range 1 to n, where the
value n specifies the number of subroutines. Execution control passes to the nth subroutine in the list provided
with the construct.
IF ... THEN
This construct allows the conditional execution of a sequence of statements. The conditional expression is
evaluated and if the resultant value is 1 or true, then the sequence of statements following the THEN command
are executed. If the value is 0 or false, the statements following the ELSE command (if any) are executed.
It is possible to perform actions based on complex testing of parameters by nesting, or successively repeating an
IF ...THEN clause as part of another.
CASE
This construct allows the conditional execution of a sequence of statements and is used in a similar manner to the
IF ... THEN construct. It differs in that the conditional expressions are examined one at a time, and so makes the
program much more modular and easier to follow.
Looping Constructs
A loop is a series of statements that are executed repeatedly for a specified number of repetitions, or until
specified conditions are met.
To repeat a procedure a set number of times, jBC provides the FOR ... NEXT loop. This allows the programmer
to set a counter that is used to monitor the number of times the loop has been repeated. The repeat of the
procedure can also be made dependent upon specified conditions.
The LOOP statement is used where the number of times a process needs to be repeated is not known, but
depends upon the value of a particular parameter. The loop is repeated while a variable holds a given value, or
until it contains a given value.
Loop constructs may be nested. This means that statements forming a complete loop may be enclosed within
another loop. This in turn can be completely enclosed in another. Loops may be nested to any number of levels.
The BREAK (or EXIT) and CONTINUE statements can be used within loops to cause premature termination of
a loop or to immediately begin the next iteration of the loop. They act upon the innermost loop in the program
structure. BREAK or EXIT will cause the immediate termination of the innermost loop. CONTINUE will
abandon the current iteration of the loop and immediately begin the next iteration of the loop.
Example
FOR I = 1 TO 10 UNTIL I = A
CRT I
A += C
IF A = 5 THEN BREAK ;* End when A is 5
NEXT I
Argument Passing
One or more arguments separated by commas may optionally be passed to an external subroutine as an argument
list. An argument can be a variable, constant, array or expression representing a value.
When an argument list is passed to the subroutine, the SUBROUTINE statement must also contain an argument
list with the same number of arguments as is being passed to it. Values passed in this way can be modified by the
subroutine, and when the RETURN statement is encountered, the modified values are returned to the calling
program.
C Functions
C functions may be freely mixed with jBC programs and data may be passed to them and received from them.
One or more C function is defined in its own .c file and is specified to the jBC compiler in exactly the same
manner as a jBC .b file. C functions referenced in a jBC program must be declared to the compiler using the
DEFC statement (see later).
Example
PROG.b
001 DEFC INT Cfunc(INT) ;* C func returns integer
002 Number = 45
003 CRT Cfunc(Number)
004 BigNo = Cfunc(1000)
005 CRT BigNo
func.c
int Cfunc(Num)
int Num; /* Integer parameter */
{
return Num*1000; /* Multiply and return */
}
Arrays
An array is a variable where related data is held together as separate entities. Each entity is referred to as an
element of the array. An array takes the form of an ordered set of data and each element can be addressed
separately.
jBC allows the use of two types of array :
Dimensioned arrays for holding data in the form of lists or tables.
Related data is held using a single variable name, and indicating the number of separate elements
involved. More details are available in the section on Dimensioned arrays later in the chapter.
Dynamic arrays for holding file data and lists of unknown length.
Data kept as records on the system may be accessed in the form of a dynamic array rather than in list or
tabular format. Data held as a dynamic array reflects its structure as held on the physical disk. More
details are available in the section on Dynamic arrays later in the chapter.
Dimensioned Arrays
A dimensioned array is a variable that has more than one piece of data stored within it. All the data within the
array is usually related in an ordered fashion, and each separate entity is called an element of the array.
Dimensioned arrays generally take the form of a vector (list), or a matrix (table).
Vectors
ADDR(4) 6, New Road, Oldtown, OL8 7MB
The above one-dimensioned array is also referred to as a vector. The first element has a value of 6, the second a
value of New Road, and so on. The first element is referenced by the variable ADDR(1), the second by variable
ADDR(2) and so on.
Matrices
array MULT(3,5)
1 2 3 4 5 column
row1 2 4 6 8 10
row2 7 14 21 28 35
row3 9 18 27 36 45
The above two-dimensional array or matrix holds part of a multiplication table. It consists of rows and columns,
which are specified when referencing the element.
Setting up an Array
Before an array can be used in jBC, it must be set up using the DIM, DIMENSION or COMMON statements.
The separate elements of the array can then be assigned values by reference to the variable in the normal way, or
they can be read into the array from a file using the MATREAD or MATREADU statements.
Dynamic Arrays
A dynamic array is a vector in which the data corresponds to the fields of a jBASE file record.
A jBASE record is divided into fields, values, and subvalues. The delimiter used for each is displayed using ^
(carat), ] (right bracket), and \ (backslash) respectively. These same delimiters are used to separate the different
elements of the dynamic array, and can be obtained with the keyboard by using the control key with the character
key in the jED editor.
Examples of dynamic arrays are:
1. MAIN Joe Smith^26^Male^Analyst
This is a dynamic array made up of four fields which give the name, age, sex and job of the person
referenced.
2. PERS Joe Smith^26]2.4.68^Male]Married\3children
The details in the array have been extended to include values and sub-values. The second field holds
two values for age and date of birth. The third field holds two values for sex and status. The status value
is further split into sub-values for marital status and children.
Example
Using the above examples:
MAIN holds Joe Smith^26^Male^Analyst
PERS holds Joe Smith^26]2.4.68^Male]Married\3children
MAIN<3> holds Male
PERS<1> holds Joe Smith
PERS<2> holds 26]2.4.68
PERS<2,1> holds 2.4.68
PERS<3,2,1> holds Married
File Handling
jBC is able to access data held in any file format with a file variable. A file variable is created when the OPEN
command is executed.
Once a file is OPENed, the file variable is used by input/output statements to access file records. File records
may be held in either of two formats - a dimensioned array or a dynamic array.
Record Access
DYNAMIC ARRAYS give a fast method of data access from disc as the system simply strips off the record key
and places the rest of the record into the file.variable space. By specifying a single variable, a full record can
quickly be read or written away.
Reading records into a DIMENSIONED ARRAY is less efficient as the system has to assign each field into a
separate element of the array. Writing records to file is also less efficient as the data needs to be reassembled
from the array.
Guidelines
Use dynamic arrays to read or write data to or from a file. If a dynamic array record field or value is to be used
several times, or needs to be string searched or manipulated, then assigning it to a variable first can improve
performance. However, the optimisation within the jBC compiler may actually do this for you.
Use dimensioned arrays where much work needs to be done on multiple record fields - e.g. to construct new
records or to continually update many fields within large records.
Locking Mechanisms
The jBC data record locking mechanism is available to application programmers for maintaining data integrity.
Any file record accessed by the application can have an update lock set, which will not allow other system users
to concurrently update the same record.
Two types of locks are available.
Execution Locks
An execution lock is used to prevent several different jBC programs from simultaneously executing a defined
process.
For example, a jBC archive application can set an execution lock that prevents other jBC applications from
running a section of code until it is finished or the lock released.
An execution lock may be set by use of the LOCK statement, and are cleared with the UNLOCK statement or
termination of the program.
@(Col, Row)
The @ function is used to position the cursor to a specific point on the terminal screen.
Command Syntax
@(col{, row})
Syntax Elements
col and row can be any expression that evaluates to a numeric value. Col specifies which column on the screen
the cursor should be moved to. Row specifies which row (line) on the screen to position the cursor. Col may be
specified on its own, which will cause the cursor to the required column on whichever row it currently occupies.
Notes
When values are specified that exceed either of the physical limits of current terminal, then unpredictable results
will occur.
The terminal is always addressed starting from (0,0), being the top left hand corner of the screen.
Cursor addressing will not normally work when directed at a printer. If you wish to build printer independence
into your programs you may achieve this by accessing the terminfo database through the SYSTEM( ) function
(see later).
Examples
FOR I = 1 TO 5
CRT @(5, I):"*":
NEXT I
@(ScreenCode)
The @(ScreenCode) function is also used to output control sequences according to the capabilities of the
terminal.
Command Syntax
@(ScreenCode)
Syntax Elements
Control sequences for special capabilities of the terminal are achieved by passing a negative number as its
argument. ScreenCode is therefore any expression that evaluates to a negative argument.
Notes
jBASE has been designed to import code from many older systems. As these systems have traditionally not co-
ordinated the development of this function they expect different functionality in many instances. In the following
table you should note that different settings of the JBCEMULATE environment variable (see earlier) will elicit
different functionality from this function. Where the emulate code is printed with strikethrough it indicates that
the functionality is denied to this emulation.
Emulate Code Function
All -1 Clear the screen and home the cursor
All -2 Home the cursor
Examples
CRT @(-1):@(30):@(-132):"jBASE Heading":@(-128):
CRT @(5,5):@(-4):"Prompt: ": ; INPUT Answer
ABORT
The ABORT statement terminates the program running as well as the program that called it.
Command Syntax
ABORT {message.number{, expression ...}}
Syntax Elements
The optional message.number provided with the statement must be a numeric value, which corresponds to a
record key in the jBASE error message file
Notes
This statement is used to terminate the execution of a jBC program together with any calling program. It will
then optionally display a message, and return to the shell prompt.
The optional message displayed on terminating the program is held in the error file. For successful printing of
the message, parameters such as linefeeds, clearscreen, date and literal strings may also be required.
Operation of this command can be altered by setting the Command Level Restart option - see the Systems
Housekeeping chapter of the System Administrators Reference Manual for more details.
Example
CRT "CONTINUE (Y/N) ?":; INPUT ANS
IF ANS NE "Y" THEN ABORT 66, "Aborted"
This will terminate the program and print error message 66 passing to it the string "Aborted", which will be
printed as part of error message 66.
ABS( )
The ABS function will return the mathematical absolute of the ()expression.
Command Syntax
ABS(expression)
Syntax Elements
expression can be an expression of any form that should evaluate to a numeric. The ABS function will then
return the mathematical absolute of the expression. This will convert any negative number into a positive result.
Notes
This can be expressed as:
value < 0 ? 0-value : value;
Examples
CRT ABS(10-15)
ALPHA( )
The ALPHA function will check that the expression consists entirely of alphabetic characters.
Command Syntax
ALPHA(expression)
Notes
Alphabetic characters are in the set a-z and A-Z
Example
Abc = "ABC"
IF ALPHA(Abc) THEN CRT "alphabetic"
Abc = "123"
IF NOT(ALPHA(Abc)) THEN CRT "non alphabetic"
Displays:
alphabetic
non alphabetic
ASCII( )
The ASCII function converts all the characters in the expression from the EBCDIC character set to the ASCII
character set.
Command Syntax
ASCII(expression)
Syntax Elements
The expression may return a data string of any form. The function will then assume that the characters are all
members of the EBCDIC character set and translate them using a character map. The original expression is
unchanged while the returned result of the function is now the ASCII equivalent.
Notes
Examples
READT EbcdicBlock ELSE CRT "Tape failed!"; STOP
AsciiBlock = ASCII(EbcdicBlock) ;* Convert to ASCII
ASSIGNED( )
The ASSIGNED function returns a Boolean TRUE or FALSE result depending on whether or not a variable has
been assigned a value.
Command Syntax
ASSIGNED(variable)
Syntax Elements
ASSIGNED returns TRUE if the variable named has been assigned a value before the execution of this
statement. If the variable has never been assigned a value then the function returns FALSE.
Notes
This function has been provided as it has been implemented in older implementations of the language. It is far
better to program in such a way as this statement will not be needed.
BITCHANGE
BITCHANGE toggles the state of a specified bit in the local bit table, and return the original value of the bit.
Command Syntax
BITCHANGE(table_no)
Syntax Elements
table_no specifies the position in the table of the bit to be changed.
Notes
A unique table of 128 bits (numbered 1 to 128) is maintained for each process. Each bit in the table is treated as
a two-state flag - the value returned will always be 0 (zero) or 1.
BITCHANGE returns the value of the bit before it was changed. You can therefore check and set (or reset) a
flag in one step.
BITCHANGE also provides some special functions if you use one of the following table_no values:
-1 toggles (enables/disables) the BREAK key Inhibit bit.
-2 toggles (enables/disables) the Command Level Restart feature.
-3 toggles (enables/disables) the Break/End Restart feature.
Example
OLD.VAL = BITCHANGE(100)
CRT OLD.VAL
If bit 100 in the table is 0 (zero), it will be set to 1 and 0 will be displayed. If bit 100 is set to 1 (one), the reverse
will apply.
BITCHECK
BITCHECK returns the current value of a specified bit from the local bit table.
Command Syntax
BITCHECK(table_no)
Syntax Elements
table_no specifies the position in the table of the bit to be checked.
Notes
A unique table of 128 bits (numbered 1 to 128) is maintained for each process. Each bit in the table is treated as
a two-state flag - the value returned will always be 0 (zero) or 1.
BITCHECK also provides some special functions if you use one of the following table_no values:
-1 returns the setting of the BREAK key Inhibit bit.
-2 returns the setting of the Command Level Restart feature.
-3 returns the setting of the Break/End Restart feature.
Examples
BIT.VAL = BITCHANGE(100)
CRT BIT.VAL
BITLOAD
BITLOAD assigns all values in the local bit table, or retrieves all the values.
Command Syntax
BITLOAD({bit-string})
Syntax Elements
bit-string is an ASCII string of characters which represent a hexadecimal value. It is interpreted as a bit pattern
and used to assign values to the table from left to right. Assignment stops at the end of the string or when a non-
hexadecimal character is found.
If the string represents less than 128 bits, the remaining bits in the table are reset to 0 (zero).
If bit-string is omitted or evaluates to null, an ASCII hex character string is returned, which defines the value of
the table. Trailing zeroes in the string are truncated.
Notes
A unique table of 128 bits (numbered 1 to 128) is maintained for each process. Each bit in the table is treated as
a two-state flag - the value will always be 0 (zero) or 1.
Example 1
NEW.VALUE = 0123456789ABCDEF
OLD.VALUE = BITLOAD(X)
Loads the bit table with the value of ASCII hex string NEW.VALUE. After assignment, the contents of the bit
table are:
0000 0001 0010 0011 0100 0101 0110 0111
1000 1001 1010 1011 1100 1101 1110 1111
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
Note that all values beyond the 64th bit have been reset to 0 (zero).
Example 2
TABLE.VALUE = BITLOAD()
Loads variable TABLE.VALUE with the hexadecimal values of the bit table.
BITRESET
BITRESET resets the value of a specified bit in the local bit table to 0 and returns the value of the bit before it
was changed.
Command Syntax
BITRESET(table_no)
Syntax Elements
table_no specifies the position in the table of the bit to be reset. If table_no evaluates to zero, all elements in the
table are reset to 0 (zero) and the returned value is zero.
Notes
A unique table of 128 bits (numbered 1 to 128) is maintained for each process. Each bit in the table is treated as
a two-state flag - the value returned will always be 0 (zero) or 1.
Example
OLD.VALUE = BITRESET(112)
PRINT OLD.VALUE
If table entry 112 is 1, returns a value of 1, resets bit 112 to 0, and prints 1. If table entry 112 is 0, returns a value
of 0, and prints 0.
BITSET
BITSET sets the value of a specified bit in the bit table to 1 and returns the value of the bit before it was
changed.
Command Syntax
BITSET(table_no)
Syntax Elements
table_no specifies the bit to be SET. If table_no evaluates to zero, all elements in the table are set to 1 (one) and
the returned value is one.
Notes
A unique table of 128 bits (numbered 1 to 128) is maintained for each process. Each bit in the table is treated as
a two-state flag - the value returned will always be 0 (zero) or 1.
BITSET returns the value of the bit before it was changed - checking and setting a flag can be accomplished in
one step.
BITSET also provides some special functions if you use one of the following table_no values:
-1 sets the BREAK key Inhibit bit.
-2 sets the Command Level Restart feature.
-3 sets the Break/End Restart feature.
Example 1
OLD.VALUE = BITSET(112)
PRINT OLD.VALUE
If table entry 112 is 0, returns a value of 0, sets bit 112 to 1, and prints 0. If table entry 112 is 1, returns a value
of 1, and prints 1.
BREAK
The BREAK statement allows the break key to be configured.
Command Syntax
BREAK
BREAK ON
BREAK OFF
BREAK expression
Notes
As BREAK is used to terminate the innermost loop, it is ignored if used outside a loop construct. The compiler
will issue warning message 44, and ignore the statement.
Examples
LOOP
READNEXT KEY FROM LIST1 ELSE BREAK
......
REPEAT
* Program resumes here after BREAK
CALL
The CALL statement transfers program execution to an external subroutine.
Command Syntax
CALL {@}subroutine.name {(argument {, argument ... })}
Syntax Elements
The CALL statement transfers program execution to the subroutine called subroutine.name, which can be any
valid string either quoted or unquoted. The CALL @ variant of this statement assumes that subroutine.name is a
variable that contains the name of the subroutine to call.
The CALL statement may optionally pass a number of parameters to the target subroutine. These parameters can
consist of any valid expression or variable name. If a variable name is used then the called program may return a
value to the variable by changing the value of the equivalent variable in its own parameter list.
Notes
When using an expression to pass a parameter to the subroutine, you may not use any of the built-in functions
(such as COUNT), of jBC within the expression.
There is no limit to the number of parameters that may be passed to an external subroutine.
The number of parameters in the CALL statement must match exactly the number expected in the
SUBROUTINE statement declaring the external subroutine.
The calling program and the external subroutine must be compiled with the same PRECISION.
Variables passed as parameters to the subroutine may not reside in any COMMON areas declared in the
program. Here are some examples of the CALL statement:
Examples
CALL MySub
SUBROUTINE MySub
CALL Hello("World")
SUBROUTINE Hello (Message)
CALL Complex(i, j, k)
SUBROUTINE Complex(ComplexA, ComplexB, ComplexC)
Command Syntax
BEGIN CASE
CASE expression
statement(s)
CASE expression
statement(s)
.....
END CASE
Syntax Elements
The CASE structure is bounded by the BEGIN CASE and END CASE statements. Within this block, an
arbitrary number of CASE expression statements may exist followed by any number of jBC statements. The
expression should evaluate to a TRUE or FALSE result. At execution time, each expression is evaluated in
order. If the expression returns a TRUE result, then the statements beneath it are executed. On completion of the
associated statements, execution will resume at the first statement following the END CASE.
Notes
A default action (to trap error conditions for instance) may be introduced by using an expression that is always
TRUE, such as CASE 1. This should always be the last expression in the CASE block.
Example
BEGIN CASE
CASE A = 1
CRT "You won!"
CASE 1
CRT "You came nowhere"
END CASE
A single comment is printed depending on the value of A. Note that if A is not 1 then the default CASE 1 rule
will be executed as a "catch all".
CHAIN
The CHAIN statement exits the current program and transfers process control to the program defined by the
expression. Process control will never return to the originating program.
Command Syntax
CHAIN expression
Syntax Elements
The expression should evaluate to a valid UNIX command (this may be another jBC program). The command
string may be suffixed with the (I option, which will cause any COMMON variables in the current program to be
inherited by the new program (providing it is a jBC program).
Notes
There are no restrictions to the CHAIN statement and you may CHAIN from anywhere to anywhere. However,
you should try and make your programs follow a logical path that may be easily seen by another programmer.
If the program which contains the CHAIN command (the current program) was called from a jCL program, and
the program to be executed (the target program) is another jBC program, control will return to the original jCL
program when the target program terminates. If the target program is a jCL program, control will return to the
command shell when the jCL program terminates.
CHANGE
The CHANGE statement operates on a variable and replaces all occurrences of one string with another.
Command Syntax
CHANGE expression1 TO expression2 IN variable
Syntax Elements
Expression1 may evaluate to any result and is the string of characters that will be replaced. Expression2 may
also evaluate to any result and is the string of characters that will replace expression1. The variable may be any
previously assigned variable in the program.
Notes
Either string can be of any length and is not required to be the same length. The jBC language also supports the
CHANGE function for compatibility with older systems.
Examples
String1 = "Jim"
String2 = "James"
Variable = "Pick up the tab Jim"
CHANGE String1 TO String2 IN Variable
CHANGE "tab" TO "cheque" IN Variable
CHAR( )
The CHAR function returns the ASCII character specified by the expression.
Command Syntax
CHAR(expression)
Syntax Elements
The expression must evaluate to a numeric argument in the range 0-255. This is the entire range of the ASCII
character set.
Notes
jBC variables can contain any of the ASCII characters 0-255, thus there are no restrictions on this function.
This function is often used to insert field delimiters within a variable or string. These are commonly equated to
AM, VM, SV in a program.
Examples
EQUATE AM TO CHAR(254) ;* Field Mark
EQUATE VM TO CHAR(253) ;* Value Mark
EQUATE SV TO CHAR(252) ;* Sub Value mark
CHDIR( )
The CHDIR function allows the UNIX current working directory, as seen by the process environment, to be
changed.
Command Syntax
CHDIR(expression)
Syntax Elements
The expression should evaluate to a valid path name within the UNIX system. The function returns a Boolean
TRUE result if the CHDIR succeeded and a Boolean FALSE result if it failed.
Examples
IF CHDIR("/usr/jbc/src") THEN
CRT "jBASE development system INSTALLED"
END
CHECKSUM ( )
The CHECKSUM function returns a simple numeric checksum of a character string.
Command Syntax
CHECKSUM(expression)
Syntax Elements
The expression may evaluate to any result but will usually be a string. The function then scans every character in
the string and returns a numeric addition of the characters within the string.
Notes
The function calculates the checksum by summing the product of the ASCII value of each character and its
position within the string.
Examples
INPUT DataBlock,128:
IF CHECKSUM(DataBlock) = ExpectedChk THEN
CRT AckChar:
END ELSE
......
CLEAR
The CLEAR statement will initialise all the variables to numeric 0.
Command Syntax
CLEAR
Notes
CLEAR can be used at any time during the execution of the program.
Examples
Var1 = 99
Var2 = 50
.
.
CLEARFILE
The CLEARFILE statement is used to clear all the data from a file previously opened with the OPEN
statement.
Command Syntax
CLEARFILE {variable} {SETTING setvar} {ON ERROR statements}
Syntax Elements
The variable must have been the subject of an OPEN statement before the execution of CLEARFILE upon it.
If the variable is omitted from the CLEARFILE statement, then the default file variable is assumed as per the
OPEN statement.
Notes
The CLEARFILE statement will remove every database record on the file it is executed against. It should
therefore be used with great care.
If the variable argument does not describe a previously opened file, the program will enter the debugger with an
appropriate message.
If the SETTING clause is specified and the CLEARFILE fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Examples
OPEN "DATAFILE" ELSE ABORT 201, "DATAFILE"
OPEN "PROGFILE" TO FILEVAR ELSE ABORT 201, "PROGFILE"
CLEARFILE
CLEARFILE FILEVAR
CLOSE
The CLOSE statement is used to CLOSE a previously opened file when it is no longer needed.
Command Syntax
CLOSE variable{, variable ...}
Syntax Elements
The variable list is should contain a list of previously opened file variables that are no longer needed. The
variables will be cleared and may be reused as ordinary variables.
Notes
It is good practice to hold open only those file descriptors that you wish to have constant access to. Although
there is no limit to the number of files that may be opened within jBC, opening large numbers of files and
leaving them open can consume resource that can be better used.
Examples
OPEN "DATAFILE" TO FILEVAR ELSE ABORT 201, "DATAFILE"
.....
CLOSE FILEVAR
Command Syntax
COMMON {/CommonName/} variable{, variable ... }
Syntax Elements
The list of variables should not have been declared or referenced previously in the program file. The compiler
will detect any bad declarations and display suitable warning or error messages. If the common area declared
with the statement is to be named then the first entry in the list should be a string, delimited by the '/' character.
Notes
The compiler will not, by default, check that variables declared in COMMON statements are initialised before
they have been used as this may be beyond the scope of this single source code check. The -JCi option, when
specified to the jBC compiler, will force this check to be applied to common variables as well.
Variables declared without naming the common area may only be shared between the program and its
subroutines (unless CHAIN is used). Variables declared in a named common area may be shared across program
boundaries. When any common area is shared, all programs using it should have declared the same number of
variables within it.
Dimensioned arrays are declared and dimensioned within the COMMON statement.
Examples
COMMON A, B(2, 6, 10), c
COMMON /Common1/ A, D, Array(10, 10)
Command Syntax
COL1()
COL2()
Notes
When a field has been located in a string, it is sometimes useful to know its exact position within the string to
manipulate either it, or the rest of the string. COL1() will return the position of the character immediately before
the last field located. COL2() will return the position of the character immediately after the end of the last field
located. They can then be used to manipulate the string.
Examples
A = "A,B,C,D,E"
Fld = FIELD(A, ",", 2)
CRT COL1()
CRT COL2()
COLLECTDATA
The COLLECTDATA statement is used to retrieve data passed from the PASSDATA clause of an EXECUTE
statement.
Syntax Elements
variable is the name of the variable which is to store the retrieved data.
Notes
The COLLECTDATA statement can be used in any program which is EXECUTEd (or PERFORMed) by
another program where the calling program uses a PASSDATA clause. The EXECUTEd program uses a
COLLECTDATA statement to retrieve the passed data.
If a PASSDATA clause is not in effect, variable will be assigned a value of null.
Example
FIRST
001 EXECUTE RUN JBC_PROGS SECOND PASSDATA Handover
SECOND
001 COLLECTDATA PassedMessage
002 CRT PassedMessage
In the above example, program FIRST will EXECUTE program SECOND and will pass the string Handover in
the PASSDATA clause. Program SECOND retrieves the string to a variable PassedMessage and prints the string
on the Terminal screen.
CONTINUE
The CONTINUE statement is the complimentary statement to the BREAK statement without arguments.
Command Syntax
CONTINUE
The statement is used within a loop to skip the remaining code in the current iteration and proceed directly on to
the next iteration.
Notes
See also: BREAK EXIT
The compiler will issue a warning message and ignore the statement if it is found outside an iterative loop such
as FOR...NEXT, LOOP...REPEAT.
Examples
FOR I = 1 TO 30
IF Pattern(I) MATCHES "0N" THEN CONTINUE
GOSUB ProcessText
NEXT I
The above example will execute the loop 30 times but will only call the subroutine ProcessText when the
current array element of Pattern is not a numeric value or null.
CONVERT
The CONVERT statement will search a variable looking for every occurrence of every character in expression1.
When it finds such an occurrence it replaces it with the equivalent character in expression2.
Command Syntax
CONVERT expression1 TO expression2 IN variable
Notes
The CONVERT statement does a one for one character conversion (as opposed to the CHANGE statement).
This means that every occurrence of a character in expression1 is converted to the corresponding character in
expression2. If there is no corresponding character in expression2 (i.e. expression2 is shorter than expression1)
then the character is removed.
Examples
CONVERT ".," TO "$,." IN Value
CONVERT "abc" TO "ABC" IN PartCode
CONVERT "1234567890" TO "0987654321" IN Code
Selecting from the examples above, the '' is converted to '$', the 'b' to 'B' and the '4' to '7'.
CONVERT( )
The CONVERT function is the function form of the CONVERT statement described earlier. It performs
exactly the same function but may also operate on an expression rather than being restricted to variables.
Command Syntax
CONVERT(expression1, expression2, expression3)
Syntax Elements
Expression1 is the string to which the conversion will apply. Expression2 is the list of all characters to translate
in expression1. Expression3 is the list of characters that will be converted to.
Notes
See Also: CONVERT statement.
Examples
Value = CONVERT(Value, ".,", "$,.")
Value = CONVERT(PartCode, "abc", "ABC")
Value = CONVERT(Code, "1234567890", "0987654321")
COS( )
The COS function calculates the cosine of any angle using floating point arithmetic, then rounds to the precision
implied by the jBC program. This makes it very accurate.
Command Syntax
COS(expression)
This function calculates the cosine of an expression.
Syntax Elements
The expression must evaluate to a numeric result or a runtime error will occur.
Notes
The value returned by expression is assumed to be in degrees.
Examples
FOR I = 1 TO 360
COUNT( )
The COUNT function returns the number of times that expression2 occurs in expression1.
Command Syntax
COUNT(expression1, expression2)
Syntax Elements
Both expression1 and expression2 may evaluate to any data type but logically they will evaluate to character
strings.
Notes
The count is made on overlapping occurrences as a pattern match from each character in expression1. This
means that the string jjj occurs 3 times in the string jjjjj.
Examples
Calc = "56 * 23 / 45 * 12"
CRT "There are ":COUNT(Calc, "*"):" multiplications"
CRT
The CRT statement sends data directly to the terminal, even if a PRINTER ON statement is currently active.
Command Syntax
CRT expression {, expression..} {:}
Syntax Elements
An expression can evaluate to any data type. The CRT statement will convert the result to a string type for
printing. Expressions separated by commas will be sent to the screen separated by a tab character.
The CRT statement will append a newline sequence to the final expression unless it is terminated with a colon ':'
character.
Notes
As the expression can be any valid expression, it may have output formatting applied to it.
A jBC program is normally executed using buffered output mode. This means that data is not flushed to the
terminal screen unless a newline sequence is printed or terminal input is requested. This makes it very efficient.
However you can force output to be flushed to the terminal by printing a null character CHAR(0). This has the
same effect as a newline sequence but without affecting screen output.
Examples
CRT A "L#5"
CRT @(8,20):"Jim":
FOR I = 1 TO 200
CRT @(10,10):I:CHAR(0):
...
NEXT I
DATA
The DATA statement stacks the series of expressions on a terminal input FIFO stack. Terminal input statements
will then treat this data as if it was typed in at the keyboard.
Syntax Elements
The expression may evaluate to any data type. Each comma separated expression will be viewed as one line of
terminal input.
Notes
The data stacked for input will subsequently be treated as input by any jBC program. Therefore it may be used
before PERFORM/EXECUTE, CHAIN or any other method of transferring program execution. It may also be
used to stack input for the currently executing program.
When stacked data is detected by a jBC program, it is taken as keyboard input until the stack is exhausted. The
program will then revert to the terminal device for subsequent terminal input.
Stacked data delimited by field marks (xFE) will be treated as a series of separate terminal inputs.
Examples
DATA "Y", "N", "CONTINUE" ;* Stack input for prog
EXECUTE "PROGRAM1" ;* Execute the program
DATE( )
The DATE( ) function returns the date in internal system form. This date is expressed as the number of days
since December 31, 1967.
Command Syntax
DATE( )
Notes
The system and your own programs should manipulate date fields in internal form. They can then be converted
to a readable format of your choice using the OCONV( ) function and the date conversion codes.
See also: TIMEDATE( )
Examples
CRT OCONV(DATE(), "D2")
DCOUNT( )
The DCOUNT( ) function counts the number of field elements in a string that are separated by a specified
delimiter.
Command Syntax
DCOUNT(expression1, expression2)
Syntax Elements
Expression1 evaluates to a string in which fields are to be counted. Expression2 evaluates to the delimiter string
that will be used to count the fields.
Notes
The delimiter string may consist of more than 1 character.
If expression1 is a NULL string, then the function will return a value of 0.
Examples
A = "A:B:C:D"
CRT DCOUNT(A, ":")
will display the value 4.
DEBUG
The DEBUG statement causes the executing program to enter the jBC debugger.
Command Syntax
DEBUG
Notes
The debugger is described in a separate chapter of this manual.
Examples
IF FatalError = TRUE THEN
DEBUG ;* Enter the debugger
END
DEFC
The DEFC statement is used to declare an external C function to the jBC compiler and define its arguments and
return types.
Command Syntax
DEFC {FuncType} FuncName ({ArgType {, ArgType ...}})
Syntax Elements
FuncType and ArgType are selected from one of INT, FLOAT or VAR. FuncType specifies the type of result
that the function will return. If FuncType is omitted then INT will be assumed. The optional list of ArgTypes
specifies the argument types that the C function will expect. The compiler must know this in advance as it will
automatically perform type conversions on these arguments.
Notes
A DEFC must be compiled for each C function before any reference is made to it or the compiler will not
recognise the function name.
The function is called in the same manner as it would be in a C program. This means it can be used as if it was
an intrinsic function of the jBC language and therefore returns a value. However it can also be specified as a
standalone function call, which causes the compiler to generate code that ignores any returned values.
When jBC variables are passed to a C function you must utilise predefined macros to access the various data
types it contains. These macros are fully documented in the manual "jBASE External Interfaces". This manual
also gives examples of working C functions and documents other interfaces available to the jBC programmer.
C functions are particularly useful for increasing the performance of tight loops that perform specific functions.
The jBC compiler must cater for any eventuality within a loop (such as the controlling variable changing from
integer to floating point). A dedicated C function can ignore such events, if they are guaranteed not to happen.
The jBC programmer may freely ignore the type of argument used when the C function is invoked as the jBC
compiler will automatically perform type conversion.
Example 2
DEFC INT getpid()
CRT Process id =:getpid()
DEL
The DEL statement is used to remove a specified element of a dynamic array.
Command Syntax
DEL variable<expression1{, expression2{, expression3}}>
Syntax Elements
The variable can be any previously assigned variable or matrix element. The expressions must evaluate to a
numeric value or a runtime error will occur. Expression1 specifies the field in the array to operate upon and must
be present. Expression2 specifies the multivalue within the field to operate upon and is an optional parameter.
Expression3 is optionally present when expression2 has been included. It specifies which subvalue to delete
within the specified multivalue.
Notes
Non integer values for any of the expressions are truncated to integers.
Invalid numeric values for the expressions are ignored without warning.
The command operates within the scope specified. I.E. if only a field is specified then the entire field (including
its multivalues and subvalues) is deleted. If a subvalue is specified, then only the subvalue is deleted leaving its
parent multivalue and field intact.
Examples
FOR I = 1 TO 20
Numbers<I> = I ;* Generate numbers
NEXT I
FOR I = I9 TO 1 STEP -2
DEL Numbers<I> ;* Remove odd numbers
NEXT I
DELETE
The DELETE statement is used to delete a record from a jBASE file.
Command Syntax
DELETE {variable,} expression {SETTING setvar} {ON ERROR statements}
Syntax Elements
The variable (if specified), should have been the subject of a previous OPEN statement. If the variable is
omitted then the default file variable is assumed.
The expression should evaluate to the name of a record stored in the open file.
If the SETTING clause is specified and the delete fails, setvar will be set to one of the following values:
128 No such file or directory
Notes
The statement will have no effect if the record name does not exist within the file.
If a lock was being held by the program against the file record, then the lock will be released.
Examples
OPEN "DAT1" TO DatFile1 ELSE ABORT 201, "DAT1"
DELETE DatFile1, "record1"
will delete the record "record1" from the file DAT1.
DELETELIST
The DELETELIST statement will delete the previously stored list named by expression.
Command Syntax
DELETELIST expression
Syntax Elements
The expression should evaluate to the name of a list that has been stored either with the WRITELIST statement
or the SAVE-LIST command from the shell.
Notes
Lists are saved in the jBASE work file.
Examples
List = "JobList"
DELETELIST List
will delete the pre-saved list called JobList.
DIMENSION
The DIM statement is used to declare arrays to the compiler before they are referenced.
Command Syntax
DIM{ENSION} variable(number{, number...}){, variable(number {, number...}) ...}
Syntax Elements
The variable may be any valid variable name that has not already been used or declared. The numbers define the
size of each dimension and must be either constants or the subject of an EQUATE statement.
A number of arrays may be declared by a single DIM statement by separating their declarations with a comma.
Notes
The array must be declared before it is referenced in the program source (compilation as opposed to execution).
The compiler will display an error message if a variable is used as a dimensioned array before it has been
declared.
The array variable may not be used as a normal variable or dynamic array before being dimensioned and the
compiler will detect this as an error.
Examples
EQUATE DimSize1 TO 29
DIM Array1(10,10), Array2(5, 20, 5, 8)
DIM Age(DimSize1)
DTX( )
The DTX function will return the hexadecimal representation of a numeric expression.
Command Syntax
DTX( expression)
Syntax Elements
Expression must evaluate to a decimal numeric value or a runtime error will occur.
Examples
Decimal = 254
CRT DTX(Decimal)
displays FE.
EBCDIC( )
The EBCDIC function converts all the characters in an expression from the ASCII character set to the EBCDIC
character set.
Command Syntax
EBCDIC(expression)
Syntax Elements
expression may contain a data string of any form. The function will convert it to a character string, assume that
the characters are all members of the ASCII set and translate them using a character map. The original
expression is unchanged while the returned result of the function is now the EBCDIC equivalent.
Notes
Examples
READT AsciiBlock ELSE CRT "Tape failed!"; STOP
EbcdicBlock = EBCDIC(AsciiBlock) ;* Convert to
* EBCDIC
ECHO
The ECHO statement will turn on or off the echoing of characters typed at the keyboard.
Command Syntax
ECHO ON
ECHO OFF
ECHO expression
Notes
The SYSTEM function can be used to determine the current state of character echoing. If echoing is enabled
then SYSTEM(24) will return Boolean TRUE and if disabled it will return Boolean FALSE.
Examples
ECHO OFF
CRT "Enter your password ":
INPUT Password
ECHO ON
.....
This will disable character input echoing while a password is typed in.
ENTER
The ENTER statement unconditionally passes control to another executable program.
Command Syntax
ENTER program_name
ENTER @ variable_name
Syntax Elements
program_name is the name of the program to be executed. The use of single or double quotes to surround
program_name is optional.
@ specifies that the program name is contained in a named variable.
variable_name is the name of the variable which contains the program name.
Notes
The jBC COMMON data area can be passed to another jBC program by specifying the I option after the
program name - see the examples. The COMMON data area can only be passed to another jBC program.
ENTER can be used to execute any type of program.
If the program which contains the ENTER command (the current program) was called from a jCL program, and
the program to be executed (the target program) is another jBC program, control will return to the original jCL
program when the target program terminates. If the target program is a jCL program, control will return to the
command shell when the jCL program terminates.
Examples
ENTER menu.
ENTER menu (I.
ProgName = UPDATE (I
ENTER @ ProgName
EQUATE
EQUATE is used to declare a symbol equivalent to a literal, variable or simple expression.
Syntax Elements
symbol is the name of the symbol to use. Can be any name that would be valid for a variable.
expression can be a literal, a variable or a simple expression..
Notes
Sensible use of EQUATEd symbols can make your program easier to maintain, easier to read, and more
efficient.
Efficiency can be enhanced because the address of an EQUATEd value is computed during compilation and is
substituted for each occurrence of the symbol name. Unlike the address of a variable, which has to be computed
for each access during run time, the address of a symbol is always known. This means that the processing
overhead involved in accessing a particular value can be significantly reduced. See the example for a more
detailed explanation of the other benefits.
Readability can be enhanced by referring to say, QTY rather than INV_LINE(4). You would simply EQUATE
QTY TO INV_LINE(4) at an early stage in the program. This can also help with maintenance of the program,
particularly in situations where record layouts might change. For example, if the quantity field moves to
INV_LINE(6), you will only have to change one line in your program.
Example
COMMON FLAG
EQUATE NO_CHARGE TO FLAG
EQUATE CR TO CHAR(13), TRUE TO 1, FALSE TO 0
EQUATE PRICE TO INV_LINE(7), TAX TO 0.175
EQUATE DASHES TO -------
IF NO_CHARGE = TRUE THEN PRICE = 0
CRT Tax =:PRICE * TAX:CR:DASHES
EXECUTE
The EXECUTE or PERFORM statement allows the currently executing program to pause and execute any
other UNIX program, including another jBC program or a jBASE command.
Command Syntax
EXECUTE|PERFORM expression {CAPTURING variable} {RETURNING|SETTING variable}
{PASSLIST {expression}} {RTNLIST {variable}}
{PASSDATA variable} {RTNDATA variable}
Data, Dynamic Arrays and lists can be passed to programs written in jBC. Screen output and error messages can
be intercepted from any program.
Syntax Elements
The PERFORMed expression can be formed from any jBASE construct. The system will not verify that the
command exists before executing it. The command is executed by a new Bourne Shell (sh) by default. The shell
type can be changed by preceding the command with a CHAR(255) concatenated with either 'k', 'c', or 's' to
signify the Korn shell, C shell or Bourne Shell.
Variables used to pass data to the executed program should have been assigned to a value before they are used.
Any variable name may be used to receive data.
CAPTURING variable
The capturing clause will capture any output that the executing program would normally send to the terminal
screen and place it in the variable specified. Every newline normally sent to the terminal is replaced with a field
mark in the variable.
Notes
The clauses may be specified in any order within the statement but only one of each clause may exist.
Examples
OPEN "DataFile" ELSE ABORT 201, "DataFile"
SELECT
PERFORM "MyProg" SETTING ErrorList PASSLIST
EXIT( )
The EXIT statement is used to halt the execution of a program and return a numeric exit code to the parent
process. For compatibility with older versions of the language the EXIT statement may be used without an
expression. In this case it is synonymous with the BREAK statement (see earlier).
Command Syntax
EXIT (expression)
EXIT
Syntax Elements
Any expression provided must be parenthesised and must evaluate to a numeric result. The numeric result is
used as the UNIX exit code, which is returned to the parent process by the C function exit(). If the expression
does not evaluate to a numeric then the program will enter the debugger with a suitable error message.
Notes
The expression has been forced to be parenthesised to avoid confusion with the EXIT statement without an
expression as much as is possible. The authors apologise for having to provide two different meanings for the
same keyword.
Examples
READ Record FROM FileDesc, RecordKey ELSE
EXP( )
The EXP function returns the mathematical constant e to the specified power.
Command Syntax
EXP(expression)
Syntax Elements
The expression may consist of any form of jBC expression but should evaluate to a numeric argument or a
runtime error will occur and the program will enter the debugger.
Notes
The function will return a value that is accurate to as many decimal places as are specified by the PRECISION of
the program.
Examples
E10 = EXP(10) ;* Get e^10
EXTRACT
The EXTRACT function is an alternative method of accessing values in a dynamic array other than using the
<n,n,n> syntax described earlier.
Command Syntax
EXTRACT(expression1, expression2 {, expression3 {, expression4}})
Syntax Elements
Expression1 specifies the dynamic array to work with and will normally be a previously assigned variable. The
expressions 2 through 4 should all return a numeric value or a runtime error will occur and the program will
enter the debugger. Expression2 specifies the field to extract, expression3 the value to extract and expression4
the sub-value to extract.
Notes
Dynamic arrays are described in detail earlier in this chapter.
Examples
A = "0"; A<2> = "1"; A<3> = "2"
CRT EXTRACT(A, 2)
Will print the value '1' to the terminal display.
FIELD( )
The FIELD function will return a multi-character delimited field from within a string.
Command Syntax
FIELD(expression1, expression2, expression3)
Notes
The field delimiter may consist of more than a single character, allowing fields to be delimited by complex
codes.
Examples
Fields = "AAAA:BBJIMBB:CCCCC"
CRT FIELD(Fields, ":", 3)
CRT FIELD(Fields, "JIM", 1)
will display:
CCCCC
AAAA:BB
on the terminal
FIND
The FIND statement allows the location of a specified string within a dynamic array.
Command Syntax
FIND expression1 IN Var1 {, expression2}
SETTING Var2 {, Var3 {, Var4}} THEN | ELSE statement(s)
Syntax Elements
Expression1 evaluates to the string to compare every element of the dynamic array with. Var1 is the actual
dynamic array that will be searched. The FIND command will normally find the first occurrence of expression1
unless expression2 is specified. If specified then expression2 will cause a specific occurrence of expression1 to
located. The three variables Var2 through Var4 are used to record the Field, Value and Sub-Value positions in
which expression1 was found.
If expression1 is found in any element of Var1 then Vars 2, 3 and 4 are set to the position in which it was found
and any THEN clause of the statement is executed. If expression1 is not found within any element of the
dynamic array then Vars 2, 3 and 4 are undefined and the ELSE clause of the statement is executed.
Notes
The statement may omit either the THEN clause or the ELSE clause but may not omit both. It is valid for the
statement to contain both clauses if required.
Examples
Var = "ABC":VM:"JAC":AM:"CDE":VM:"WHO"
FIND "JAC" IN Var SETTING Ap, Vp THEN
CRT "JAC is in Field ":Ap:", value ":Vp
END ELSE
CRT "JAC could not be found"
END
Will display:
JAC is in Field 1, value 2
to the terminal.
Command Syntax
FINDSTR expression1 IN Var1 {, expression2}
SETTING Var2 {,Var3 {, Var4}} THEN | ELSE statement(s)
Syntax Elements
Expression1 evaluates to the string to search every element of the dynamic array with. Var1 is the actual
dynamic array that will be searched. FINDSTR will normally locate the first occurrence of expression1 unless
expression2 is specified. If specified then expression2 will cause a specific occurrence of expression1 to be
located. The three variables Var2 through Var4 are used to record the Field, Value and Sub-Value positions in
which expression1 was found.
If expression1 is found as a substring of any element of Var1 then Vars 2, 3 and 4 are set to the position in which
it was found and the THEN clause of the statement is executed if it is present. If expression1 is not found within
any element of the dynamic array then Vars 2,3 and 4 are undefined and the ELSE clause of the statement is
executed.
Notes
The statement may omit either the THEN clause or the ELSE clause but may not omit both. It is valid for the
statement to contain both clauses if required.
Examples
Var = "ABC":VM:"OJACKO":AM:"CDE":VM:"WHO"
FINDSTR "JAC" IN Var SETTING Ap, Vp THEN
CRT "JAC is within Field ":Ap:", value ":Vp
END ELSE
CRT "JAC could not be found"
END
Would display
JAC is within Field 1, value 2
to the terminal.
FOOTING
The FOOTING statement causes all subsequent output to the terminal to be halted at the end of each output
page. The statement allows an expression to be evaluated and displayed at the foot of each page. If output is
currently being sent to the terminal, the output will be paused until a carriage return is entered at the terminal
(unless the N option is specified either in the current HEADING or in this FOOTING).
Command Syntax
FOOTING expression
Syntax Elements
The expression should evaluate to a string that will be printed at the bottom of every page of output. The string
may contain a number of special characters that are interpreted and replaced in the string before it is printed. The
following characters have special meaning within the string:
'C{n}' Centre the line. If n is specified the output line is assumed to be n characters long.
'D' or \\ Replace with the current date.
'L' or ] Replace with the newline sequence.
Notes
If output is being directed to the printer (a PRINTER ON) statement is in force then output sent to the terminal
with the CRT statement is not paged. If output is being sent to the terminal then all output is paged.
Example
FOOTING "Programming staff by weight Page 'P'"
FOR
The FOR statement allows the programming of looping constructs within the program. The loop is controlled by
a counting variable and may be terminated early by expressions tested after every iteration.
Command Syntax
FOR Var=expression1 TO expression2 {STEP expression3}
{WHILE | UNTIL expression4}...NEXT {Var}
Syntax Elements
Var is the counting variable used to control the loop. The first time the loop is entered Var is assigned the value
of expression1, which must evaluate to a numeric value. After every iteration of the loop Var is automatically
incremented by 1. Expression2 must also evaluate to a numeric value as it causes the loop to terminate when the
value of Var is greater than the value of this expression. Expression2 is evaluated at the start of every iteration of
the loop and compared with the value of expression1.
If the STEP expression3 clause is included within the statement, Var will automatically be incremented by the
value of expression3 after each iteration of the loop. Expression3 is evaluated at the start of each iteration.
Expression3 may be negative, in which case the loop will terminate when Var is less than expression2.
The statement may optionally include either a WHILE or UNTIL clause (not both), which will be evaluated
before each iteration of the loop. When the WHILE clause is specified the loop will only continue with the next
iteration if Expression4 evaluates to Boolean TRUE. When the UNTIL clause is specified the loop will only
continue with the next iteration if Expression4 evaluates to Boolean FALSE.
Notes
Because expression2 and expression3 must be evaluated upon each iteration of the loop you should only code
complex expressions here if they may change within each iteration. If the values they yield will not change then
you should assign the value of these expressions to a variable before coding the loop statement. Expressions 3
and 4 should then be replaced with these variables. This can offer large performance increases where complex
expressions are being used.
See also: BREAK, CONTINUE.
Examples
Max =DCOUNT(BigVar, CHAR(254))
FOR I = 1 TO Max STEP 2 WHILE BigVar<I> LT 25
BigVar<I> += 1
NEXT I
This example will increment every second field of the variable BigVar but the loop will terminate early if the
current field to be incremented is not numerically less than 25.
Command Syntax
GETCWD(Var)
Syntax Elements
When executed the Var will be set to the name of the current working directory. The function itself returns a
Boolean TRUE or FALSE value indicating whether the command was successful or not.
Notes
Refer to your UNIX documentation (sh is a good place to start), for more information on the concept of the
current working directory.
Examples
IF GETCWD(Cwd) THEN
CRT "Current Working Directory = ":Cwd
END ELSE
CRT "Could not determine CWD!"
END
GETENV( )
All UNIX processes have an environment associated with them that contains a number of variables indicating the
state of various UNIX parameters. The GETENV function allows a jBC program to determine the value of any
of the environment variables associated with it.
Command Syntax
GETENV( expression, Variable)
Syntax Elements
The expression should evaluate to the name of the environment variable whose value is to be returned. The
function will then assign the value of the environment variable to Variable. The function itself returns a Boolean
TRUE or FALSE value indicating the success or failure of the function.
Notes
See the UNIX documentation for the Bourne shell (sh) for information on environment variables. See earlier in
this manual for information regarding environment variables unique to the jBASE system.
See also PUTENV
Examples
IF GETENV("PATH", ExecPath) THEN
CRT "Execution path is ":ExecPath
END ELSE
CRT "Execution path is not set up"
END
GETLIST
GETLIST allows the program to retrieve a previously stored list (perhaps created with the SAVE-LIST
command), into a jBCvariable.
Syntax Elements
Variable1 is the variable into which the list will be read.
Expression should evaluate to the name of a previously stored list to retrieve, or null. If expression evaluates to
null, the current default external select list (generated by a previous SELECT command for example) will be
retrieved.
Variable2 (if specified) will be set to the number of elements in the list.
If the statement succeeds in retrieving the list, then the statements associated with any THEN clause will be
executed. If the statement fails to find the list, then the statements associated with any ELSE clause will be
executed.
Notes
The GETLIST statement is identical in function to the READLIST statement.
See also: WRITELIST
Examples
* Find the list first
GETLIST "MyList" TO MyList ELSE STOP
LOOP
* Loop until there are no more elements
WHILE READNEXT Key FROM MyList DO
......
REPEAT
GOSUB
The GOSUB statement causes execution of a local subroutine, after which execution will continue with the next
line of code.
Command Syntax
GOSUB label
Syntax Elements
The label should refer to an existent label within the current source code. This label identifies the start of a local
subroutine. Label formats are defined earlier in this chapter.
Examples
GOSUB Initialise ;* Open files etc..
GOSUB Main ;* Perform main program
GOSUB Finish ;* Close files etc..
STOP
....
Initialise: * Open files
OPEN.......
RETURN
....
Main: * Main execution loop
.......RETURN
Command Syntax
GO{TO} Label
Syntax Elements
The label should refer to an existing label within the current source code.
Notes
The use of the GOTO command is not recommended as it obscures the readability of code and therefore is a
hindrance to maintainability. All programs written using the GOTO construct can be written using structured
statements such as LOOP and FOR. Opinions on this are divided but the consensus is that GOTO should be
avoided.
One possibly acceptable use of the GOTO statement is to transfer execution to an error handler upon detection
of a fatal error that will cause the program to terminate.
Examples
GOTO Exception ;* Jump to the exception handler
.....
Exception: * Exception handler
....STOP
GROUP( )
The GROUP function is an extension of the FIELD function allowing the return of a group of fields rather than
just a single one.
Command Syntax
GROUP(Expression1, Expression2, Expression3, Expression4)
Syntax Elements
Expression1 evaluates to the string containing fields to be extracted. Expression2 evaluates to the character(s)
delimiting each field within Expression1. Expression3 should evaluate to a numeric value specifying the number
of the first field to extract from Expression1. Expression4 evaluates to a numeric value specifying the number of
fields to extract as a group.
Notes
Expression2 may evaluate to more than a single character allowing fields to be delimited with complex
expressions.
Examples
A = "123:-456:-789:-987:-"
CRT GROUP(A, ":-", 2, 2)
This example will display
456:-789
on the terminal being the second and third fields and their delimiter within variable A.
Command Syntax
HEADING expression
Syntax Elements
The expression should evaluate to a string that will be printed at the top of every page of output. The string may
contain a number of special characters that are interpreted and replaced in the string before it is printed. The
following characters have special meaning within the string:
'C{n}' Centre the line. If n is specified the output line is assumed to be n characters long.
'D' or \\ Replace with the current date.
'L' or ] Replace with the newline sequence.
'N' Terminal output does not pause at the end of each page.
'P' or ^ Replace with the current page number.
'PP' or ^^ Replace with the current page number in a field of 4 characters. The field is right justified.
'T' or \ Replace with the current time and date.
'' Replace with a single ' character.
Notes
If output is being directed to the printer (a PRINTER ON statement is in force), output sent to the terminal with
the CRT statement will not be paged. If output is being sent to the terminal, all output will be paged unless you
specify the N option.
Examples
HEADING "Programming staff by size of waist Page 'P'"
ICONV( )
The ICONV function converts data in external form such as dates to their internal form.
Command Syntax
ICONV(expression1, expression2)
Syntax Elements
Expression1 evaluates to the data that the conversion is to be performed upon. Expression2 should evaluate to
the conversion code that is to be performed against the data.
Notes
The range of conversion codes available are defined elsewhere in this manual. Also see OCONV
Examples
InternalDate = ICONV("14 JUL 1964", "D")
In this example ICONV returns the internal form of the date July 14, 1964.
Command Syntax
IF expression THEN|ELSE statements
Syntax Elements
The expression will be evaluated to a value of Boolean TRUE or FALSE. If the expression is TRUE then the
statements defined by the THEN clause will be executed (if present). If the expression is FALSE then the
statements defined by the ELSE clause are executed.
The THEN and ELSE clauses may take two different forms being single and multiple line statements.
The simplest form of either clause is of the form:
IF A THEN CRT A
or
IF A ELSE CRT A
but the clauses may be expanded to enclose multiple lines of code using the END keyword as so:
IF A THEN
A = A*6
CRT A
END ELSE
A = 76
CRT A
END
The single and multi-line versions of either clause may be combined to make complex combinations of the
command. For reasons of readability it is suggested that where both clauses are present for an IF statement that
the same form of each clause is coded.
Notes
IF statements can be nested within either clause to any number of levels.
Examples
CRT "Are you sure (Y/N) ":
INPUT Answer,1_
IF OCONV(Answer, "MCU")= "Y" THEN
GOSUB DeleteFiles
CRT "Files have been deleted"
END ELSE
CRT "File delete was ignored"
END
IN
The IN statement allows the program to receive raw data from the input device, which is normally the terminal
keyboard, one character at a time.
Command Syntax
IN Var {FOR expression THEN|ELSE statements}
Syntax Elements
Var will be assigned the numeric value (0 - 255 decimal) of the next character received from the input device.
The statement will normally wait indefinitely (block) for a character from the keyboard.
Examples
Char2 = ""
IN Char
IF Char = 27 THEN ;* ESC seen
IN Char2 FOR 20 THEN ;* Function Key?
Char2 = CHAR(Char2) ;* ASCII value
END
END
Char = CHAR(Char):Char2 ;* Return key sequence
INDEX( )
The INDEX function will return the position of a character or characters within another string.
Command Syntax
INDEX(expression1, expression2, expression3)
Syntax Elements
Expression1 evaluates to the string to be searched. Expression2 evaluates to the string or character that will be
searched for within expression1. Expression3 should evaluate to a numeric value and specifies which occurrence
of expression2 should be searched for within expression1.
Notes
If the specified occurrence of expression2 cannot be found in expression1 then 0 is returned.
Examples
ABet = "abcdefghijklmnopqrstuvwxyzabc"
CRT INDEX(ABet, 'a', 1)
CRT INDEX(ABet, 'a', 2)
CRT INDEX(ABet, 'jkl', 1)
The above example will print
1
27
10
to the terminal.
INPUT
The INPUT statement allows the program to collect data from the current input device, which will normally be
the terminal keyboard but may be stacked input from the same or separate program.
Command Syntax
INPUT {@(expression1{, expression2)}{:} Var
{{, expression3}, expression4} {:}{_} {WITH expression5}
{FOR expression6 THEN|ELSE statements}
Notes
The INPUT statement will always examine the data input stack before requesting data from the input device. If
data is present on the stack then it is used to satisfy INPUT statements one field at a time until the stack is
exhausted. Once exhausted, the INPUT statement will revert to the input device for further input.
There is no way (by default) to input a null field to the INPUT@ statement. If the INPUT@ statement receives
the newline sequence only as input, then the Var will be unchanged. The INPUTNULL statement should be
used to define a character that indicates a NULL input (see later).
Examples
Answer = ""
LOOP
WHILE Answer = "" DO
INPUT Answer,1 FOR 10 ELSE
GOSUB UpdateClock
END
REPEAT
The above example attempts to read a single character from the input device for 10 deci-seconds (1 second). The
LOOP will exit when a character has been input otherwise every second it will call the local subroutine
UpdateClock.
INPUTNULL
The INPUTNULL statement allows the definition of a character that will allow a null input to be seen by the
INPUT@ statement.
Syntax Elements
The expression should evaluate to a single character. Subsequently, any INPUT@ statement that sees only this
character input before the new-line sequence will NULL the variable in which input is being stored.
If expression evaluates to the NULL string "" then the default character of _ is used to define a NULL input
sequence.
Notes
The INPUT statement does not default to accepting the _ character as a NULL input, the programmer must
explicitly allow this with the statement:
INPUTNULL ""
Examples
INPUTNULL "&"
INPUT @(10,10):Answer,1
IF Answer = "" THEN
CRT "A NULL input was received"
END
INS
The INS statement allows the insertion of elements into a dynamic array.
Command Syntax
INS expression BEFORE Var<expression1{, expression2{, expression3}}>
Syntax Elements
Expression evaluates to the element to be inserted in the dynamic array.
Expression1, expression2 and expression3 should all evaluate to numeric values and specify the Field, Value and
Sub-Value before which the new element is to be inserted.
Notes
Specifying a negative value to any of expressions 1 through 3 will cause the element to appended as the last
Field, Value or Sub-Value rather than at a specific position. Only one of the expressions may be negative
otherwise the first negative value is used correctly but the others are treated as the value 1.
The statement will insert NULL Fields, Values or Sub-Values accordingly if any of the specified insertion points
exceeds the number currently existing.
Example
Values = ""
FOR I = 1 TO 50
INS I BEFORE Values<-1>
NEXT I
FOR I = 2 TO 12
INS I*7 BEFORE Values<7,I>
NEXT I
INSERT
The INSERT command is the function form of the INS statement, which should be used in preference to this
function.
Syntax Elements
Expression1 evaluates to a dynamic array in which to insert a new element and will normally be a variable.
Expression2, Expression3 and Expression4 should evaluate to numeric values and specify the Field, Value and
Sub-Value before which the new element will be inserted.
Expression5 evaluates to the new element to be inserted in expression1.
Notes
See Also INS
Examples
A = INSERT(B, 1,4; "Field1Value4")
INT( )
The INT function truncates a numeric value into its nearest integer form .
Command Syntax
INT( expression)
Syntax Elements
The expression should evaluate to a numeric value. The function will then return the integer portion of the value.
Notes
The function works by truncating the fractional part of the numeric value rather than by standard mathematical
rounding techniques. Therefore INT(9.001) and INT(9.999) will both return the value 9.
Examples
CRT INT(22/7)
LEN( )
The LEN function returns the character length of the supplied expression.
Command Syntax
LEN( expression)
Syntax Elements
Expression can evaluate to any type and the function will convert it to a string automatically.
Examples
Lengths = ""
FOR I = 1 TO 50
Lengths<I> = LEN(Values<I>)
NEXT I
Command Syntax
LN( expression)
Syntax Elements
The expression should evaluate to a numeric value. The function will then return the natural logarithm of that
value.
Notes
The natural logarithm is calculated using the mathematical constant e as a number base.
Examples
A = LN(22/7)
LOCATE
The LOCATE statement finds the position of an element within a specified dimension of a dynamic array.
Command Syntax
LOCATE expression1 IN expression2{<expression3{, expression4}>}
{, expression5} {BY expression6} SETTING Var THEN|ELSE statement(s)
Syntax Elements
Expression1 evaluates to the string that will be searched for in Expression2.
Expression2 evaluates to the dynamic array within which expression1 will be searched for.
Expression3 and expression4, when specified, cause a value or subvalue search respectively.
Expression5 indicates the field, value or subvalue from which the search will begin.
BY expression6 causes the search to expect the elements to be arranged in a specific order, which can
considerably improve the performance of some searches. The available string values for Expression6 are:
"AL" Values are in ascending alphanumeric order.
"AR" Values are in right justified, then ascending order.
"DL" Values are in descending alphanumeric order.
"DR" Values are in right justified, then descending order.
Var will be set to the position of the Field, Value or Sub-Value in which expression1 was found if indeed, it was
found. If it was not found and expression6 was not specified then Var will be set to one position past the end of
the searched dimension. If expression6 did specify the order of the elements then Var will be set to the position
before which the element should be inserted to retain the specified order.
The statement must include one of or both of the THEN and ELSE clauses. If expression1 is found in an
element of the dynamic array the statements defined by the THEN clause are executed. If expression1 is not
found in an element of the dynamic array the statements defined by the ELSE clause are executed.
Notes
See also FIND FINDSTR
Examples
Name = "Jim"
LOCATE Name IN ForeNames BY 'AL' SETTING Pos ELSE
INS Name BEFORE ForeNames<Pos>
END
Command Syntax
LOCK expression {THEN|ELSE statements}
Syntax Elements
The expression should evaluate to a numeric value between 0 and 255 (63 in R83 import mode).
The statement will execute the THEN clause (if defined) providing the lock could be taken. If the LOCK is
already held by another program and an ELSE clause was provided then the statements defined by the ELSE
clause are executed. If no ELSE clause was provided with the statement then it will block (hang) until the lock
has been released by the other program.
Notes
See also UNLOCK
If the program was compiled with the environment variable JBCEMULATE set to R83, the number of execution
locks is limited to 64. If an execution lock greater than this number is specified, the actual lock taken is the
specified number modulo 64.
Examples
LOCK 32 ELSE
CRT "This program is already executing!"
STOP
END
LOOP
The LOOP construct allows the programmer to specify loops with multiple exit conditions.
Command Syntax
LOOP statements1 WHILE|UNTIL expression DO statements2 REPEAT
Syntax Elements
Statements1 and 2 consist of any number of standard statements include the LOOP statement itself, thus
allowing nested loops. Statements1 will always be executed at least once, after which the WHILE or UNTIL
clause is evaluated.
Expression is tested for Boolean TRUE/FALSE by either the WHILE clause or the UNTIL clause. When tested
by the WHILE clause statements2 will only be executed if expression is Boolean TRUE. When tested by the
UNTIL clause, statements2 will only be executed if the expression evaluates to Boolean FALSE.
REPEAT causes the loop to start again with the first statement following the LOOP statement.
Notes
See also BREAK CONTINUE
Examples
LOOP WHILE B < Max DO
Var<B> = B++ *6
REPEAT
LOOP
CRT "+":
WHILE READNEXT KEY FROM List DO
MAT
The MAT command is used to either assign every element in a specified array to a single value or to assign the
entire contents of one array to another.
Command Syntax
MAT Array = expression
MAT Array1 = MAT Array2
Syntax Elements
Array, Array1 and Array2 are all pre-dimensioned arrays declared with the DIM() statement. Expression can
evaluate to any data type.
Notes
Note that if any element of the array Array2 has not been assigned a value then a runtime error message will
occur. This can be avoided by coding the statement MAT Array2 = "" after the DIM statement.
Examples
001 DIM A(45), G(45)
002 MAT G = "Array value"
003 MAT A = MAT G
MATCH{ES}
The MATCH or MATCHES function allows pattern matching to be applied to an expression.
Command Syntax
expression1 MATCHES expression2
Syntax Elements
Expression1 may evaluate to any type. Expression2 should evaluate to a valid pattern matching string as
described below. Expression1 is then matched to the pattern supplied and a value of Boolean TRUE is returned
if the pattern is matched. A value of Boolean FALSE is returned if the pattern is not matched.
Expression2 can contain any number of patterns to match separated by value marks. The value mark implies a
logical OR of the specified patterns and the match will evaluate to Boolean TRUE if expression1 matches any of
the specified patterns.
Notes
Pattern matching strings are constructed from the rule table shown below. When reading the table n refers to any
integer number.
Pattern Explanation
nN This construct matches a sequence of n digits.
nA This construct matches a sequence of n alpha
characters.
Examples
IF Var MATCHES "0N" THEN CRT "A match!"
matches if all characters in Var are numeric or Var is a null string.
IF Var MATCHES "0N'.'2N".......
matches if Var contains any number of numerics followed by the . character followed by 2 numeric characters.
e.g. 345.65 or 9.99
Pattern = "4X':'6N'; 2A
Matched = Serno MATCHES Pattern
matches if the variable Serno consists of a string of 4 arbitrary characters followed by the : character then 6
numerics then the ; character and then 2 alphabetic characters. e.g. 1.2.:123456;A2 or 17st:456789;FB
MATBUILD
Command Syntax
The MATBUILD statement is used to create a dynamic array out of a dimensioned array.
MATBUILD variable FROM array{, expression1{, expression2}}
{USING expression3}
Syntax Elements
Variable is the jBC variable into which the created dynamic array will be stored. Array is a previously
dimensioned and assigned matrix from which the dynamic array will be created. Expression1 and expression2
should evaluate to numeric integers. Expression1 specifies which element of the array the extraction will start
with, expression2 specifies which element of the array the extraction will end with (inclusive).
By default, each array element is separated in the dynamic array by a field mark. By specifying expression3, the
separator character can be changed. If expression3 evaluates to more than a single character, only the first
character of the string is used.
Notes
When specifying start and end positions with multi-dimensional arrays, it is necessary to expand the matrix into
its total number of variables to calculate the correct element number. See the information about dimensioned
arrays earlier in this chapter for detailed instructions on calculating element numbers.
Examples
DIM A(40)
MATBUILD Dynamic FROM A,3,7 USING ':'
Builds a 5 element string separated by a : character.
MATBUILD Dynamic FROM A
Builds a field mark separated dynamic array from every element contained in the matrix A.
Command Syntax
The MATPARSE statement is used to assign the elements of a matrix from the elements of a dynamic array.
MATPARSE array{, expression1{, expression2}} FROM variable1
{USING expression3} SETTING variable2
Syntax Elements
Array is a previously dimensioned matrix, which will be assigned to from each element of the dynamic array.
Variable1 is the jBC variable from which the matrix array will be stored. Expression1 and expression2 should
evaluate to numeric integers. Expression1 specifies which element of the array the assignment will start with,
expression2 specifies which element of the array the assignment will end with (inclusive).
By default, each array element in the dynamic array is assumed to be separated by a field mark. By specifying
expression3, the separator character can be changed. If expression3 evaluates to more than a single character,
only the first character of the string is used.
As assignment will stop when the contents of the dynamic array have been exhausted, it can be useful to
determine the number of matrix elements that were actually assigned to. If the SETTING clause is specified then
variable2 will be set to the number of elements of the array that were assigned to.
Notes2
When specifying start and end positions with multi-dimensional arrays, it is necessary to expand the matrix into
its total number of variables to calculate the correct element number. See the information about dimensioned
arrays earlier in this section for detailed instructions on calculating element numbers.
Examples
DIM A(40)
MATPARSE A,3,7 FROM Dynamic
Assign 5 elements of the array starting at element 3.
MATREAD
The MATREAD statement allows a record stored in a jBASE file to be read and mapped directly into a
dimensioned array.
Command Syntax
MATREAD array FROM {variable1,}expression {SETTING setvar} {LOCKED statements} {THEN|ELSE
statements}
Syntax Elements
Array should be a previously dimensioned array, which will be used to store the record to be read. Variable1, if
specified, should be a jBC variable that has previously been opened to a file using the OPEN statement. If
variable1 is not specified then the default file is assumed (see OPEN statement). The expression should evaluate
to a valid record key for the file.
If the record is found and can be read from the file then it is mapped into array and the THEN statements are
executed (if any). If the record cannot be read from the file for some reason then array is unchanged and the
ELSE statements (if any) are executed.
2
It is our opinion that MATBUILD and MATPARSE have been named the wrong way round, but imagine the confusion if we had changed them!
Notes
The record is mapped into the array using a predefined algorithm. The record is expected to consist of a number
of Field separated records, which are then assigned one at a time to each successive element of the matrix. See
the notes on matrix organisation earlier in this section for details of multi dimensional arrays.
If there were more fields in the record than elements in the array then the final element of the array will be
assigned all remaining fields. If there were fewer fields in the record than elements in the array then remaining
array elements will be assigned a null value.
Note that if multivalues are read into an array element they will then be referenced individually as:
Array(n)<1,m>
not: Array(n)<m>
Examples
MATREAD Xref FROM CFile, "XREF" ELSE MAT Xref = ""
MATREAD Ind FROM IFile, "INDEX" ELSE MAT Ind = 0
MATREADU
The MATREADU statement allows a record stored in a jBASE file to be read and mapped directly into a
dimensioned array. The record will also be locked for update by the program.
Command Syntax
MATREADU array FROM {variable1,}expression {SETTING setvar} {LOCKED statements}
{THEN|ELSE statements}
Syntax Elements
Array should be a previously dimensioned array, which will be used to store the record to be read. Variable1, if
specified, should be a jBC variable that has previously been opened to a file using the OPEN statement. If
variable1 is not specified then the default file is assumed (see OPEN statement). The expression should evaluate
to a valid record key for the file.
If the record is found and can be read from the file then it is mapped into array and the THEN statements are
executed (if any). If the record cannot be read from the file for some reason then array is unchanged and the
ELSE statements (if any) are executed.
If the record could not be read because another process already had a lock on the record then one of two actions
is taken. If the LOCKED clause was specified in the statement then the statements dependant on it are executed.
If no LOCKED clause was specified then the statement blocks (hangs) until the lock is released by the other
process.
If the SETTING clause is specified, setvar will be set to the number of fields in the record on a successful read.
If the read fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
Notes
The record is mapped into the array using a predefined algorithm. The record is expected to consist of a number
of Field separated records, which are then assigned one at a time to each successive element of the matrix. See
the notes on matrix organisation earlier in this section for details of the layout of multi dimensional arrays.
If there were more fields in the record than elements in the array then the final element of the array will be
assigned all remaining fields. If there were fewer fields in the record than elements in the array then remaining
array elements will be assigned a null value.
Note that if multivalues are read into an array element they will then be referenced individually as:
Array(n)<1,m>
not: Array(n)<m>
Examples
MATREADU Xref FROM CFile, "XREF" ELSE MAT Xref = ""
MATREADU Ind FROM IFile, "INDEX" LOCKED
GOSUB InformUserLock ;* Say it is locked
END THEN
GOSUB InformUserOk ;* Say we got it
END ELSE
MAT Ind = 0 ;* It was not there
END
MATWRITE
The MATWRITE statement transfers the entire contents of a dimensioned array to a specified record on disc.
Command Syntax
MATWRITE array ON {variable,}expression {SETTING setvar} {ON ERROR statements} {THEN|ELSE
statements}
Syntax Elements
Array should be a previously dimensioned and initialised array. If specified, variable should be a previously
opened file variable (i.e. the subject of an OPEN statement). If variable is not specified the default file variable
is used. Expression should evaluate to the name of the record in the file.
The THEN|ELSE clause is optional on the MATWRITE statement. If the write is successful, the THEN
statements will be executed. If the write fails (because of security permissions for instance), the ELSE
statements are executed.
If the SETTING clause is specified and the write fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
The compiler will check that the variable specified is indeed an array and has been dimensioned before its use in
the statement.
Examples
DIM A(8)
MAT A = 99
....
MATWRITEU
The MATWRITEU statement transfers the entire contents of a dimensioned array to a specified record on file,
in the same manner as the MATWRITE statement. An existing record lock will be preserved.
Command Syntax
MATWRITEU array ON {variable,}expression {SETTING setvar} {ON ERROR statements}
{THEN|ELSE statements}
Syntax Elements
Array should be a previously dimensioned and initialised array. If specified, variable should be a previously
opened file variable (i.e. the subject of an OPEN statement). If variable is not specified the default file variable
is used. Expression should evaluate to the name of the record in the file.
The THEN|ELSE clause is optional on the MATWRITE statement. If the write is successful, the THEN
statements will be executed. If the write fails (because of security permissions for instance), the ELSE
statements are executed.
If the SETTING clause is specified and the write fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
The compiler will check that the variable specified is indeed an array and has been dimensioned before its use in
the statement.
Examples
DIM A(8)
MAT A = 99
....
MATWRITEU A ON "NewArray"
Command Syntax
MOD(expression1, expression2)
Syntax Elements
Both expression1 and expression2 should evaluate to numeric expressions or a runtime error will occur.
Notes
The modulo is calculated as the remainder of expression1 divided by expression2.
If expression2 evaluates to 0, then the value of expression1 is returned.
Examples
FOR I = 1 TO 10000
NOT( )
The NOT function is used to invert the Boolean value of an expression. It useful for explicitly testing for a false
condition.
Command Syntax
NOT(expression)
Syntax Elements
Expression may evaluate to any Boolean result.
Notes
The NOT function will return Boolean TRUE if the expression returned a Boolean FALSE. It will return
Boolean FALSE of the expression returned a Boolean TRUE.
The NOT function is useful for explicitly testing for the false condition of some test and can clarify the logic of
such a test.
Examples
EQU Sunday TO NOT(MOD(DATE(), 7))
IF Sunday THEN
CRT "It is Sunday!"
END
In this example the expression MOD(DATE(),7) will return 0 (FALSE) if the day is Sunday and 1 to 6 (TRUE)
for the other days. To explicitly test for the day Sunday we need to invert the result of the expression. BY using
the NOT function we return a 1 (TRUE) if the day is Sunday and 0 (FALSE) for all other values of the
expression.
NULL
The NULL statement performs no function but can be useful in clarifying syntax and where the language
requires a statement but the programmer does not wish to perform any actions.
Command Syntax
NULL
Syntax Elements
None.
Examples
LOCATE A IN B SETTING C ELSE NULL
NUM( )
The NUM function is used to test arguments for numeric values.
Command Syntax
NUM(expression)
Syntax Elements
Expression may evaluate to any data type.
Examples
LOOP
INPUT Answer,1
IF NUM(Answer) THEN BREAK ;* Exit loop if numeric
REPEAT
OCONV( )
The OCONV statement is used to convert internal representations of data to their external form.
Command Syntax
OCONV(expression1, expression2)
Syntax Elements
Expression1 may evaluate to any data type but should be relevant to the conversion. Expression2 should evaluate
to a conversion code from the list below. Alternatively, expression2 may evaluate to a user exit known to the
jBC language or supplied by the user (see external interfaces documentation).
Notes
OCONV will return the result of the conversion of expression1 by expression2. Valid conversion codes are
shown below:
Conversion Action
D{n{c}} Converts an internal date to an external date format. The numeric argument
n specifies the field width allowed for the year and can be 0 to 4 (default 4).
The character c causes the date to be return in the form ddcmmcyyyy. If it is
not specified the month name is return in abbreviated form.
DI Allow the conversion of an external date to the internal format even though
an output conversion is expected.
DD Returns the day in the current month.
DM Returns the number of the month in the year.
DMA Returns the name of the current month.
DJ Returns the number of the day in the year (0-366).
DQ Returns the quarter of the year as a number 1 to 4
DW Returns the day of the week as a number 1 to 7 (Monday is 1).
DWA Returns the name of the day of the week.
DY{n} Returns the year in a field of n characters.
F Given a prospective filename for a command such as CREATE-FILE this
conversion will return a filename that is acceptable to the version of UNIX
jBASE is running on.
MCA Removes all but alphabetic characters from the input string.
MC/A Removes all but the NON alphabetic characters in the input string.
MCN Removes all but numeric characters in the input string
Conversion Action
MC/N Removes all but NON numeric characters in the input string
ON...GOSUB, ON...GOTO
The ON...GOSUB and ON...GOTO statements are used to transfer program execution to a label based upon a
calculation.
Command Syntax
ON expression GOTO label{, label...}
ON expression GOSUB label{, label...}
Syntax Elements
Expression should evaluate to an integer numeric value. Labels should be defined somewhere in the current
source file.
ON GOTO will transfer execution to the labelled source code line in the program. ON GOSUB will transfer
execution to the labelled subroutine within the source code.
Notes
The value of expression is used as an index to the list of labels supplied. If the expression evaluates to 1 then the
first label will be jumped to, 2 then the second label will be used and so on.
If the program was compiled with the environment variable JBCEMULATE set to R83 then no validations are
performed on the index to see if it is valid. Therefore if the index is out of range this instruction will take no
action and report no error.
If the program was compiled for other compatibilities then the index will be range checked. If the index is found
to be less than 1 it is assumed to be 1 and a warning message is issued. If the index is found to be too big, then
the last label in the list will be used to transfer execution and a warning message issued.
OPEN
The OPEN statement is used to open a file or device to a descriptor variable within jBC.
Command Syntax
OPEN {expression1,}expression2 TO {variable} {SETTING setvar} THEN|ELSE statements
Syntax Elements
The combination of expression1 and expression2 should evaluate to a valid file name of a file type that has been
installed into the jBASE system. If the file has a dictionary section and this is to be opened by the statement then
this may be emphasised by the literal string "DICT" being specified in expression1. If specified, the variable will
be used to hold the descriptor for the file. It should then be to access the file using READ and WRITE. If no file
descriptor variable is supplied, then the file will be opened to the default file descriptor.
Specific data sections of a multi level file may specified by separating the section name from the file name by a
',' char in expression2.
If the OPEN statement fails it will execute any statements associated with an ELSE clause. If the OPEN is
successful it will execute any statements associated with a THEN clause. Note that the syntax requires either one
or both of the THEN and ELSE clauses.
If the SETTING clause is specified and the open fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
The OPEN statement uses the environment variable JEDIFILEPATH to search for the file named. If this is not
defined then the current working directory is looked in followed by the home directory of the current process.
See the documentation on environment variables for more details.
The file that is the subject of the OPEN statement can be of any type known to the jBASE system. Its type will
be determined and correctly opened transparently to the application, which need not be aware of the file type.
There is no limit to the number of files that may be opened by a jBC program.
Examples
OPEN "DICT", "CUSTOMERS" TO F.Dict.Customers ELSE
ABORT 201, "DICT CUSTOMERS"
END
opens the dictionary section of file CUSTOMERS to its own file descriptor F.Dict.Customers.
OPEN "CUSTOMERS" ELSE ABORT 201, "CUSTOMERS"
opens the CUSTOMERS file to the default file variable.
OUT
The OUT statement is used to send raw characters to the current output device (normally the terminal).
Command Syntax
OUT expression
Notes
The numeric expression is first converted to the raw ASCII character specified and then sent directly to the
output advice.
Examples
EQUATE BELL TO OUT 7
BELL ;* Sound terminal bell
FOR I = 32 TO 127; OUT I; NEXT I ;* Printable chars
BELL
PAGE
Prints any FOOTING statement, throws a page and prints any heading statement on the current output device.
Command Syntax
PAGE {expression}
Syntax Elements
If expression is specified it should evaluate to a numeric integer, which will cause the page number after the page
throw to be set to this value.
Examples
HEADING "10 PAGE REPORT"
FOR I = 1 TO 10
PAGE
GOSUB PrintPage
NEXT I
PERFORM
Notes
See EXECUTE
PRECISION
The PRECISION statement informs jBASE as to the number of digits of precision it uses after the decimal
point in numbers.
Command Syntax
PRECISION integer
Syntax Elements
Integer should be in the range 0 to 9.
Notes
PRECISION is a compiler directive rather than a jBC executable statement and may only be specified once in a
source file.
Calling programs and external subroutines MUST be compiled at the same degree of precision or unpredictable
results will occur in calculations.
Examples
PRECISION 6
CRT 2/3
will print the value 0.666666 (note truncation not rounding!).
PRINT
The PRINT statement sends data directly to the current output device, which will either be the terminal or the
printer.
Command Syntax
PRINT expression {, expression...} {:}
Syntax Elements
An expression can evaluate to any data type. The PRINT statement will convert the result to a string type for
printing. Expressions separated by commas will be sent to the output device separated by a tab character.
The PRINT statement will append a newline sequence to the final expression unless it is terminated with a colon
':' character.
Notes
As the expression can be any valid expression, it may have output formatting applied to it.
If a PRINTER ON statement is currently active then output will be sent to the currently assigned printer form
queue, (see also SP-ASSIGN command).
See also: CRT
Examples
PRINT A "L#5"
PRINT @(8,20):"Patrick":
PRINTER ON|OFF|CLOSE
The PRINTER statement is used to control the destination of output from the PRINT statement.
Command Syntax
PRINTER ON|OFF|CLOSE
Notes
PRINTER ON will cause all subsequent output from the PRINT statement to be redirected to the print spooler.
PRINTER OFF will cause all subsequent output from the PRINT statement to be redirected to the terminal
device.
PRINTER CLOSE will act as PRINTER OFF but in addition will close the currently active spool job created
by the active PRINTER ON statement.
Examples
PRINTER ON ;* Open a spool job
FOR I =1 TO 60
PRINT "Line ":I ;* Send to printer
PRINTER OFF
PRINT "+": ;* Send to terminal
PRINTER ON ;* Back to printer
PRINTERR
To print standard jBASE error messages.
Command Syntax
PRINTERR expression
Syntax Elements
Field 1 of the expression should evaluate to the numeric or string name of a valid error message in the jBASE
error message file. If the error message requires parameters then these can be passed to the message as
subsequent fields of the expression.
Notes
The PRINTERR statement is most useful for user defined messages that have been added to the standard set.
See the section on error messages in this manual for more information.
You should be very careful when typing this statement it is very similar to the PRINTER statement. Although
this is not ideal, the PRINTERR statement must be supported for compatibility with older systems.
Examples
PRINTERR 201:CHAR(254):"CUSTOMERS"
PROCREAD
Used to retrieve data passed to programs from a jCL program.
Command Syntax
PROCREAD variable THEN|ELSE statements
Syntax Elements
Variable is a valid jBC identifier, which will be used to store the contents of the primary input buffer of the last
jCL program called.
If the program was not initiated by a jCL program then the PROCREAD will fail and any statements associated
with an ELSE clause will be executed. If the program was initiated by a jCL program then the PROCREAD
will succeed, the jCL primary input buffer will be assigned to variable and any statements associated with a
THEN clause will be executed.
Notes
It is recommended that the use of jCL and therefore the PROCREAD statement should be not be expanded
within your application and gradually replaced with more sophisticated methods such as UNIX scripts or jBC
programs.
Examples
PROCREAD Primary ELSE
CRT "Unable to read the jCL buffer"
STOP
END
PROCWRITE
Used to pass data back to the primary input buffer of a calling jCL program.
Syntax Elements
Expression may evaluate to any valid data type.
Notes
See also: PROCREAD
Examples
PROCWRITE "Success":CHAR(254):"0"
PROGRAM
Performs no function other than to document the source code.
Command Syntax
PROGRAM progname
Syntax Elements
Progname can be any string of characters.
Notes
Examples
PROGRAM HelpUser
!
! Start of program
PROMPT
Used to change the prompt character used by terminal input commands
Command Syntax
PROMPT expression
Syntax Elements
Expression can evaluate to any printable string.
Notes
The entire string is used as the prompt.
The default prompt character is the question mark '?' character.
Examples
PROMPT "Next answer : "
INPUT Answer
PUTENV
Used to set environment variables for the current process.
Command Syntax
PUTENV(expression)
Notes
PUTENV only sets environment variables for the current process and processes spawned (say by EXECUTE)
by this process. These variables are known as export only variables.
Examples
IF PUTENV("JBCLOGNAME=":UserName) THEN
CRT "Environment configured"
END
PWR( )
The PWR function raises a number to the nth power.
Command Syntax
PWR(expression1, expression2)
or
expression1 ^ expression2
Syntax Elements
Both expression1 and expression2 should evaluate to numeric arguments. The function will return the value of
expression1 raised to the value of expression2.
Notes
If expression1 is negative and expression2 is not an integer then a maths library error is displayed and the
function returns the value 0. The error message displayed is:
pow: DOMAIN error
All calculations are performed at the maximum precision supported on the host machine and truncated to the
compiled precision on completion.
Examples
A = 2
B = 31
CRT "2 GB is ":A^B
or
CRT 2GB is:PWR(A,B)
READ
The READ statement allows a program to read a record from a previously opened file into a variable.
Command Syntax
READ variable1 FROM {variable2,} expression {SETTING setvar} {LOCKED statements} THEN|ELSE
statements
Notes
If the record could not be read because another process already had a lock on the record then one of two actions
is taken. If the LOCKED clause was specified in the statement then the statements dependant on it are executed.
If no LOCKED clause was specified then the statement blocks (hangs) until the lock is released by the other
process.
On a successful read, if a LOCKED clause is used, a lock will be set.
Many programmers assume that using a LOCKED clause with a READ statement will allow a test for the
record being locked without setting a lock for the current program. In fact this is not the case as the use of a
LOCKED clause will result in a lock being taken against the record. As the programmer has assumed a lock is
not taken on the record this can result in erroneous programs.
If you wish to set a lock on a record you should do so explicitly with the READU statement.
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
READ Rec FROM DCusts, "Xref" THEN
READ DataRec FROM Rec<7> ELSE
ABORT 202, Rec<7>
END
END ELSE
ABORT 202, "Xref"
END
READLIST
READLIST allows the program to retrieve a previously stored list (perhaps created with the SAVE-LIST
command), into a jBC variable.
Command Syntax
READLIST variable1 FROM expression {SETTING variable2} THEN|ELSE statements
Syntax Elements
Variable1 is the variable into which the list will be read. Expression should evaluate to the name of a previously
stored list to retrieve. Variable2 (if specified) will be set to the number of elements in the list.
If the statement succeeds in retrieving the list, then the statements associated with any THEN clause will be
executed. If the statement fails to find the list, then the statements associated with any ELSE clause will be
executed.
Notes
The READLIST statement is identical in function to the GETLIST statement.
Examples
* Find the list first
READLIST MyList FROM "MyList" ELSE STOP
LOOP
* Loop until there are no more elements
WHILE READNEXT Key FROM MyList DO
......
REPEAT
READNEXT
READNEXT retrieves the next element in a list variable.
Command Syntax
READNEXT variable1, variable2 {FROM variable3} {SETTING setvar} {THEN|ELSE statements}
Syntax Elements
Variable1 is the variable into which the next element of the list will be read.
Variable2 is used when the list has been retrieved externally from a SSELECT or similar jBASE command that
has used an exploding sort directive. When specified, this variable will be set to the multi-value reference of the
current element. For example, if the SSELECT used a BY-EXP directive on field 3 of the records in a file, the
list will contain each record key in the file as many times as there are multi-values in the field. Each
READNEXT instance will set variable2 to the multi-value in field 3 that the element refers to. This allows the
multi-values in field 3 to be retrieved in sorted order.
If variable3 is specified with the FROM clause, the READNEXT operates on the list contained in variable3. If
variable3 is not specified, the default select list variable will be assumed.
If the SETTING clause is specified and the read (to build the next portion of the list) fails, setvar will be set to
one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
See also: SELECT
READNEXT can be used as an expression returning a Boolean TRUE or FALSE value. If an element is
successfully read from the list, TRUE is returned. If the list was empty, FALSE is returned.
Examples
LOOP
WHILE READNEXT Key FROM RecordList DO
......
REPEAT
READT
The READT statement is used to read a range of tape devices 0-9.
Command Syntax
READT variable {FROM expression} THEN|ELSE statements
Notes
A "tape" does not refer to magnetic tape devices only but any device that has been described to jBASE. Writing
device descriptors for jBASE is beyond the scope of this manual.
If no tape device has been assigned to the channel specified then the jBASE debugger is entered with an
appropriate message.
Each instance of the READT statement will read the next record available on the device. The record size is not
limited to a single tape block and the entire record will be returned whatever block size has been allocated by the
T-ATT command.
Examples
LOOP
READT TapeRec FROM 5 ELSE
Reason = SYSTEM(0)
IF Reason = 2 THEN BREAK ;* done
CRT "ERROR"; STOP
END
REPEAT
READU
The READU statement allows a program to read a record from a previously opened file into a variable. It
respects record locking and locks the specified record for update.
Command Syntax
READU variable1 FROM {variable2,} expression {SETTING setvar} {LOCKED statements} THEN|ELSE
statements
Syntax Elements
Variable1 is the identifier into which the record will be read.
Variable2, if specified, should be a jBC variable that has previously been opened to a file using the OPEN
statement. If variable2 is not specified then the default file is assumed (see OPEN statement).
The expression should evaluate to a valid record key for the file.
If the SETTING clause is specified and the read fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
LOOP
READU Rec FROM DCusts, "Xref" LOCKED
CRT "Locked - retrying"
SLEEP 1; CONTINUE ;* Restart LOOP
END THEN
READ DataRec FROM Rec ELSE
ABORT 202, Rec
END
BREAK ;* Leave the LOOP
END ELSE
ABORT 202, "Xref"
END
REPEAT
READV
The READV statement allows a program to read a specific field from a record in a previously opened file into a
variable.
Command Syntax
READV variable1 FROM {variable2,} expression1, expression2 {SETTING setvar} {LOCKED statements}
THEN|ELSE statements
Syntax Elements
Variable1 is the identifier into which the record will be read.
Variable2, if specified, should be a jBC variable that has previously been opened to a file using the OPEN
statement. If variable2 is not specified, the default file is assumed (see OPEN statement).
Expression1 should evaluate to a valid record key for the file.
Expression2 should evaluate to a positive integer. If the number is invalid or greater than the number of fields in
the record, a NULL string will be assigned to variable1. If a non-numeric argument is evaluated, a run time error
will occur.
If the SETTING clause is specified and the read fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
Notes
If the record could not be read because another process had already set a lock, one of two actions is taken. If the
LOCKED clause was specified in the statement, the associated statements are executed. If a LOCKED clause
was not specified, the process will pause (hang) until the lock is released by the other process.
On a successful read, if a LOCKED clause is used, a lock will be set.
A common error is to assume that using a LOCKED clause will allow you to test for the record being locked
without actually setting a lock. This is not the case. If you use a LOCKED clause, a lock will be set against the
record.
If you wish to set a lock on a record you should do so explicitly with the READVU statement.
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
READV Rec FROM DCusts, "Xref,7 THEN
READ DataRec FROM Rec<7> ELSE
ABORT 202, Rec<7>
END
END ELSE
ABORT 202, "Xref"
END
READVU
The READVU statement allows a program to read a specific field in a record in a previously opened file into a
variable. It also respects record locking and locks the specified record for update.
Command Syntax
READVU variable1 FROM {variable2,} expression1, expression2 {SETTING setvar} {LOCKED
statements} THEN|ELSE statements
Syntax Elements
Variable1 is the identifier into which the record will be read.
Variable2, if specified, should be a jBC variable that has previously been opened to a file using the OPEN
statement. If variable2 is not specified then the default file is assumed (see OPEN statement).
Expression1 should evaluate to a valid record key for the file.
Expression2 should evaluate to a positive integer number. If the number is invalid or greater than the number of
fields in the record, then a NULL string will be assigned to variable1. If a non-numeric argument is evaluated a
run time error will occur.
If the SETTING clause is specified and the read fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
If the record could not be read because another process already had a lock on the record then one of two actions
is taken. If the LOCKED clause was specified in the statement then the statements dependant on it are executed.
If no LOCKED clause was specified then the statement blocks (hangs) until the lock is released by the other
process.
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
LOOP
READVU Rec FROM DCusts, "Xref,7 LOCKED
CRT "Locked - retrying"
SLEEP 1; CONTINUE ;* Restart LOOP
END THEN
READ DataRec FROM Rec ELSE
ABORT 202, Rec
END
BREAK ;* Leave the LOOP
END ELSE
ABORT 202, "Xref"
END
REPEAT
REGEXP
The REGEXP function is a very powerful function that allows pattern matching using UNIX regular
expressions.
Command Syntax
REGEXP(variable, expression)
Syntax Elements
Variable can be any type of jBC variable and is the variable upon which pattern matching will be performed.
Expression should evaluate to a standard UNIX regular expression as defined in the UNIX documentation.
Notes
The function returns a numeric integer value being the first character in variable that failed to match the
specified regular expression. If a match is not found or the regular expression was invalid then the function
returns 0.
Examples
String = "James Anthony Computing"
CRT REGEXP(String, "C[^t]*")
would display the value 20 being the position of the character 't' in the word Computing.
RELEASE
The RELEASE statement enables a program to explicitly release record locks without updating the records
using WRITE.
Syntax Elements
If variable is specified it should be a valid file descriptor variable (i.e. It should have been the subject of an
OPEN statement).
If an expression is supplied it should evaluate to the record key of a record whose lock the program wishes to
free. If variable was specified the record lock in the file described by it is released. If variable was not specified
the record lock in the file described by the default file variable is released.
If RELEASE is issued without arguments then all record locks in all files that were set by the current program
will be released.
Notes
Where possible the program should avoid the use of RELEASE without arguments. This is less efficient and can
be a dangerous - especially in subroutines.
Examples
READU Rec FROM File, "Record" ELSE ABORT 203, "Record"
IF Rec<1> = "X" THEN
RELEASE File, "Record"
END
......
REMOVE
REMOVE will successively extract delimited strings from a dynamic array.
Command Syntax
REMOVE variable FROM array SETTING setvar
Syntax Elements
variable is the variable which is to receive the extracted string.
array is the dynamic array from which the string is to be extracted.
setvar is set by the system during the extraction to indicate the type of delimiter found - as described in the
following table:
0 end of the array
1 xFF ASCII 255
2 xFE ASCII 254 Field marker
3 xFD ASCII 253 Value marker
4 xFC ASCII 252 Subvalue marker
5 xFB ASCII 251
6 xFA ASCII 250
7 xF9 ASCII 249
Notes
The first time the REMOVE statement is used with a particular array, it will extract the first delimited string it
and set the special remove pointer to the start of the next string (if any). The next time REMOVE is used on the
same array, the pointer will be used to retrieve the next string and so on. The array is not altered.
The variable named in the SETTING clause is used to record the type of delimiter that was found - so that you
can tell whether the REMOVE statement extracted a field, a value or a subvalue for example. Delimiters are
defined as characters between xF9 and xFF only.
Example
EQU FM TO CHAR(254), VM to CHAR(253), SVM to CHAR(252)
REC = Field 1:FM:Value 1:VM:Value 2:FM:Field 3
REMOVE EXSTRING FROM REC SETTING DELIM
REMOVE EXSTRING FROM REC SETTING DELIM
The first time REMOVE is used, EXSTRING will contain Field 1 and DELIM will contain xFE. The second
time REMOVE is used, EXSTRING will contain Value 1 and DELIM will contain xFD.
REPLACE
This is an obsolete way to assign to dynamic arrays via a function.
Command Syntax
REPLACE (var, expression1{, expression2{, expression3}}; expression4)
Syntax Elements
Var is the dynamic array that the REPLACE function will use to assign expression4. Unless the same var is
assigned the result of the function it will be unchanged.
Expression1 specifies into which field assignment will be made and should evaluate to a numeric.
Expression2 is only specified when multi-value assignment is to be done and should evaluate to a numeric.
Expression3 is only specified when sub-value assignment is to be done and should evaluate to a numeric.
Expression4 can evaluate to any data type and is the actual data that will be assigned to the array.
Notes
The function returns a copy of var with the specified replacement carried out. This value may be assigned to the
original var in which case the jBC compiler will optimise the assignment.
See the heading Dynamic Arrays earlier in this chapter for information on the preferred method of accessing
dynamic arrays.
Examples
X = "JBASE":MV:"is Great"
X = REPLACE(X,1,1;"jBASE")
RETURN
The RETURN statement transfers program execution to the caller of a subroutine or to a specific label in the
program.
Command Syntax
RETURN {TO label}
Notes
The RETURN statement will transfer program execution to the statement after the GOSUB that called the
current internal subroutine.
If the RETURN statement is executed in an external SUBROUTINE and there are no outstanding GOSUBs,
then the program will transfer execution back to the program that called it via CALL.
The program will enter the debugger with an appropriate message should a RETURN be executed with no
GOSUB or CALL outstanding.
Command Syntax
REWIND {ON expression} THEN|ELSE statements
Syntax Elements
Expression, if specified, should evaluate to an integer in the range 0 to 9. Default is 0.
Notes
If the statement fails to issue the rewind then any statements associated with the ELSE clause are executed. If
the statement successfully issues the rewind command then the statements associated with any THEN clause are
executed. Either or both of the THEN and ELSE clauses must be specified with the statement.
If the statement fails then the reason for failure can be determined via the value of SYSTEM(0) as follows:
Value Meaning
1 There is no media attached to the channel
2 An end of file mark was found.
RND
The RND statement allows the generation of random numbers by a program.
Command Syntax
RND(expression)
Syntax Elements
Expression should evaluate to a numeric integer value or a runtime error will occur. The absolute value of
expression is used by the function (see ABS).
Notes
The function will return a random integer number between 0 and the value of expression-1.
Examples
FOR I=1 TO 20
CRT RND(100):", ":
NEXT I
prints 20 random numbers in the inclusive range 0 to 99.
RQM
See SLEEP
RTNDATA
The RTNDATA statement allows a jBC program to return specific data to the RTNDATA clause of another
programs EXECUTE statement.
Command Syntax
RTNDATA expression
Syntax Elements
Expression may evaluate to any data type.
SELECT
The SELECT statement creates a select list of elements in a specified variable.
Command Syntax
SELECT {variable1} {TO variable2} {SETTING setvar}
Syntax Elements
variable1 can be an OPENed file descriptor, in which case the record keys in the specified file will be selected,
or an ordinary variable in which case each field in the variable will become a list element. Variable1 may also be
an existing list in which case the elements in the list will be selected.
If variable1 is not specified in the statement then the default file variable is assumed.
If variable2 is specified then the newly created list will be placed in the variable. If variable2 is not specified
then the default list variable will be assumed.
If the SETTING clause is specified and the select fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
When a list is being built from record keys in a file, the list is not created immediately by scanning the file for all
the record keys. Instead, only the first few keys will be extracted. When these keys have been taken from the list,
the next few keys will be obtained and so on. This means that the list could contain records that are written to
the file after the SELECT command is started.
Consider the situation where you open a file, SELECT it and then, on the basis of the keys obtained, write new
records to the same file. It would be easy to assume that these new keys would not show up in the list because
you created the list before the new records existed. THIS IS NOT THE CASE. Any records written beyond the
current position in the file will eventually show up in the list. In situations where this might cause a problem, or
to ensure that you obtain a complete, qualified list of keys, you should use a slower external command like jQL
SELECT or SSELECT and then READNEXT to parse the file.
Lists can be selected as many times as required.
Example
OPEN "Customers" ELSE ABORT 201, "Customers"
SELECT TO CustList1
SELECT TO CustList2
.....
SENTENCE
The SENTENCE statement allows a program to find out the command used to invoke it and the arguments it
was given.
Command Syntax
SENTENCE({expression})
Notes
The command line arguments are assumed to be space separated and when the entire command line is returned
they are returned as such.
Examples
DIM Parm(5)
ProgName = SENTENCE(1) ;* Program is ?
FOR I = 2 TO 5
Parm(I) = SENTENCE(I) ;* Get parameters
NEXT I
SEQ( )
The SEQ function returns numeric ASCII value of a character.
Command Syntax
SEQ(expression)
Syntax Elements
Expression may evaluate to any data type. However the SEQ function will convert the expression to a string and
operate on the first character of that string.
Notes
SEQ operates on any character in the integer range 0 to 255
Examples
EQU ENQ TO 5
* Get next comms code
* Time-out after 20 seconds
INPUT A,1 FOR 200 ELSE BREAK
IF SEQ(A) = ENQ THEN
* Respond to ENQ char
......
SIN( )
The SIN function returns the mathematical sine value of a numeric expression.
Command Syntax
SIN(expression)
Syntax Elements
Expression should evaluate to a numeric value and is interpreted as a number of degrees between 0 and 360.
Notes
The function will calculate the sine of the angle specified by the expression as accurately as the host system will
allow. It will then truncate the value according to the PRECISION of the program.
SLEEP
Allows the program to halt execution for a specified time period.
Command Syntax
SLEEP {expression}
Syntax Elements
Expression may evaluate to one of two forms:
Numeric in which case the statement will sleep for the specified number of seconds.
"nn:nn{:nn}" in which case the statement will sleep until the time specified.
If expression is not supplied then a default time period of 1 second is assumed.
Notes
Sleeping until a specified time works by calculating the time between the current time and the time supplied and
sleeping for that many seconds. If the host clock is changed in the meantime then the program will not wake up
at the desired time.
Examples
* Sleep until the end of the working day for anyone
* who doesn't program computers.
SLEEP "17:30"
*
* 40 winks...
SLEEP 40
SORT( )
The SORT function allows the program to sort a dynamic array.
Command Syntax
SORT(expression)
Syntax Elements
Expression may evaluate to any data type but will only be useful if it evaluates to a dynamic array.
Notes
The SORT command will return a dynamic array sorted by the highest delimiter found in the array. This means
the if it is passed a list of fields it will sort by field but if passed a list of sub-values it will sort by sub-values.
The SORT is achieved by the quick sort algorithm, which sorts in situ and is very fast.
Examples
* Read a list, sort it and write it back
*
READ List FROM "Unsorted" ELSE List = ""
List = SORT(List)
SOUNDEX( )
The SOUNDEX function allows phonetic conversions of strings.
Command Syntax
SOUNDEX(expression)
Syntax Elements
Expression may evaluate to any data type but the function will only give meaningful results for English words.
Notes
The phonetic equivalent of a string is calculated as the first alphabetic character in the string followed by a 1 to 3
digit representation of the rest of the word.
The digit string is calculated from the following table:
Characters Value code
BFPV 1
CGJKQSXZ 2
DT 3
L 4
MN 5
R 6
All characters not contained in the above table are ignored. The function is case insensitive and identical
sequences of a character are interpreted as a single instance of the character.
The idea is to provide a crude method of identifying words such as surnames even if they are not spelt correctly.
The function is not foolproof by any means and should not be the sole method of identifying a word.
Examples
INPUT Surname
Surname = SOUNDEX(Surname)
.....search the data bases
SPACE( )
The SPACE function is a convenient way to generate a specific number of ASCII space characters.
Command Syntax
SPACE(expression)
Syntax Elements
Expression should evaluate to a positive integer value.
Notes
The SPACE function will return the specified number of ASCII space characters and is useful for padding
strings. It should not be used to position output on the terminal screen however as this is inefficient and should
be accomplished using the @( ) function.
Examples
TenSpaces = SPACE(10)
SQRT
The SQRT function returns the mathematical square root of a value.
Syntax Elements
The expression should evaluate to a positive numeric value as the authors do not want to introduce a complex
number type within the language. Negative values will cause a math error.
Notes
The function calculates the result at the highest precision available and then truncates the answer to the required
PRECISION.
Examples
FOR I = 1 TO 1000000
J=SQRT(I)
NEXT I
STOP
The STOP statement is virtually identical in function to the ABORT statement except that the calling jCL
program will not be terminated.
STR( )
The STR function allows the duplication of a string a number of times.
Command Syntax
STR(expression1, expression2)
Syntax Elements
Expression1 will evaluate to the string to duplicate and may be of any length.
Expression2 should evaluate to a numeric integer, which specifies the number of times the string will be
duplicated.
Examples
LongString = STR("long string ", 999)
SUBROUTINE
The SUBROUTINE statement is used at the start of any program that will be called externally by the CALL
statement. It also declares any parameters to the compiler.
Command Syntax
SUB{ROUTINE} Name {({MAT} variable{,{MAT} variable...})}
Syntax Elements
Name is the identifier by which the subroutine will be known to the compilation process. It should always be
present as this name (not the source file name), will be used to call it by. However, if the name is left out, the
compiler will name subroutine as the source file name (without suffixes). Default naming is not encouraged as it
can cause problems if source files are renamed.
Each comma separated variable in the optional parenthesised list is used to identify parameters to the compiler.
These variables will be assigned the values passed to the subroutine by a CALL statement.
Examples
SUBROUTINE DialUp(Number, MAT Results)
DIM Results(8)
....
SYSTEM
The SYSTEM function allows the program to determine the state of many system level variables and functions
by a numeric index.
Command Syntax
SYSTEM(expression)
Syntax Elements
Expression should evaluate to one of the integer numbers defined below.
Notes
The SYSTEM() function will return the following information according to the numeric index:
Index Description
0 Return the last tape or file error number as defined by the error message file.
1 Returns 1 if output is being sent to the printer, 0 if it is not.
2 Returns the current page width taken either from the terminfo database, the environment
variable JBCSCREEN_WIDTH or JBCPRINTER_WIDTH.
3 Returns the current page width taken either from the terminfo database or from the
environment variable JBCSCREEN_LENGTH or JBCPRINTER_LENGTH.
4 Returns the number of lines remaining in the current formatted page. Only effective
when a HEADING or FOOTING statement is in force.
5 Returns the current page number of formatted output. Only effective when a HEADING
or FOOTING statement is in force.
6 Returns the current line counter in the current formatted output. Only effective when a
HEADING or FOOTING statement is in force.
7 Returns the terminal type as defined by the environment variable TERM. If the
environment variable JBCTERM_TYPE is defined then the value of this variable will
be returned instead.
8 Returns the record length for tape channel 0. The IOCTL() statement can be used to
determine record lengths for other channels.
9 Returns the CPU millisecond count used by both the current process and any child
processes.
10 Returns 1 if keyboard input is actually being read from a previously stacked data or a
UNIX pipe, rather than from the keyboard.
13 On some systems this will force a release of the time slice quantum. This is neither
necessary nor desirable within jBASE. This function will return 1 if the JBCEMULATE
variable is set to ROS or 0 otherwise.
14 Returns the number of characters currently buffered in the output buffer.
15 Returns the string of command line options used to invoke this command. I.e. all the
options following ( in the command line.
16 Returns the level of nesting (EXECUTE/PERFORM) level of the current process.
17 If the program has EXECUTEd a daughter process then this index will return the STOP
code of the daughter process. The function will return a null string if there have been no
daughter processes spawned by this process.
18 Returns the port number of the current process. This index will return a number defined
by the UNIX environment unless the environment variable JBCPORTNO is defined, in
and which case the value of this variable is returned. It is recommended that the
101 JBCPORTNO variable is determined at login time by the .profile script.
19 Returns the login account name for the current process. This will normally be the UNIX
user login name (env LOGNAME) unless the environment variable JBCLOGNAME has
been defined, in which case the value of this variable will be returned.
23 Returns 1 if the BREAK key (stty intr) is enabled or 0 if it is not.
24 Returns 1 if character echoing is enabled (stty echo) or 0 if it is not (stty -echo).
25 Returns 1 if the current process is running in the background or as a jBTP job.
26 Returns the current prompt string defined by the PROMPT statement.
40 Returns the name of the current program.
100 Returns the version string compiled into the program by jBASE.
101 See SYSTEM(18).
1000 Returns the command line string with each component separated by a field mark. The
invocation option string (characters following the '(') is not returned.
1001 Returns the command line string as SYSTEM(1000) but includes the invocation option
string.
1002 Returns the name of the temporary scratch file currently used by the program (may not
be useful outside jBASE system programs).
1003 Returns the entire binary information provided by the terminfo database for the
currently defined terminal type.
1004 Returns the terminfo NUMBERS information for the currently defined terminal.
1005 Returns the terminfo STRING information.
1006 Returns the time of the last login for this user.
1007 Returns the current time in UNIX format.
1008 Returns the name of the SYSTEM file if it has been defined using the
JEDIFILENAME_SYSTEM environment variable.
Index Description
1009 Returns the name of the MD file if it has been defined using the JEDIFILENAME_MD
environment variable.
Examples
024 PortNo = SYSTEM(18) ;* Get Port number
025 READ Control FROM CFile, "CTL*":PortNo
TAN( )
The TAN function returns the mathematical tangent of an angle.
Command Syntax
TAN(expression)
Syntax Elements
Expression should evaluate to a numeric type.
Notes
The function calculates the result at the highest precision available on the host system. The result is truncated to
the current PRECISION after calculation.
Examples
Adjacent = 42
Angle = 34
CRT "Opposite length = ":TAN(Angle)*Adjacent
TIME( )
The TIME() function returns the current system time.
Command Syntax
TIME()
Notes
The time is returned as the number of seconds past midnight
Examples
CRT "Time is ":OCONV(TIME(), "MTS")
TIMEDATE( )
The TIMEDATE() function returns the current time and date as a printable string.
Command Syntax
TIMEDATE()
Examples
CRT "The time and date is ":TIMEDATE()
TRANSABORT
TRANSABORT is used to abort the current transaction and reverse any updates to the database.
Command Syntax
TRANSABORT {abort-text} [THEN statement | ELSE statement]
Syntax Elements
abort-text specifies an optional variable or quoted literal text string which is to be saved with the transaction
abort record.
Notes
A THEN or ELSE (or both) statement is required. The THEN clause will be executed if the transaction is
successfully aborted. The ELSE clause will be executed if the transaction abort fails for any reason.
Any record locks set during the transaction will be released upon successful completion.
TRANSEND
TRANSEND is used to mark the end of a successfully completed transaction.
Command Syntax
TRANSEND {end-text} [THEN statement | ELSE statement]
Syntax Elements
end-text specifies an optional variable or quoted literal text string which is to be saved with the transaction end
record.
Notes
A THEN or ELSE (or both) statement is required. The THEN clause will be executed if the transaction is
successfully ended. The ELSE clause will be executed if the transaction end fails for any reason.
Any record locks set during the transaction will be released upon successful completion.
TRANSQUERY
TRANSQUERY is used to detect whether or not a transaction is active in the current process.
Command Syntax
TRANSQUERY()
Notes
TRANSQUERY will return 1 (true) if the process is within a transaction boundary, or 0 (false) if it is not. In
other words, TRANSQUERY will return 1 (true) if a TRANSTART has been issued but a TRANSEND or
TRANSABORT has not yet been processed.
Command Syntax
TRANSTART {start-text} [THEN statement | ELSE statement]
Syntax Elements
start-text specifies an optional variable or quoted literal text string which is to be saved with the transaction start
record.
Notes
A THEN or ELSE (or both) statement is required. The THEN clause will be executed if the transaction is
successfully started. The ELSE clause will be executed if the transaction start fails for any reason.
Record locks set during the transaction will not be released until a TRANSEND or TRANSABORT statement is
processed.
A program (or series of programs) can only have one active transaction at one time. If another TRANSTART
statement is encountered whilst a transaction is active, a run-time error will be generated.
TRIM( )
The TRIM statement allows characters to be removed from a string in a number of ways.
Command Syntax
TRIM(expression1 {, expression2{, expression3}})
Syntax Elements
Expression1 specifies the string from which to trim characters.
Expression2 may optionally specify the character to remove from the string. If not specified then the space
character is assumed.
Expression3 evaluates to a single character specifies the type of trim to perform.
Notes
The trim types available for expression3 are as follows:
Type Operation
L Removes leading characters only.
T Removes trailing characters only.
B Removes leading and trailing characters.
A Removes all occurrences of the character.
R Removes leading, trailing and redundant characters.
F Removes leading spaces and tabs.
E Removes trailing spaces and tabs.
D Leading, trailing and redundant spaces and tabs.
Examples
INPUT Answer
* Remove spaces and tabs (second parameter ignored)
Answer = TRIM(Answer, "", "D")
INPUT Joker
TRIMB( )
The TRIMB() function is equivalent to TRIM(expression, " ", "T")
TRIMF( )
The TRIMF() function is equivalent to TRIM(expression, " ", "L")
UNASSIGNED
The UNASSIGNED() function allows a program to determine whether a variable has been assigned a value or
not.
Command Syntax
UNASSIGNED(variable)
Syntax Elements
Variable is the name of variable used elsewhere in the program.
Notes
The function returns Boolean TRUE if variable has not yet been assigned a value. The function returns Boolean
FALSE if variable has already been assigned a value.
See also: ASSIGNED
Examples
IF UNASSIGNED(Var1) THEN
Var1 = "Assigned now!"
END
UNLOCK
The UNLOCK statement releases a previously LOCKed execution lock.
Command Syntax
UNLOCK {expression}
Syntax Elements
If expression is specified it should evaluate to the number of a held execution lock, which will then be released.
If expression is omitted then all execution locks held by the current program will be released.
Notes
No action is taken if the program attempts release an execution lock that it had not taken.
Examples
LOCK 23 ; LOCK 32
......
UNLOCK
WEOF
The WEOF statement allows the program to write an EOF mark on an attached tape device.
Syntax Elements
Expression specifies the device channel to use. Should evaluate to a numeric integer argument in the range 0-9.
Default value is 0.
Notes
If the WEOF fails then the statements associated with any ELSE clause will be executed. SYSTEM(0) will
return the reason for the failure as follows:
Value Meaning
1 There is no media attached to the channel
2 End of media found
Notes
A "tape" does not refer to magnetic tape devices only but any device that has been described to jBASE. Writing
device descriptors for jBASE is beyond the scope of this manual.
If no tape device has been assigned to the channel specified then the jBASE debugger is entered with an
appropriate message.
Examples
WEOF ON 5 ELSE
CRT "No tape device exists for channel 5"
END
WRITE
The WRITE statement allows a program to write a record into a previously opened file.
Command Syntax
WRITE variable1 ON {variable2,} expression {SETTING setvar} {ON ERROR statements}
Syntax Elements
Variable1 is the identifier containing the record to write.
Variable2, if specified, should be a jBC variable that has previously been opened to a file using the OPEN
statement. If variable2 is not specified then the default file is assumed (see OPEN statement).
The expression should evaluate to a valid record key for the file.
If the SETTING clause is specified and the write fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
If a lock was being held on the record by this process it will be released by the WRITE.
If you wish to retain a lock on a record you should do so explicitly with the WRITEU statement.
Examples
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
WRITE Rec ON DCusts, "Xref" ON ERROR
WRITELIST
WRITELIST allows the program to store a list held in a jBC variable to the global list file.
Command Syntax
WRITELIST variable ON expression {SETTING setvar} {ON ERROR statements}
Syntax Elements
Variable is the variable in which the list is held.
Expression should evaluate to the required list name. If expression is null, the list will be written to the default
external list.
If the SETTING clause is specified and the write fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
See also: READLIST
Examples
* Create the list first
WRITELIST MyList ON "MyList"
WRITET
The WRITET statement enables data to be written to a range of tape devices between 0-9.
Command Syntax
WRITET variable {ON expression} THEN|ELSE statements
Syntax Elements
Variable is the variable that holds the data for writing to the tape device. Expression should evaluate to an
integer value in the range 0-9 and specifies which tape channel to read data from. If the ON clause is not
specified the WRITET will assume channel 0.
If the WRITET fails then the statements associated with any ELSE clause will be executed. SYSTEM(0) will
return the reason for the failure as follows:
Value Meaning
1 There is no media attached to the channel
2 End of media found
Notes
A "tape" does not refer to magnetic tape devices only but any device that has been described to jBASE. Writing
device descriptors for jBASE is beyond the scope of this manual.
If no tape device has been assigned to the channel specified then the jBASE debugger is entered with an
appropriate message.
Where possible the record size is not limited to a single tape block and the entire record will be written blocked
to whatever block size has been allocated by the T-ATT command. However certain devices do not allow
jBASE to accomplish this (SCSI tape devices for instance).
WRITEU
The WRITEU statement allows a program to write a record into a previously opened file. An existing record
lock will be preserved.
Command Syntax
WRITEU variable1 ON {variable2,} expression {SETTING setvar} {ON ERROR statements}
Syntax Elements
Variable1 is the identifier holding the record to be written.
Variable2, if specified, should be a jBC variable that has previously been opened to a file using the OPEN
statement. If variable2 is not specified then the default file is assumed (see OPEN statement).
The expression should evaluate to a valid record key for the file.
If the SETTING clause is specified and the write fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Notes
If the statement fails to write the record then any statements associated with the ON ERROR clause are
executed.
The lock maintained by the WRITEU statement will be released by any of the following events:
The record is written to by the same program with WRITE, WRITEV or MATWRITE statements.
The record lock is released explicitly using the RELEASE statement.
The program stops normally or abnormally.
See also: READU, MATREADU, RELEASE
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
WRITEU Rec FROM DCusts, "Xref" Setting Err ON ERROR
CRT I/O Error[:Err:]
ABORT
END
WRITEV
The WRITEV statement allows a program to write a specific field of a record in a previously opened file.
Command Syntax
WRITEV variable1 FROM {variable2,} expression1, expression2 {SETTING setvar} {ON ERROR
statements}
Notes
The WRITEV statement will cause any lock held on the record by this program to be released.
If you wish to retain a lock on the record you should do so explicitly with the WRITEVU statement.
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
WRITEV Rec FROM DCusts, "Xref",7 Setting Err ON ERROR
CRT I/O Error[:Err:]
ABORT
END
WRITEVU
The WRITEVU statement allows a program to write a specific field on a record in a previously opened file. An
existing record lock will be preserved.
Command Syntax
WRITEVU variable1 ON {variable2,} expression1, expression2 {SETTING setvar} {ON ERROR
statements}
Syntax Elements
Variable1 is the identifier holding the record to be written.
Variable2, if specified, should be a jBC variable that has previously been opened to a file using the OPEN
statement. If variable2 is not specified then the default file is assumed (see OPEN statement).
Expression1 should evaluate to a valid record key for the file.
Expression2 should evaluate to a positive integer number. If the number is greater than the number of fields in
the record, null fields will be added to variable1. If Expression2 evaluates to a non-numeric argument, a run time
error will be generated.
If the SETTING clause is specified and the write fails, setvar will be set to one of the following values:
128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error
Examples
OPEN "Customers" ELSE ABORT 201, "Customers"
OPEN "DICT Customers" TO DCusts ELSE
ABORT 201, "DICT Customers"
END
WRITEVU Rec ON DCusts, "Xref",1 SETTING Err ON ERROR
CRT I/O Error[:Err:]
ABORT
END
XTD( )
The XTD() function converts hexadecimal number into its decimal equivalent.
Command Syntax
XTD(expression)
Syntax Elements
Expression should evaluate to a valid hexadecimal string.
Notes
The conversion process will halt at the first character that is not a valid base 16 character in the set [0-9, A-F or
a-f].
Examples
A = "FF"
CRT XTD(A)
will print 255 to the terminal.
Labels
Labels appear at the start of a line and are always numeric (1, 330, 1000, etc.). You should always put at least
one space between the label and the statement.
Grouping Commands
You can place more than one command on a line by separating each command with a subvalue mark character
(x'FC' - entered by typing <CTRL \>). The commands will be executed sequentially, left to right.
Some commands cannot be grouped on the same line because they require one or more dedicated lines in the
program. These commands are:
() [] B BO F F;
FB F-CLEAR F-FREE F-KLOSE F-OPEN F-READ
F-UREAD F-WRITE GOSUB H IBH IH
MVA MVD O P RI RO
RSUB RTN U X
Lines which are a continuation of a T or L command from a previous line are also not suitable for grouping.
The M (Mark) command can be followed by other commands on the same line, but it must be the first command
on a line. Commands following the M command, on the same line must be separated by a subvalue mark rather
than a space (unlike numeric labels).
Comment Lines
Command line which start with a 'C' or an '*' are treated as comments.
If you include a comment in a multiple command line, anything between the 'C' or '*' and a following a subvalue
mark (or the end of the line) will be ignored.
A label will remain active if the 'C' or '*' is placed after it on the line.
Note that the pointer program and the pointed to program can have the same name.
File Buffers
jCL provides nine file buffers, numbered from 1 to 9. The file buffers are used as the medium for transferring
data from and to files - reading and writing.
You should always open file buffers before you use them for reading or writing. They can also be used as
temporary data storage areas.
The data held in a file buffer (like a database record) is divided into fields which are separated by field marks. If
you refer to a field beyond the last field, the required number of additional fields (with null values) are created.
File buffer references are constructed by specifying an ampersand (&), followed by the file buffer number, a
period (.) and then a numeric value (which might be an indirect reference) to define the field number you want.
For example, if file buffer 4 contains:
000 TEST1
001 ABC
002 DEF
003 GHI
004 JKL
&4.2 refers to the second field in file buffer 4 - in this case DEF, and &4.0 refers to the record key of the record
in file buffer 4 - in this case TEST1.
The record key will be null until you perform a read operation or until you move data into field 0 of the file
buffer.
The FB command provides a special Fast Buffer facility. You can use FB to read a record from a file into the
fast buffer without having to open the file first. There is only one fast buffer. The fields are referred to as &n,
where n is the field number. Any existing data is overwritten each time you use the FB command.
Select Registers
Select registers are used to hold a list of record keys or other multi-valued fields which have been generated by
shell commands that produce lists. These include BSELECT, ESEARCH, FORM-LIST, GET-LIST, QSELECT,
SEARCH, SELECT and SSELECT. Having executed one of these commands, you should use the PQ-SELECT
and PQ-RESELECT jCL commands to load or reset the select registers.
Five select registers (numbered from 1 to 5) are provided. Each can contain a separate list.
The select registers are accessed to by using an exclamation mark (!) followed by the register number - for
example !2. Each time a select register is accessed, the next field is taken from the top of the list.
Buffer References
Buffer reference symbols can be used to make direct or indirect references to the input and output buffers and
the file buffers. You can only make direct references to the select registers.
Four special symbols are used:
% for the primary input buffer.
# for the active output buffer.
& for a file buffer or the 'fast' buffer.
! for a select register.
Referencing the primary input buffer or the active output buffer will not reposition the pointer.
Use the appropriate symbol with a literal value to use direct reference. For example:
% 23 Refers to the 23rd parameter in the primary input buffer.
#4 Refers to the 4th parameter in the current output buffer.
&4.19 Refers to field 19 in file buffer 4.
!3 Refers to the next value in select register 3.
Use a combination of symbols and literal values to create an indirect reference. For example:
% %3 Refers to the %3th parameter in the primary input buffer. If say, %3 contained the value
10, this example would refer to the 10th parameter of the primary input buffer.
&4.%5 Refers to the field in file buffer 4 defined by %5.
Indirect references can only be made to the primary input buffer (%), the active output buffer (#) or a file buffer
(&). If the resulting value is non-numeric, a zero is used. In the case of the file buffer (&), you may only use an
indirect reference to the parameter, not the file buffer number - for example, &5.%3 is legal, &%3.5 is not.
Direct or indirect buffer references can be used with the following jCL commands:
() F-OPEN IBH IFN MVA
[] F-READ IBP IH MVD
F; F-UREAD IF IP RI
F-FREE FB IF (multivalued) L S
F-CLOSE H IF (mask) MV T
Grouping Commands
You can put more than one jCL command on the same line by using a subvalue mark <CTRL \>. For example:
001 PQN
002 10 T "Enter file name :",+
003 IBP %1
004 F-O 1 %1
005 T "Cannot open '", %1, "'..."\ GO 10
006 T "File '", %1, "' opened OK"
In this example, if the file cannot be opened by the F-O command, the line immediately following the command
will be executed (see the F-O command for details). If the file is opened, the next but one line will be executed.
By grouping an error message and a branch on the error line (005), you will avoid the necessity of creating a
separate subroutine to handle the error condition.
Note that you cannot use grouping like this where a command relies on a particular line structure - the F-O
command for example.
You can use a mark with the <CTRL \> but it must be the first jCL command on the line. For example, use:
M \ IBP:%1 \ IF # %1 X
not:
IBP %1 \ M \ IF # %1 X
Readability
To increase readability and make it easier to edit and debug your jCL program, you can indent lines by using
leading blanks.
The incorporation of useful comments, using the C or * commands, will help with the future maintenance of your
programs.
Long Statements
To help with program clarity, you can construct long statements by using several H commands. Make sure there
is a space at the end the first H command or before the second (and subsequent) commands. For example:
001 PQN
002 HGET-LIST listname
003 STON
005 HSORT filename WITH ...
006 H HEADING "..."
007 P
Older systems required you to use a line continuation symbol (two less-than characters <<) if you wanted to put
more than 140 characters into the buffer. Although this functionality is still supported, you do not need to use the
line continuation symbol in jBASE.
Concatenation
Use an asterisk (*) to concatenate (join) a series of values. For example:
001 PQN
002 MV %2 string
003 MV %1 Text *%2* has been concatenated
004 T %1
will display Text string has been concatenated.
Conditional Operations
IF Allows conditional execution of jCL program commands.
IF E Tests for presence of an error condition after processing a shell command.
IFN Performs numeric comparisons and allows conditional execution of jCL program commands.
File Operations
F-CLEAR, F-C Clears the specified file buffer.
F-DELETE, F-D Deletes an record from a file opened by an F-OPEN command.
F-FREE, F-F Releases an record lock set by the F-UREAD command.
F-KLOSE, F-K Closes the specified file buffer.
F-OPEN, F-O Clears and opens a file buffer to allow reads and writes.
F-READ, F-R Reads a record from a file into a file buffer.
F-UREAD, F-UR Reads a record from a file into a file buffer and locks the record.
F-WRITE, F-W Writes the contents of the specified file buffer to a file.
FB Reads an record into a special 'fast buffer' without first opening the file.
Arithmetic Operators
+ Adds an integer to the current parameter in the active input buffer.
- Subtracts an integer from the current parameter in the active input buffer.
F; Performs arithmetic functions on constants and buffer parameters.
Processing
P Executes the shell command in the primary output buffer.
PU Executes the UNIX command in the primary output buffer, using the UNIX shell.
Exiting
() Terminates the current jCL program and begins execution of another jCL program.
X Halts execution of a jCL program and returns control to the shell.
Syntax Elements
DICT specifies the dictionary section of file-name, if required.
file-name is the name of the file that contains the jCL program to be executed. Can be a literal, or a direct or
indirect reference to a buffer or select register.
data-section-name specifies an alternative data section of the file. Can be a literal, or a direct or indirect
reference to a buffer or select register.
key is the name of the jCL program to be executed. Can be a literal, or a direct or indirect reference to a buffer or
select register. If key is not specified, the current parameter in the active input buffer will be used.
label specifies a label in the target jCL program from which to start execution.
Notes
The ( ) command terminates the current jCL program and begins execution of another jCL program, of the same
type.
The input buffers, output buffers, and file buffers are all passed to the second program, and all open files stay
open.
The ( ) command is often used in the MD to point to another jCL program which contains the main body of
code. See example 1.
The ( ) command can also be used to divide large jCL programs into smaller units, minimising the search time
for labels.
Using the ( ) command (or the [ ] command), will ensure that the contents of all buffers are available to the target
program. If this is not a consideration, you can execute another jCL program with the P command (see later).
Example 1
MENU
001 PQN
002 (JCL MENU2)
Immediately executes another jCL program called MENU2 in the file called JCL.
Example 2
MENU
001 PQN
002 (JCLFILE)
When the word MENU is entered from the shell, it will be placed in parameter 1 of the primary input buffer -
%1. The program will then unconditionally pass control to the MENU program in file JCLFILE.
Example 3
DOIT
001 PQ
002 IP?
003 (JCL)
Example 4
MENU
001 PQN
002 (JCL MENU2) 300
Immediately executes another jCL program called MENU2 in the file called JCL. Execution of MENU2 will
begin at label 300.
[]
Calls another jCL program as an external subroutine.
Syntax
[{DICT} file-name{, data-section-name} {key}] {label}
Syntax Elements
DICT specifies the dictionary level of file-name, if required.
file-name is the name of the file that contains the jCL program subroutine. Can be a literal, or a direct or indirect
reference to a buffer or select register.
data-section-name specifies an alternative data section of the file (default is the same name as the dictionary).
Can be a literal, or a direct or indirect reference to a buffer or select register.
key is the name of the jCL program to be executed. Can be a literal, or a direct or indirect reference to a buffer or
select register. If key is not specified, the current parameter in the active input buffer will be used.
label specifies a label in the target jCL program from which to start execution. Use of the label clause makes this
command synonymous with the GOSUB command.
Notes
Input buffers, output buffers, and file buffers are all passed through to the called program, and all open files stay
open.
External subroutines can call other subroutines. There is no limit to the number of calls that you can make but
the jCL programs must be of the same type.
When an RTN is encountered, control is returned to the calling jCL program. If an RTN is not encountered,
execution will terminate at the end of the called program.
Example
001 PQN
002 [SUBS SUB1]
003 ...
Calls the jCL program SUB1 in the SUBS file as an external subroutine.
+
Adds an integer value to the current parameter in the active input buffer.
Syntax
+n
Syntax Elements
n is the integer to be added.
Example 1
Command PIB Before PIB After
+30 AAA^+20^333 AAA^050^333
Example 2
Command PIB Before PIB After
+100 BBB^AA^44 BBB^100^44
Example 3
Command PIB Before PIB After
+51 ABC^0000^55 ABC^0051^55
-
Subtracts an integer from the current parameter in the active input buffer.
Syntax
-n
Syntax Elements
n is the integer to be subtracted.
Notes
If the number of characters within a parameter decreases with a - command, the result is prefixed with zeros to
maintain the same number of characters as the original value.
Parameters within the input buffer can be preceded by a minus sign.
If the buffer pointer is at the end of the buffer, a new parameter will be created.
If the referenced parameter is non-numeric, a zero is used.
Example 1
Command PIB Before PIB After
-300 AAA^345^666 AAA^045^666
Example 2
Command PIB Before PIB After
-20 AAA^ABC^666 AAA^-20^666
Example 3
Command PIB Before PIB After
Example 4
001 PQN
002 OEnter a number+
003 S5
004 IBP
005 +7
006 T %5
007 -3
008 T %5
009 RTN
This example receives input from the terminal and places it in the 5th parameter of the primary input buffer. It
adds 7 to the value stored in the 5th parameter and displays the result. It then subtracts 3 from the result and
displays the new value.
A
Copies a parameter from the active input buffer to the active output buffer.
Syntax
A{c|\}{p}
A{c|\}{p}({n},m)
Syntax Elements
c specifies a character to surround the string being copied. Can be any non-numeric character except left
parenthesis ( or backslash \.
\ specifies that the value is to be concatenated with the current parameter in the active output buffer.
p specifies the number of the parameter to be copied. If p is not specified, the current parameter will be copied.
n specifies the starting column in the PIB. Copying continues until the end of the parameter is reached or the
number of characters specified by m have been copied.
Notes
Used on its own, the A command will copy the parameter pointed to from the active input buffer to the active
output buffer.
The A command can also be used with the IF command.
If the active input buffer pointer is at the end of the buffer, the A command will have no effect.
The c option is often used when you need to surround keys with single quotes, or values with double quotes.
If you include an n or m specification, the PIB will be selected. If the destination is the SOB (stack is on), c
will be ignored.
If the stack is "off" (the POB is active), the A command will put the data in the output buffer as a separate
parameter. The buffer pointers in the primary output buffer will be positioned at the field mark at the end of the
copied parameter.
If the stack is "on" (the SOB is active), the A command will concatenate the value to the previous parameter in
the output buffer. It will continue to copy until a field mark is encountered. When complete, the buffer pointers
will be positioned at the end of the secondary output buffer.
Example 1
Command PIB Before PIB After
A AAA^SALES^JAN AAA^SALES^JAN
Note the position of the buffer pointer after you issue the A command.
Example 2
Command PIB Before PIB After
A AAA^SALES^JAN AAA^SALES^JAN
Issuing an A3 command would have achieved the same result, except that the starting position of the PIB
pointer would have been immaterial.
Example 3
Command PIB Before PIB After
A\ ABC^DEF^GHI ABC^DEF^GHI
Example 4
Command PIB Before PIB After
A2(2,-2) ABC^MYLIST^JKL ABC^MYLIST^JKL
The command attempts to copy the second parameter from the PIB, starting with the second character, up to and
including, the penultimate character, to the current output buffer.
B
Moves the active input buffer pointer back to the previous parameter.
Syntax
B
Notes
The input buffer pointer is moved backwards to the preceding field mark or to the beginning of the input buffer.
If the pointer is on the first character of a parameter (or a field marker), the pointer will be moved back to the
field mark of the previous parameter.
Example 1
Command PIB Before PIB After
B ABC^DEF^GHIJK ABC^DEF^GHIJK
BO
Moves the active output buffer pointer back by one parameter.
Syntax
BO
Notes
The buffer pointer will move backward until it finds a field mark or the start of the buffer.
To completely clear the buffer, use the RO command. To clear specific parameters, use the MV #n command
Example 1
Command POB Before POB After
BO ABC^DEF^GHIJK ABC^DEF^GHIJK
Example 2
Command SOB Before SOB After
BO SAVE-LIST SAVE-LIST
C
Defines a comment.
Syntax
C
*
Notes
The C command indicates that the following text is a comment. All comments are ignored at run-time. Use
comments to improve the readability of a program or to help when you are debugging.
Typically, the first few lines of a jCL program are used to describe the program, identify the programmer and
record the date it was last modified.
Comments can be used within grouped commands (more than one command on a single line) but make sure that
you only use them where they will not conflict with normal command syntax.
Do not include too many comment lines, they may slow down execution.
Example
001 PQN
002 C This program will...
003 C Created by A. Programmer, dd/mm/yy
004 C Last modified by:...
005 RI
006 RO
007 10 T C, (5, 10), "Password :",+
008 HECHO OFF
009 P
D
Displays the current parameter of the active input buffer or specific parameters from the PIB.
Syntax
D{n}{+}
Syntax Elements
n specifies the number of the PIB parameter to be displayed. If n is set to 0 (zero), all parameters in the primary
input buffer will be displayed.
+ inhibits a NEWLINE at the end of output.
Notes
D with no other qualifiers will display the current parameter of the active input buffer.
The pointer position will not be changed.
Example 1
Command Active Input Buffer Display
D ABC^DEF^GHI DEF
Example 2
Command Primary Input Buffer Display
D3 ABC^DEF^GHI GHI
Example 3
Command Primary Input Buffer Display
D0 ABC^DEF^GHI ABC^DEF^GHI
DE
Displays the current value of LastError.
Syntax
DE
Notes
The DE command is mainly used when debugging your jCL programs.
Example
If LastError contains 404]61^QLNUMSEL, the DE command will display:
404]61^QLNUMSEL
Syntax
DEBUG [ON|OFF]
Notes
When the DEBUG function is turned on, your jCL program will be suspended before each command (line) is
executed. You will see the program name and the next command to be executed, and you will be prompted to
enter one of the following commands:
<RETURN> execute current line
? display list of available commands
e toggle last error display
f toggle file buffer display
h display list of available commands
i toggle input buffer display
n toggle next line display between one and two lines
o toggle output buffer display
q quit (terminate) program
x exit DEBUG function
After each input, the program name and the next line to be executed will be redisplayed, together with any
additional information requested (for example, the content of the input buffers).
F
Moves the active input buffer pointer forward to the next parameter.
Syntax
F
Notes
The input buffer pointer is moved forward to the next field mark, or to the end of the buffer.
Example 1
Command PIB Before PIB After
F ABC^DEF^GHI ABC^DEF^GHI
Example 2
Command PIB Before PIB After
F ABC^DEF^GHI ABC^DEF^GHI
F;
Provides a range of arithmetic functions.
Syntax
F;element{;element}...;?[P|r]
Syntax Elements
element operators or operands - see below.
?P moves the result (top stack entry) into the current parameter of the primary input buffer.
Operators
+ Add last stack entry and penultimate stack entry. Store the result in stack entry 1.
- Subtract last stack entry from penultimate stack entry. Store the result in stack entry 1.
* Multiply the last two stack entries. Store the result in stack entry 1.
/ Divide stack entry 2 by stack entry 1. Store the result in stack entry 1.
R Divide stack entry 2 by stack entry 1. Store the remainder in stack entry 1.
_ (underscore) reverse the last two stack entries.
Operands
r A direct or indirect reference to a buffer or select register value to be put on the stack.
{C}literal Literal value specified by literal.
Notes
The F; command uses a stack processor similar to, the one used by the F; function in jQL.
Commands are processed from left to right.
Each operand pushes a value on to the top of the push-down/pop-up stack.
The result of a calculation can be copied into any buffer with the question mark (?) operator.
Example
Command PIB Before PIB After
F;C100;%2;-;?%3 6^8^999^7^GHI 6^8^92^7^GHI
Stack 100
%2 pushes a value of 8 (the 2nd parameter of the PIB) onto the stack.
Stack 100
8
- subtracts last entry from penultimate entry, and replaces last entry 1 with the result of 92.
Stack 92
?%3 then copies the result to the 3rd parameter of the PIB, replacing the old value.
F-CLEAR
Clears the specified file buffer.
Syntax
F-CLEAR file-buffer
F-C file-buffer
Syntax Elements
file-buffer is the number (1 to 9) of the file buffer to be cleared.
Example
001 PQN
002 F-C 1
003 MV &1.0 Key, Field 1
.
Clear file buffer 1. Set the record key to Key and the first field to Field 1. Functionally equivalent to MV
&1.0 Key, Field1,_. (Note the use of the underscore character as the last character of the command.)
F-DELETE
Deletes a record from a file.
Syntax
F-DELETE file-buffer
F-D file-buffer
Syntax Elements
file-buffer is the number (1 to 9) of the file buffer which is associated with the file containing the record to be
deleted.
Notes
The record specified in field zero (&f.0) of the file buffer will be deleted. If the record does not exist, the
command will have no effect.
The content of the file buffer is not altered.
An outstanding record lock will be released.
The file must have been opened with an F-OPEN command.
Example
001 PQN
002 10 T "File name :",+
003 IBP %1
004 F-O 1 %1
005 T "File '", %1, "' does not exist!"\ GO 10
006 MV &1.0 Key
007 F-D 1
If the file cannot be opened by the F-O command, the line immediately following the command will be executed
(see the F-O command). If the file is opened, Key is moved into field 0 of file buffer 1. F-D 1 then attempts to
delete record Key from the file.
F-FREE
Releases a record lock set by the F-UREAD command.
Syntax
F-FREE {file-buffer {key}}
F-F {file-buffer {key}}
Syntax Elements
file-buffer specifies a file buffer (1 to 9) assigned by an F-OPEN command.
Notes
If file-buffer is not specified, all record locks set by the jCL program on the current port, within the current
context level will be released.
If key is not specified, any outstanding locks for the current file will be released.
Record locks are also released by F-WRITE or F-DELETE commands, and at the end of the jCL program. Use
the LIST-ITEM-LOCKS command to see which records are currently locked.
Example 1
F-FREE
Unlocks all records previously locked by this jCL program.
Example 2
F-FREE 1
Unlocks the record specified by the key in field zero of file buffer 1.
Example 3
F-F 1 Key
Unlocks the record Key in the file associated with file buffer 1.
F-KLOSE
Closes a specified file buffer.
Syntax
F-KLOSE file-buffer
F-K file-buffer
Syntax Elements
file-buffer is the number (1 to 9) of the file buffer to be closed.
Notes
F-KLOSE is normally only used when you have finished working with a remote file and need to close it.
Example
F-K 1
Closes file buffer 1.
F-OPEN
Clears a file buffer and opens a file for reading and writing.
Syntax
F-OPEN file-buffer {DICT} file-name{,data-section-name}
error-cmd-line
F-O file-buffer {DICT} file-name{,data-section-name}
error-cmd-line
Notes
If the file cannot be opened, the line immediately after the F-OPEN command will be executed. If the file is
opened successfully, this line will be ignored.
File buffers are maintained when control is transferred between jCL programs.
The file will remain open until closed (see the F-KLOSE command) or until the end of the program.
Example 1
001 PQN
002 F-OPEN 1 SALES
003 X ERROR: Cant find the Sales File!
004 T C, (5,10), "Welcome to...",+
.
If the SALES file is opened, execution continues with line 004. Otherwise, the program terminates with an
appropriate error message.
F-READ
Reads a record from an open file into a file buffer.
Syntax
F-READ file-buffer key
error-cmd-line
F-R file-buffer key
error-cmd-line
Syntax Elements
file-buffer is the number (1 to 9) of the file buffer with which the file is associated.
key is the key of the record to be read. Can be a literal (not enclosed in quotes), or a direct or indirect reference
to a buffer or select register.
error-cmd-line is the line immediately after the F-READ command. Only executed if the specified record cannot
be read.
Notes
If an associated file has not been opened (see the F-OPEN command), the program will terminate with an error
message.
If the specified record is not on file, the line immediately following the F-READ command will be executed. If
the read is successful, this line will be ignored.
Example
001 PQN
002 F-OPEN 1 SALES
003 X ERROR: Cant find the Sales File!
F-UREAD
Reads and locks a record from an open file into a file buffer.
Syntax
F-UREAD file-buffer key
error-cmd-line
F-UR file-buffer key
error-cmd-line
Syntax Elements
file-buffer is the number (1 to 9) of the file buffer with which the file is associated.
key is the key of the record to be read and locked. Can be a literal (not enclosed in quotes), or a direct or indirect
reference to a buffer or select register.
error-cmd-line is the line immediately after the F-UREAD command. Only executed if the specified record
cannot be read.
Notes
The F-UREAD command is identical to the F-READ command, except that it also locks the record against
access by another process, thus eliminating simultaneous updates.
If you attempt to F-UREAD a record which is already locked, execution will be suspended until the record is
unlocked by the other process.
Record locks are released by F-DELETE, F-WRITE or F-FREE commands, or when the program terminates.
It is good practise to F-UREAD a record before you create it. This will reserve the key in the file and avoid
double updates. Remember though that the command line immediately following the F-UREAD command will
be executed because the record does not exist.
F-WRITE
Writes the contents of a file buffer as a record.
Syntax
F-WRITE file-buffer
F-W file-buffer
Syntax Elements
file-buffer is the number (1 to 9) of the file buffer with which the target file is associated.
Notes
The key of the record is contained in field zero of the file buffer. If this field is null, the record will not be
written.
Example
001 PQN
002 F-OPEN 1 SALES
003 X ERROR: Cant find the Sales File!
004 T C, (5, 10), "Welcome to...",+
.
015 F-UREAD 1 ABC
016 F-F 1 \ G 1002
017 T Record ABC found
018 MV &1.2 Field 2
019 F-WRITE 1
.
Line 15 reads and locks record ABC in file SALES. If the record does not exist, the lock is released on line 16
and control is transferred to label 1002. If the record is read successfully, field 2 is overwritten on line 18. The
record is then written back to the file on line 19 and unlocked.
FB
Reads a record from a file into the special "fast" buffer without having to open the file first.
Syntax
FB {DICT} file-name{,data-section-name} {key}
error-cmd-line
FB ({DICT} file-name{,data-section-name} {key})
error-cmd-line
Syntax Elements
DICT specifies the dictionary section of file-name, if required.
file-name is the name of the file to be opened. Can be a literal (not enclosed in quotes), or a direct or indirect
reference to a buffer or select register.
data-section-name specifies an alternative data section of file-name.
key is the key of the record to be read. Can be a literal (not enclosed in quotes), or a direct or indirect reference
to a buffer or select register. If key is not specified, the value at the active input buffer pointer is used to supply
the key.
error-cmd-line is the line immediately after the FB command. Only executed if the specified file cannot be
opened or the record read.
Notes
Each time you use the FB command, the previous contents of the buffer will be overwritten.
The FB command is useful if you are only reading one record from a file. Otherwise, you should use the F-
OPEN and F-READ commands.
If the specified record is not on file, or if the file does not exist, the line immediately following the FB command
will be executed. If the read is successful, this line will be ignored.
Subsequent references to the fast buffer use a special syntax. For example, to refer to the second field of a record
in the fast buffer, you would use &2.
Example 2
001 PQN
002 T C, (5, 10), "Name :",+
003 IP %2
004 FB SALES %2
005 T "New record"
006 T "Area :",+
007 IP %3
.
Here the user is prompted for a name (the record key) and the fast buffer is used to read the record from the
SALES file. If the record does not exist, a message is output but processing continues.
G, GO or GOTO
Transfers control unconditionally to another location in the program.
Syntax
G label
GO label
GOTO label
GO label] label... (Multivalued form used with multivalued IF command)
Syntax Elements
label specifies the location from which execution is to continue.
Notes
If the label has not already been encountered in the program, GOTO will search for the label, from the current
position. The target label must be found at the beginning of a command line, separated from the command by at
least one space.
If the label cannot be found, or is defined more than once, the program will terminate with an error message.
Multivalued Form
To use the multivalued form of the GO command, you must specify one label for each result of a multiple
comparison. For example:
IF %2 = A]B]C]D GO 10]20]30]40
Separate the test values and the destination labels with value marks <CTRL ]>.
Note that this is a special case of the GO command. If you need to mix command types in the resulting actions,
you should not use this form of the GO command. You can still achieve the same effect but each value must
contain a separate command. For example:
IF %2 = A]B]C] GO 10]GO 20]GO 30]XFinished
In this case, if the result of the test for null is true the program will terminate with a suitable message.
Example 2
022 5 T "Option :",+
023 IP %1
024 IF %1 = A]B]C GO 10]20]30
025 GOTO 5
.
This example transfers control to label 10 if A is entered, to label 20 if B is entered and to label 30 if C is
entered. If the response is not recognised, control transfers back to label 5.
GO B
Transfers control to the statement following the most recent M (mark) command executed.
Syntax
GB
GO B
GOTO B
Notes
GO B goes back to the last executed M, no matter where it is located in the program.
If a 'mark' has not previously been executed, the program will terminate with an error message:
Cant find mark at line n in programname
Example 1
001 PQN
.
010 MV #1 "SSELECT SALES BY MONTH"
011 STON
012 MV #1 "PQ-SELECT 1"
013 P
014 M
015 MV %1 !1
016 IF # %1 GO F
017 C Process the record
.
025 GO B
026 M
Lines 10 to 13 create a sorted list of the records in the SALES file. After each record is processed, the GO B
command on line 25 returns control to the M command on line 14. When the end of the list is reached, the IF
command on line 16 transfers control to the M command on line 26.
GO F
Transfers control to the statement containing the next M (mark) command.
Syntax
GF
GO F
GOTO F
Notes
The program is scanned forward from the current line, until the next M command is found. Program execution
then jumps to that line.
If an M command cannot be found, the jCL program will terminate with an error message:
Cant find mark at line n in programname
Example
001 PQN
.
005 GO F
006 10 MV %1 ABC
007 MV %6 DEF
008 MV %10 HIJ
009 M
.
The GO F command on line 5 causes the program to be scanned from line 6, looking for the next M command.
In this case, control will be transferred to line 9.
GOSUB
Transfers control to a specific subroutine.
Syntax Elements
label specifies the label which marks the required subroutine.
Notes
When an RSUB statement is encountered, control is transferred back to the line immediately following the
calling GOSUB.
See also [ ] {n} command.
Multivalued Form
To use the multivalued form of the GOSUB command, you must specify one label for each result of a multiple
comparison. For example:
IF %2 = A]B]C]D GOSUB 1000]2000]3000]4000
Separate the test values and the destination labels with value marks <CTRL ]>.
Note that this is a special case of the GOSUB command. If you need to mix command types in the resulting
actions, you should not use this form of the GOSUB command. You can still achieve the same effect but each
result must contain a separate command. For example:
IF %2 = A]B] GOSUB 1000]GOSUB 2000]XFinished
In this case, if the result of the test for null is true the program will terminate with a suitable message.
Example
010 GOSUB 1000
011 T Returned from GOSUB
.
031 1000 T In subroutine
032 IP %1
033 RSUB
The GOSUB command on line 10 transfers control to label 1000 on line 31. When the RSUB on line 33 is
processed, control returns to line 11.
H
Places a text string in the active output buffer.
Syntax
Htext-string
Syntax Elements
text-string is the text to be placed in the active output buffer. Can be a literal (not enclosed in quotes), or a direct
or indirect reference to a buffer or select register.
Notes
The H command is used to place a text string in the currently active output buffer. Use the POB, to create a shell
command. Use the SOB to create secondary commands (such as PQ-SELECT) or to stack a series of inputs
required by the active process.
The string is moved into the buffer starting at the current location of the buffer pointer. At the end of the
operation, the buffer pointer will be positioned immediately after the last character in the string.
Example 1
001 PQN
002 HSLEEP 10
003 P
Forces the process to sleep for 10 seconds.
Example 2
Command POB Before POB After
HCOPY COPY
H SALES COPY COPY^SALES
H ABC COPY^SALES COPY^SALES^ABC
H-DEF COPY^SALES^ABC COPY^SALES^ABC-DEF
H (P) COPY^SALES^ABC-DEF COPY ^SALES^ABC-DEF^(P)
Note how COPY and SALES have become separate parameters but ABC and -DEF have been concatenated.
Example 3
001 PQN
002 HGET-LIST LISTA
003 STON
004 HCOPY SALES<
005 H(SALES.HOLD
006 P
IBH
Places text in the active input buffer whilst retaining embedded spaces and applying any required input/output
conversions.
Syntax
IBHtext
IBHreference;input-conversion;
IBHreference:output-conversion:
Notes
The IBH command works in the same way as the IH command except that the string is moved as a single
parameter and all spaces are maintained.
Depending on the position of the buffer pointer, IBH will either replace an existing parameter or adds a new
parameter to the end of the input buffer. The rules are as follows:
If the buffer pointer is at the beginning of an existing parameter, that parameter will be replaced with
the new string.
If the buffer pointer is within an existing parameter, IBH will concatenate the new string (without
inserting a field mark), starting at the current location of the buffer pointer.
If the buffer pointer is at the end of the input buffer, a new parameter will be created and the buffer
pointer will be left pointing to the field mark preceding the new parameter.
In all cases, the position of the buffer pointer will remain unchanged.
Conversions containing colons or semicolons will not work (for example, IBH;G1;1;).
Example 1
Command PIB Before PIB After
IBHDEF GHI ABC^XXX^Z ABC^DEF GHI^Z
Example 2
Command PIB Before PIB After
IBH XX AA^BB^CC^DD AA^BB^CC^DD^ XX
Example 3
File buffer 1 contains:
000 Key
001 9873
Command PIB Before PIB After
IBH&1.1:D2: AA^BB^CC^DD AA^BB^11 JAN 95^DD
IBN
Prompts for input, places the entered data in the secondary input buffer as a single parameter and maintains
embedded spaces. The secondary input buffer becomes as the active input buffer.
Syntax
IBN{c}
Syntax Elements
c is an optional prompt character which, once used, remains in effect until a new IBN, IBP, IN or IP command is
issued. If c is not specified, the prompt character will default to the last prompt character used, or to a colon (:).
Example 1
Input SIB Before SIB After
ABC XXX ABC
Example 2
ABC DEF XXX ABC DEF
Example 3
<RETURN> XXX ^
IBP
Prompts for input from the terminal. Input data is kept as a single parameter and embedded spaces are retained.
Syntax
IBP{c{r}}
Syntax Elements
c is an optional prompt character which, once used, remains in effect until a new IBN, IBP, IN or IP command is
issued. If c is not specified, the prompt character will default to the last prompt character used, or to a colon (:).
r is a direct or indirect reference to a buffer or select register which is to receive the data. If you use a reference,
the prompt character c must be specified.
Notes
The IBP command is similar to the IP command except that the input is placed in the buffer as a single
parameter and embedded spaces are maintained.
If you do not specify a buffer reference, the active input buffer will be used.
The new data will always replace the parameter pointed to by the buffer pointer but the position of the pointer
will not be changed.
If the user responds with RETURN only, a null parameter will be created.
Example 1
Command PIB Before Input PIB After
IBP? AAA^BBB CCC AAA^BBB^CCC
Example 2
Command PIB Before Input PIB After
IBP? AA^BB^CC XX X AA^XX X^CC
Example 4
Command File Buffer 2 Input File Buffer 2
Before After
IBP:&2.2 000 Key BBB 000 Key
001 AAA 001 AAA
002 XXX 002 BBB
003 CCC 003 CCC
Example 5
Command File Buffer 2 Input File Buffer 2
Before <RETURN> After
IBP:&2.2 000 Key 000 Key
001 AAA 001 AAA
002 XXX 002
003 CCC 003 CCC
IF
Allows conditional execution of jCL commands based on the evaluation of an expression, or the presence (or
absence) of a reference.
Syntax
IF{#} reference command
or
IF reference operator expression command
Syntax Elements
# tests for the absence of a value.
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround
character. Using an A command will not move a value but simply provides a reference to the parameter to be
tested.
operator performs a value comparison. Operators are:
= Equal to
# Not equal to
< Less than
> Greater than
[ Less than or equal to
] Greater than or equal to
expression follows the operator and can be one of the following:
A direct or indirect reference to a buffer or select register.
A string. If the string contains embedded spaces or the first character is an exclamation mark (!),
percent sign (%) or ampersand (&), enclose the string in single or double quotes.
A pattern format string. Refer to the IF (with Mask) command.
command is any valid jCL command.
Example 1
021 IF %1 T %1 is not null
022 IF # %1 T %1 is null
023 ...
Line 21 tests for a value in the 1st parameter of the PIB and outputs a message if the parameter is not null. Line
22 tests for opposite case.
Example 2
021 IF &1.1 = ABC GO 10
022 MV %3 &1.1
023 10 ...
If &1.1 contains ABC execution will branch to line 23. Otherwise, the value in &1.1 will be moved into %3.
Example 3
010 T "Continue (Y/n) :",+
011 IP %1
009 S1
012 IF # A G 10
013 IF A(1,1) = Y G 10
014 IF A(1,1) = y G 10
015 XFinished
016 10 ...
If the user enters Y, y or <RETURN> to the prompt on line 11, execution will continue at label 10 on line 16.
Otherwise, the program will terminate.
IF (Multivalued)
Compares an expression with one of several different expressions or values, and conditionally executes one of
several commands.
Syntax
IF reference = expression{]expression}... command{]command]}...
IF reference # expression{]expression}... command.
Syntax Elements
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround
character. Using an A command will not move a value but simply provides a reference to the parameter to be
tested.
expression follows the operator and can be one of the following:
A direct or indirect reference to a buffer or select register.
A string. If the string contains embedded spaces or the first character is an exclamation mark (!),
percent sign (%) or ampersand (&), enclose the string in single or double quotes.
A pattern format string. Refer to the IF (with Mask) command.
Notes
The multivalues feature of the IF command enables one IF statement to be used instead of a series.
Do not use O or X commands unless they are the last in the series. Commands after an O or X will be ignored.
The equal (=) operator, will perform a logical OR on the expressions. If the reference is equal to any expression,
the condition is true. If more than one expression is true, the command corresponding to the first true expression
is executed. If there are more expressions than commands, and the true expression does not have a corresponding
command, the last command in the series will be executed. If there are more commands than expressions,
remaining commands are ignored.
If you use the not equal (#) operator, a logical AND is performed on the expressions. The reference must not
equal any expression in the series for the condition to be true. In this case, the first command specified is
executed. Subsequent commands are ignored.
If a direct or indirect reference to a buffer or select register identifies a multivalued parameter, the same jCL
statement is executed regardless of which of the multivalues is true. This means that each value will not access a
different command - as it would have if you had specified it directly in the IF statement. For example:
MV %1 A]B]C]D
IF %1 = X]Y]Z]C GO 10]20]30]40
will cause program execution to continue from label 40.
Example 1
IF %1 = A]B]C G 10
If %1 is equal to A, B or C, control is transferred to label 10.
Example 2
IF %2 # "AA"]&1.1](2N)]"" GOSUB 1001
If %2 is not equal to AA, the content of &1.1, two numerics or null, control is transferred to subroutine 1001.
Example 3
IF %3 = (0N)]($ON) GO 10]MV #4 "DOLLARS"
If %3 equals a pound sign () followed by any (or no) numerics, control transfers to the statement with label 10.
If %3 equals a dollar sign ($) followed by any (or no) numerics, the string "DOLLARS" is moved into the output
buffer.
IF (with Mask)
Conditionally executes commands based on a comparison with a specified pattern.
Syntax Elements
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround
character. Using an A command will not move a value but simply provides a reference to the parameter to be
tested.
operator performs a value comparison. Operators are:
= Equal to.
# Not equal to.
(pattern) is a format string enclosed in parentheses that tests for a specified numeric, alphanumeric or alphabetic
string. A pattern format string can consist of any combination of the following:
(nA) Tests for n alphabetic characters. If n is 0 (zero), any number (or no) alphabetic characters are
assumed to match.
(nC) Tests for n alphanumeric characters. If n is 0 (zero), any number (or no) alphanumeric
characters are assumed to match.
(nN) Tests for n numeric characters. If n is 0 (zero), any number (or no) numeric characters are
assumed to match.
(nP) Tests for n printable characters. If n is 0 (zero), any number (or no) printable characters are
assumed to match.
(nX) Tests for n characters. If n is 0 (zero), any number (or no) characters are assumed to match.
(string) Tests for one or more specified characters. If string contains numeric characters, %, #, &, !, or
spaces, it must be enclosed in quotes.
For example, the pattern (2N-3A-2N) specifies a format of two numeric characters, a hyphen, three
alphabetic characters, another hyphen and then two numeric characters.
command is a valid jCL command.
Notes
0X can only be used as the last specification in a pattern.
A null value will match any of the defined patterns such as (0A), (0N), or (0X).
If you want to test for spaces in the pattern, use double quotes, for example:
IF %n = (2A" "3N" "0X)
Ambiguous literal strings must be enclosed in quotes.
Example 1
IF %3 = (3N1A) GO 10
If %3 matches three numerics followed by one alphabetic character, branch to label 10.
Example 2
IF &1.2 # (2NAAA) GOSUB 1001
If &1.2 does not equal two numerics followed by AAA, control will be transferred to subroutine 1001.
Example 3
IF %1 # (2N*2A*0N) MV %1 99*AA*1234
If %1 does not equal two numerics, an asterisk, two alphabetics, an asterisk, and a number (or no numerics),
move a string that does into %1.
Example 5
IF &1.1 = ((0X)) GO 100
If &1.1 contains (ABC123), control will not be transferred to label 100.
Example 6
IF &1.1 = ((0X) GO 100
If &1.1 contains (ABC123), control will be transferred to label 100.
IF E
Conditionally executes a command depending on the presence or absence of an error message after running a
shell command.
Syntax
IF {#} E command
IF E operator msg-key command
Syntax Elements
# tests for the absence of an error message.
operator performs a value comparison. Operators are:
= Equal to
# Not equal to.
msg-key is the key of a system message from the ERRMSG file.
command is a valid jCL command.
Notes
Any system messages generated as a result of running a shell command (see the P command) will cause the
system message number to be placed in the SIB, in multivalue format. The value tested is the first multivalue
(the STOP code) of the error text returned from the last command.
The IF E command is most often used to test for an error condition but can be used to detect any resulting
system message. IF # E command tests for the absence of a system message.
Some jCL commands, particularly those that operate on the PIB, will destroy the contents of the secondary input
buffer. You should therefore use the IF E command as soon as control returns from the shell command.
Example
021 HCOUNT SALES WITH VALUE > 1000
022 PH
023 IF E = 401 G 100
If the SALES file does not contain any records which match the criteria, the system will generate the message
No records counted. Using the PH command will stop the message being output on the terminal but the
message key 401 will still be placed in the SIB where it can be detected by line 23.
IF S
Conditionally executes a command depending on the presence or absence of an active select list.
Syntax Elements
# tests for the absence of an active select list.
command is a valid jCL command.
Notes
IF S will execute command if there is an active select list. IF # S will execute command if there is not an active
select list.
Example
021 HSELECT SALES WITH VALUE > 1000
022 PH
023 IF S G 100
If the SELECT command generates an active select list, control will be transferred to label 100.
IFN
Allows conditional execution of commands depending on the result of numeric comparisons.
Syntax
IFN reference operator expression command
Syntax Elements
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround
character. Using an A command will not move a value but simply provides a reference to the parameter to be
tested.
operator performs a value comparison. Operators are:
= Equal to
# Not equal to
< Less than
> Greater than
[ Less than or equal to
] Greater than or equal to
expression can be one of the following:
A direct or indirect reference to a buffer or select register.
A string. If the string contains embedded spaces or the first character is an exclamation mark (!),
percent sign (%) or ampersand (&), enclose the string in single or double quotes.
command is a valid jCL command.
Notes
IFN tests numbers by value, rather than their ASCII sequence of characters.
Leading zeros are ignored, as are trailing decimal zeros. For example, if %1 contains 00123.000, IFN %1 = 123
will be true.
If a submitted value equates to null or is non-numeric, zero will be used. Leading plus or minus signs are
allowed.
Example 2
IFN %1 [ 0 G 100
If %1 is less than or equal to 0, control will be transferred to label 100.
Example 3
IFN A < %3 G 100
If the current parameter is less than %3, control will be transferred to label 100.
IH
Places a text string in the active input buffer, clears an existing parameter, or creates new null parameters.
Syntax
IHtext
IHreference;input-conversion;
IHreference:output-conversion:
IH\
IH \
Syntax Elements
text is the text to be placed in the active input buffer. Can be a literal (not enclosed in quotes), or a direct or
indirect reference to a buffer or select register. The text must not contain subvalue marks.
reference is a direct or indirect reference to a buffer or select register.
input-conversion is a jQL input conversion to be applied to the string before putting it in the buffer.
output-conversion is a jQL output conversion to be applied to the string before putting it in the buffer.
\ (backslash). If there is no preceding space, the current parameter in the active input buffer will be nulled. If
there is a preceding space, a new null parameter will be created at the current buffer pointer position. A
backslash in any other position will be treated as part of the literal text.
Notes
Each group of one or more spaces in the text will be replaced with a single field mark, thereby creating new,
separate parameters to replace the current single parameter. Leading and trailing spaces within text are ignored.
Use the IBH command if you want to insert text into the active input buffer as a single parameter with all blanks
intact.
If the buffer pointer is at the beginning of an existing parameter, that parameter will be replaced by the new text.
If the buffer pointer is in the middle of a parameter, that parameter will be truncated from the current location
and the new parameter (without a leading field mark) will be concatenated.
If the buffer pointer is at the end of the input buffer, one or more new parameters will be created.
The position of the buffer pointer will not be changed.
Example 1
Command PIB Before PIB After
IHXXX AB^CD^YY^ZZ AB^CD^XXX^ZZ
Example 2
Command PIB Before PIB After
IH GH IJ AB^CD^EF AB^CD^EF^GH^IJ
Example 3
%3 contains 9873
Command PIB Before PIB After
IH%3:D2: AB^CD^9873^GH AB^11^JAN^95^9873^GH
Example 4
Command PIB Before PIB After
IH%4 AB^CD^EF^GH IJ^ AB^CD^EF^GH^IJ^
This example demonstrates how, in effect, you can replace a space with a field mark within a parameter. The 4th
parameter of the PIB is copied back into the same location but the space is replaced by a field mark.
Example 5
Command PIB Before PIB After
IH\ AB^CD^EF^GH AB^CD^^GH
Example 6
Command PIB Before PIB After
S(7)
IH\ AB^CDEFGH^IJK AB^CDE^IJK
Example 7
Command PIB Before PIB After
IH \ AB^CD^EF^GH AB^CD^^EF^GH
Example 8
Command PIB Before PIB After
IH \ AB^CDEFGH^IJK AB^CDE^^FGH^IJK
Syntax
IN{c}
Syntax Elements
c is an optional prompt character which, once used, remains in effect until a new IBN, IBP, IN or IP command is
issued. If c is not specified, the prompt character will default to the last prompt character used, or to a colon (:).
Notes
The new data replaces the content of the SIB, and the SIB will remain active until an RI, S(n) or MV %n source
command is used.
Leading and trailing spaces are removed and groups of one or more embedded spaces are replaced by a single
field mark. Use the IBN command if you want to maintain embedded spaces.
If the user responds with RETURN only, a null parameter will be created.
When the command has been completed, the buffer pointer will be positioned at the beginning of the buffer.
Example 1
Input SIB Before SIB After
ABC ABC
Example 2
ABC DEF XYZ ABC^DEF
Example 3
<RETURN> WWW^XXX
IP
Prompts for input and places it into the active input buffer or a nominated buffer.
Syntax
IP{c{r}}
Syntax Elements
c is an optional prompt character which, once used, remains in effect until a new IBN, IBP, IN or IP command is
issued. If c is not specified, the prompt character will default to the last prompt character used, or to a colon (:).
r is a direct or indirect reference to a buffer or select register which is to receive the data. If you use a reference,
the prompt character c must be specified.
Notes
If you do not specify a buffer reference, the active input buffer will be used.
The new data will replace the parameter at the current buffer pointer position but the pointer will not be moved.
Leading and trailing spaces will be removed and groups of one or more embedded spaces will be replaced by a
single field mark. By replacing a parameter with data that contains spaces, you can insert several new
parameters.
Example 1
Command PIB Before Input PIB After
IP? AAA^BBB CCC AAA^BBB^CCC
Example 2
Command PIB Before Input PIB After
IP? AA^BB^CC XX X AA^XX^X^CC
Example 3
Command PIB Before Input PIB After
IP? ABC^DEF^GHI <RETURN> ABC^^GHI
Example 4
Command File Buffer 2 Input File Buffer 2
Before After
IP:&2.2 000 Key BBB 000 Key
001 AAA 001 AAA
002 XXX 002 BBB
003 CCC 003 CCC
Example 5
Command File Buffer 2 Input File Buffer 2
Before BB CC DD After
IP:&2.2 000 Key 000 Key
001 AAA 001 AAA
002 XXX 002 BB
003 DDD 003 CC
004 DD
IT
Reads a tape record into the primary input buffer.
Syntax
IT{C}{A}
Syntax Elements
C performs an EBCDIC to ASCII conversion before the data is put into the buffer.
A masks 8-bit ASCII characters to 7 bits (resets the most significant bit to a 0).
Notes
The IT command will read a tape record into the primary input buffer.
The new data will be placed at the beginning of the buffer and will replace all existing buffer data.
L
Formats printed output.
Syntax
L element{, element}...
Syntax Elements
element can be any of the following:
"text" Prints literal text. Enclose the text in quotes.
r{;input;} Prints the result of a direct or indirect reference to a buffer or select register (r). If required, a
jQL input conversion can be applied before output.
r{:output:} Prints the result of a direct or indirect reference to a buffer or select register (r). If required, a
jQL output conversion can be applied before output.
n Skips n lines before printing. You cannot use n in a HDR print format specification.
(c) Sets the print position to column number c. Can be a direct or indirect reference to a buffer or
select register.
+ Suppresses NEWLINE being output at the end of the L command. You cannot use + in a
HDR print format specification.
C Closes the print file and forces printing. You cannot use C in a HDR print format
specification.
E Ejects to top-of-form (form feed). You cannot use E in a HDR print format specification.
N Redirects subsequent printer output to the terminal. Normally only used for debugging. Must
be the only element in an L command.
HDR Allows you to define a page heading. HDR, must be the first element in the L command.
L Outputs a line feed in the heading. Only used in a HDR specification.
P Outputs the current page number in a heading. Only used in a HDR specification.
T Outputs current time and date in a heading. Only used in a HDR specification.
Z Resets the current page number in a heading to zero. Only used in a HDR specification.
Notes
Output from the L command creates (or adds to) a print file.
The print file will remain open until a shell command is issued by using the P command. If the shell command
also generates print output, this will be added to the same print file. You can close the print file and avoid any
unnecessary output by choosing any shell command which does not generate print output, or by using the L C
command. Alternatively, you can hold the print file open indefinitely by using the O option of the SP-ASSIGN
command (see the jLP chapter of the System Administrators Reference Manual).
Continuation lines (which do not start with an L) can be created by terminating each preceding line with a
comma (,).
A + specified as the last element the command will cause the output from the next L command to be appended.
If you specify a heading statement (HDR) which contains direct or indirect references, these will be evaluated
(and included in the heading) as the command is processed. Subsequent changes to the source values will have
no effect on the heading.
M
Marks a destination for a GO F or GO B command.
Syntax
M
Notes
The M command is used with the GO B and GO F branch commands to mark the destination of the jump.
As a jCL program is executed it remembers the location of the last M command it passes through. When a GO
B command is encountered, the program can then branch straight back to the remembered location. Remember
that an M command must be executed for it to be remembered.
GO F scans forward from the current location until it finds an M command and then resumes execution from
there.
If commands are grouped on a line, the M command must be the first command on the line.
Examples
See the GO B and GO F commands for examples of usage.
MS
Move the entire content of the secondary input buffer to the primary input buffer.
Syntax
MS
Notes
MS copies the entire content of the secondary input buffer and inserts the parameters before the parameter
currently pointed to in the primary input buffer. The primary input buffer must be active when MS is executed.
After the move, the secondary input buffer will be empty.
Hold file numbers are returned as Entry #n, where 'n' is the hold file number.
Example
001 PQN
002 HSP-ASSIGN HS
003 P
004 HCOPY SALES ABC (P
005 P
006 S10
008 MS
MV
Copies data between buffers or between buffers and select registers.
Syntax
MV destination source{,source}...{,*{n}}{,_}
or
MV destination source{*source}...
Syntax Elements
destination is a direct or indirect reference to the destination buffer or select register which is to receive that
data.
source is the data you want to copy. Can be a direct or indirect reference to a buffer or select register, or a literal
string enclosed in single or double quotes.
,* copies all source parameters starting with the specified parameter. If * is the last operand in the source field,
the destination buffer or select register will be truncated after the last copied parameter.
,*n copies the number of source parameters specified by n starting with the specified parameter. The destination
buffer or select register will not be truncated.
,_ specifies that the destination is to be truncated after the source is copied.
*source specifies the source values are to be concatenated into one field in the destination buffer or select
register.
Notes
If the source is a literal string containing just two double quotes, the destination will be nulled.
If the input buffer (%n) is specified as the destination, it will be selected as the active input buffer and the buffer
pointer will left at the beginning of any copied data.
If the field or parameter number in destination is larger than the current number of fields or parameters,
intervening null values will be created automatically.
Specify an asterisk (*) as the last character in the source element if you want to copy all the following source
buffer parameters. For example:
MV &2.2 %1,*
will copy the 1st parameter of the PIB to field 2 of file buffer 2. Parameter 2 of the PIB will be copied to field 3
and so on.
If you want to copy a series of parameters, specify the number of additional parameters to be copied after the
asterisk. For example:
MV &2.2 %1,*3
will copy the 1st, 2nd, 3rd and 4th parameters of the PIB into fields 2, 3, 4 and 5 of file buffer 2. The remainder
of file buffer 2 will not be changed.
If you specify a series of values as the source, each value will copied to successive locations in the destination.
For example:
MV %2 "ABC"*&2.1*!1
will copy ABC into PIB parameter 2, field 1 of file buffer 2 into PIB parameter 3, and the next value from select
register 1 into PIB parameter 4.
Example 1
Command PIB Before PIB After
MV %5 "XXX" ABC ABC^^^^XXX
Example 2
Command PIB Before PIB After
MV %4 %1 ABC^DEF^GHI ABC^DEF^GHI^ABC
Example 3
PIB contains:
QTR^ABC^DEF
Command POB Before POB After
MV #3 %1 SORT^SALES^ SORT^SALES^QTR^
Example 4
Command PIB Before PIB After
MV %1 "AA",,"CC" XX^BB^YY^ZZ AA^BB^CC^ZZ
Example 5
File buffer 2 contains:
000 Key
001 111
002 AAA
003 BBB
Command File Buffer 1 File Buffer 1
Before After
MV &1.1 &2.2,* 000 KEY1 000 KEY1
001 WWW 001 AAA
002 XXX 002 BBB
003 YYY 003 YYY
004 ZZZ 004 ZZZ
Example 6
PIB contains:
ABC^DEF^GHI^JKL^MNO
MVA
Copies a value from the source to the destination buffer and stores it as a multivalue.
Syntax
MVA destination source
Syntax Elements
destination is a direct or indirect reference to a buffer or select register which is to receive the data.
source is the data to be copied. The source can be a direct or indirect reference to a buffer or select register, or a
literal string.
Notes
New values will be copied to the destination in ascending ASCII sequence.
If a new value already exists in the destination buffer, it will not be copied.
If the source data is multivalued, it will be copied to the destination without modification. This might create
duplicate values and invalidate the ascending sequence.
If the destination is the input buffer, the buffer pointer will be left at the beginning of the destination parameter.
Example 1
PIB contains:
ABC^DEF^GHI
Command File Buffer 1 File Buffer 1
Before After
MVA &1.1 %3 000 Key 000 Key
001 FFF]HHH 001 FFF]GHI]HHH
002 YYY 002 YYY
Example 2
File buffer 2 contains:
000 Key
001 GG]YY
002 AAA
Command File Buffer 1 File Buffer 1
Before After
MVA &1.1 &2.1 000 Key 000 Key
001 FFF]HHH 001 FFF]GG]YY]HHH
002 YYY 002 YYY
MVD
Deletes a value from a multivalued parameter in the target buffer.
Syntax
MVD target source
Notes
Values in the target must be in ascending ASCII sequence, otherwise the result of the command will be
unpredictable.
If the source does not exist or if the multivalue cannot be matched, the command will no effect, except perhaps
to move the buffer pointer.
If the source element exists more than once in the target parameter, only the first occurrence will be deleted.
If the target is the primary input buffer, the buffer pointer will be left at the beginning of the specified target
parameter.
Example
Command File Buffer 1 File Buffer 1
Before After
MVD &1.1 DEF 000 Key 000 Key
001 ABC]DEF]GHI 001 ABC]GHI
002 YYY 002 YYY
O
Outputs a text string to the terminal.
Syntax
O{text}{+}
Syntax Elements
text is the text to be displayed.
+ inhibits a NEWLINE at the end of the output and leaves the cursor positioned to the right of the last character
displayed. This is often used when prompting for input.
Notes
The O command has largely been replaced by the T command which also provides cursor positioning and
special display features.
If no text is supplied, a blank line will be output.
Example 1
Command Terminal output
O SALES SYSTEM SALES SYSTEM
O
OEnter Password + Enter Password :
IP:
P
Submits the shell command created in the primary output buffer for execution.
Syntax
P{P}{H}{Ln}{X}{U}{W}
Notes
When the P command is executed, control is passed to the shell and only returns when the shell process has been
completed. After the P command has been executed, both output buffers are cleared and the stack is turned off.
Commands and data in the secondary output buffer are made available to processes which require further input.
If you need to preserve buffer contents when passing control between jCL programs, use the ( ) or [ ] command
instead.
If you use the PP variants (PP, PPH, PPLn), the content of both output buffers will be displayed before they are
executed and you will be prompted with a question mark (?). Enter:
Y to continue.
S to cancel execution but continue the program.
N to cancel execution and exit the program.
Example 1
003 HLIST SALES QTR VALUE
004 P
Copy the jQL command LIST SALES QTR VALUE to the output buffer and execute it.
Example 2
003 HCOPY SALES ABC
004 STON
005 H(SALES.HOLD<
006 PP
Place the COPY command in the primary output buffer. Turn the stack on. Put the response to the TO: prompt
into the secondary input buffer. Issue the PP command to display the contents of the buffers and prompt for input
before continuing.
Example 3
003 Henv | grep EMULATE
006 PU
Issue the UNIX grep command.
RI
Resets (clears) the primary and secondary input buffers.
Syntax
RI
Syntax Elements
p specifies starting parameter from which to clear to the end of the buffer. Can be a number, or a direct or
indirect reference to a buffer or select register.
(n) specifies the starting column from which to clear to the end of the buffer. Can be a number, or a direct or
indirect reference to a buffer or select register.
Notes
The RI command clears the entire PIB and SIB.
RIp clears the PIB starting from parameter p and continuing to the end of the buffer.
RI(n) clears the PIB starting from parameter n and continuing to the end of the buffer.
The buffer pointer will be left at the end of the PIB. The primary input buffer becomes the active buffer and the
secondary input buffer will be cleared.
Example 1
Command PIB Before PIB After
RI ABC^DEF^GHI
Example 2
RI3 ABC^DEF^GHI ABC^DEF
Example 3
RI(6) ABC^DEF^GHI ABC^D
RO
Resets (clears) the active output buffer.
Syntax
RO
Notes
The RO command clears the active output buffer.
The buffer pointer is left at the beginning of the buffer.
Example 1
Command POB Before POB After
STOFF
RO ABC^DEF
Example 1
Command SOB Before SOB After
STON
RO GHI^JKL
Syntax
RSUB {n}
Syntax Elements
n specifies that control should be returned to the n'th statement line after the calling GOSUB. Can be a number,
or a direct or indirect reference to a buffer or select register.
Notes
If n is not specified, control will return to the statement immediately following the calling GOSUB.
An RSUB without a corresponding GOSUB will ignored.
Example 1
010 GOSUB 1001
011 ...
012 ...
.
051 1001 T Press <CR> to continue...,+
052 S10
052 IP?
053 RSUB
The RSUB command on line 53 will return control to line 11.
Example 2
010 GOSUB 1001
011 ...
012 ...
.
051 1001 T Press <CR> to continue...,+
052 S10
052 IP?
053 RSUB 2
The RSUB command on line 53 will return control to line 12.
RTN
Terminates execution of an external subroutine and returns control to a statement following the [ ] command that
called the subroutine.
Syntax
RTN{n}
Syntax Elements
n specifies that control should be returned to the n'th statement line after the calling [ ] command. Can be a
number, or a direct or indirect reference to a buffer or select register.
Notes
If n is not specified, control will return to the statement immediately following the calling [ ] command.
A RTN without a corresponding [ ] command will terminate the program.
Example 2
MENU MENU2
. .
051 [SUBS MENU2] 066 RTN 2
052 ...
053 ...
jCL program MENU calls MENU2 from line 51. When MENU2 reaches line 66, control will be returned to
MENU at line 53.
S
Positions the primary input buffer pointer to a specified parameter or column, and selects the primary input
buffer as active.
Syntax
Sp
S(n)
Syntax Elements
p specifies the parameter to which the buffer pointer should be set. Can be a number, or a direct or indirect
reference to a buffer or select register.
(n) specifies the starting column to which the buffer pointer should be set. Can be a number, or a direct or
indirect reference to a buffer or select register.
Notes
Sp sets the buffer pointer to the field mark preceding parameter p.
If the specified column or parameter number is less than 2, the buffer pointer is placed at the beginning of the
active input buffer.
If the specified column or parameter number is beyond the end of the buffer, the buffer pointer will positioned at
the end of the buffer. Use the MV command to create parameters beyond the current end of the buffer.
All data in the secondary input buffer will be cleared.
Example 1
Command PIB Before PIB After
S3 ABC^DEF^GHI ABC^DEF^GHI
Example 2
Command PIB Before PIB After
S(4) 12345^ABC 12345^ABC
Syntax
STOFF
ST OFF
Notes
The stack can be turned on (STON) or off (STOFF) at any point within a jCL program.
At the start of a jCL program or after execution of an RO or P command, both output buffers will be empty, and
the stack will be off.
When the stack is off, H commands will place their data in the primary output buffer.
STON
Selects the secondary output buffer as the active output buffer.
Syntax
STON
ST ON
Notes
The STON command selects the SOB as the active output buffer. With the stack turned on, all data moved to an
output buffer with an MV, H or A command will be placed in the secondary output buffer.
The stack is often used to feed responses to interactive processes. It can also be used to store a series of
commands that you might need for example when you are dealing with select lists. For example, do a GET-
LIST, followed by a SORT-LIST and then run a jBC program.
Typically, you would create the command necessary to start the external job stream in the primary output buffer.
Next you would turn the stack on and store all the necessary responses (or commands) to the external process.
When you issue the P command to execute the external program, instead of taking its input from the terminal,
the program will be fed directly from the stack.
Terminated successive responses in the stack, with a less-than-character (<) to represent a RETURN key
depression. A single response or the last response in the stack does not require the less than character (<)
because a RETURN is generated by the P command.
Example
Command POB Before POB After
STON COPY^SALES^ABC COPY^SALES^ABC
H(SALES.HOLD<
T
Produces formatted terminal output.
Syntax
T element{, element}
Notes
The T command must be followed by a single space and each element must be separated by a comma.
Continuation lines (which do not start with a T) can be created by ending the preceding line with a comma.
Example 1
Commands Terminal Output
MV %1 99
T C, "%1 = ",%1 clear screen
%1 = 99
Example 2
Commands Terminal Output
T "Enter Password :",+
Example 3
Commands Terminal Output
T *=6 ======
Example 4
Commands Terminal Output
MV %1 9873
T "DATE:",S2,%1:D2: DATE: 11 JAN 95
Example 5
Command: T (0,10),T,(0),"ERROR",B,D,(O),S5,D,L
Terminal Output: ERROR bell (flashing)
Example 6
Commands Terminal Output
T X1B,"J",+ erase to end of screen
or
T I27,I74,+
or
T (-3),+
TR
Traces jCL program execution and displays each command (source line) before it is executed.
Syntax
TR {ON}
TR OFF
Notes
The TR command will help you to test and debug your jCL programs.
TR or TR ON turns the trace on. TR OFF turns the trace off.
You can easily provide a general purpose trace program by creating a jCL program called TRACE in the file
defined by the JEDIFILENAME_MD environment variable. The TRACE program should look like this:
TRACE
001 PQN
002 TR ON
003 (%1 %2)
Run the TRACE program like this:
TRACE jcl_file jcl_program
If the target program relies on the initial content of the PIB, you will have to insert a line into the program like
this:
002 MV %1 %2,*
to move the PIB parameters to their required positions - otherwise the word TRACE will appear in %1 and the
jCL program name (normally in %1) will be in %2.
U
Execute a user exit from a jCL program.
Syntax
Unxxx
Syntax Elements
n represents the user exit entry point
xxx is the id of the user exit.
Notes
User exits are user written functions which are used to manipulate buffers and perform tasks beyond the scope of
the standard jCL commands. For more details, refer to the Advanced Programmers Reference Manual.
See the Time and Date topic earlier in this chapter and the TR command for more examples of standard user
exits.
Example 1
012 U31AD
Returns the current port number.
Example 2
012 U307A
013 300
Causes the process to sleep for 300 seconds.
X
Halts execution of the program and returns control to the shell.
Syntax
X{text}{+}
Syntax Elements
text is any text to be displayed on exit.
+ suppress a NEWLINE at exit or after text output.
Notes
The X command returns control directly to the shell.
Example 1
F-OPEN 1 SALES
XCannot Open SALES file!
The X command stops execution of the program if the file SALES cannot be opened, and displays a suitable
message.
PQ-RESELECT
Executed from a jCL program, resets the pointer of a specified select register to the beginning of the list of
record keys.
Syntax
PQ-RESELECT register-number
Syntax Elements
register-number is the number (1 to 5) of the select register to be reset.
Notes
This command is executed from the primary output buffer to reset the pointer of a specified select register back
to the beginning of the list.
Each time you use the '!' reference to retrieve a value from the list, the value is not destroyed. The pointer is
simply advanced to the next parameter in the list. PQ-RESELECT resets the pointer back to the beginning of the
list so that you can perform another pass.
You cannot execute PQ-RESELECT directly from the shell.
Example
HSELECT SALES
STON
HPQ-SELECT 1
PH
MV %1 !1
IF # %1 XNo records selected
HPQ-RESELECT 1
PH
10 MV %1 !1
IF # %1 XFinished
...
GO 10
PQ-SELECT
Executed from a jCL program, loads a list of keys into a select register.
Syntax
PQ-SELECT register-number
Syntax Elements
register number is the number of the select register (1 to 5) in which the keys are to be placed.
Notes
To use PQ-SELECT you must first construct a list by using one of the list processing commands such as
SELECT, SSELECT, QSELECT, BSELECT, GET-LIST, FORM-LIST, SEARCH or ESEARCH. Put the
PQ-SELECT command in the stack so that it will be processed as part of the external job stream when the
required list is active.
Example
001 PQN
002 HSSELECT SALES
003 STON
004 HPQ-SELECT 1
005 P
006 10 MV %1 !1
007 IF # %1 X Done
008 T %1
009 GO 10
This example selects all the records in the SALES file, loads the record-list into select register 1 and displays the
keys one at a time.
Delimiters
PQ-style programs usually use a blank as the delimiter between parameters in the buffers. PQN-style programs
usually use a field mark.
PQN allows parameters to be null or contain blanks and more closely mirrors the native record structure.
PQ commands are still supported for compatibility but you should use the functionally superior PQN commands
in new or revised jCL programs.
When pointers are moved, PQ commands will generally leave the pointer at the first character of a parameter.
PQN commands will generally leave the pointer at a field mark.
Commands affected by this difference are A, B, BO, F, H, IH and IP.
Buffers
Buffer referencing, file buffers and select registers are only available with PQN commands.
Commands
These commands are only used in PQN-style jCL programs:
F; F-KLOSE F-WRITE L MVD
F-CLEAR F-OPEN FB MS
F-DELETE F-READ IBH MV
F-FREE F-UREAD IBP MVA
These commands are functionally equivalent in both PQ and PQN-style programs:
() G IF E RSUB U
[] GO B IFN RTN X
+ GO F M S
- GOSUB P STOFF
C IF RI STON
D IF (mask) RO TR
Command Syntax
jQL-command file-specifier {record-list} {selection-criteria} {sort-criteria} {USING file-specifier} {output-
specification} {format-specification} {(options}
Syntax Elements
jQL-command is one of the verb-like commands detailed later. Most commands will accept any or all of the
optional clauses.
file-specifier identifies the main data file to be processed. Usually the data section of a file, but could be a
dictionary or a secondary data area.
record-list defines which records will be eligible for processing. Comprises an explicit list of record keys or
record selection clauses. An explicit list comprises one or more record keys enclosed in single or double quotes.
A selection clause uses value strings enclosed in single or double quotes and has at least one relational operator.
If no record list is supplied, all records in the file will be eligible for processing unless an implicit record list is
provided by preceding the command with a selection command such as GET-LIST or SELECT.
selection-criteria qualify the records to be processed. Comprises a selection connective (WITH or IF) followed
by a field name. Field names can be followed by relational operators and value strings enclosed in double
quotes.
sort-criteria specify the order in which data is to be listed. Comprises a sort modifier, such as BY or BY-DSND,
followed by a field name. Can also be used to explode a report by sorting lines corresponding to multivalued
fields by value, and to limit the output of values (see output-specification).
USING file-specifier defines an alternate file to be used as the dictionary. There is no restriction of the number
of USING clauses that can be included in a jQL sentence.
output-specification comprises of the names of fields to be included in the report, optionally preceded by a
TOTAL or BREAK-ON connective. Print limiters (values strings enclosed in double quotes after the field name,
optionally preceded by relational operators) can be used to restrict multivalue output.
format-specification comprises modifiers, such as HEADING, ID-SUPP, and DBL-SPC, that define the overall
format of the report.
options comprise letters enclosed in parentheses which modify the action of the command - to redirect output to
a printer for example.
Notes
Any element of a jQL command sentence (with the exception of the command and filename) can be substituted
with a macro - see later.
Example
SORT SALES WITH PART.NO = ABC] BY POSTCODE CUST.NAME POSTCODE TOTAL
VALUE DBL-SPC HDR-SUPP (P
where:
SORT is the jQL command.
SALES is the filename.
WITH PART.NO = ABC] is the selection criterion. Select all records which contain a part number that starts
with ABC.
BY POSTCODE is the sort criterion.
CUST.NAME POSTCODE TOTAL VALUE is the output specification. Column 1 will contain the key of the
SALES file, column 2 will contain the customer name and column 3 will contain the POSTCODE. Column 4
will contain VALUE and will be totalled at the end of the report.
DBL-SPC HDR-SUPP are the format specifications. Double-space the lines and suppress the automatic header.
(P is an option. Redirect output to the system printer, rather than to the terminal.
PART.NO, CUST.NAME, POSTCODE and VALUE are references to data definition records which are defined
in the dictionary level of the SALES file.
Output Device
You can redirect the output to a printer (or the currently-assigned Spooler device) by using the LPTR format
specifier or the P option.
Report Layout
If the columnar report will not fit in the current page width of the output device, it will be output in non-
columnar format where each field of each record occupies one row on the page.
Paging
If the report is displayed at the terminal and extends over more than one screen, press RETURN to view the next
screen. To exit the report without diaplaying any remaining screens, press <CTRL X>, <CTRL E> or q.
jQL Commands
A jQL command is the first word in the jQL sentence.
The commands available from a particular account may be defined in the file specified by the
JEDIFILENAME_MD environment variable.
If JEDIFILENAME_MD is not set, all of the commands will be available.
If JEDIFILENAME_MD has been set and the user attempts to issue a command that is not defined in the
specified file, they will receive an error message. You can therefore effectively restrict user access to commands
by removing the definitions of unwanted commands from the specified file.
A later section of this chapter gives detailed descriptions of all the jQL commands in alphabetical order.
The most frequently used jQL commands are:
LIST SORT SELECT SSELECT
Other jQL commands are:
BSELECT CHECK-SUM COUNT EDELETE
ESEARCH LIST-LABEL REFORMAT SORT-LABEL
SREFORMAT T-DUMP T-LOAD
A number of jQL and non-jQL command can be used to generate an implicit list. These are:
Throwaway Connectives
A number of words and symbols can be used in a jQL sentence simply to make it easier to read and understand.
These words are ignored by the system.
Throwaway connectives include:
A AN ANY ARE DATA FILE FOR IN
ITEMS OF PAGE PG THE
Example
:LIST THE DATA IN THE SALES FILE WITH ANY S.CODE = ABC
The words THE, DATA, IN, FILE and ANY are ignored. This command is functionally equivalent to:
:LIST SALES WITH S.CODE = ABC
File Specifiers
The file specifier element of a jQL sentence defines the initial source of the data that will be used to build the
report.
Syntax
{DICT}{ ONLY}{ WITHIN}{ TAPE} filename{,data-section-name}
Syntax Elements
DICT specifies that the dictionary section of the named file is to be used as the source of data, and that the
JEDIFILENAME_MD is to be used as the source of the data definition records (unless you include a USING
clause - see later). DICT must be included immediately before the filename.
ONLY specifies that other than record keys, all data-related output is to be suppressed. ONLY can be included
anywhere on the command line.
WITHIN specifies a sublist such as bill of materials records. See the V Code - Sublist section for more
information.
TAPE tells the processor to retrieve the data from magnetic tape. The data must have been written in T-DUMP
format. When using the TAPE connective, filename is used indirectly to specify the default dictionary; although
you specify the data portion of the file, jQL will search the associated dictionary (DICT filename) for any data
definition records.
filename specifies the name of the file that is to be used as the initial source of data for the report. A filename
used without a modifier (SALES for example) specifies the primary data section of the named file. Can be
modified by DICT or data-section-name.
data-section-name specifies that the named (secondary) data section of filename is to be used as the initial
source of data for the report. data-section-name must be separated from filename by a comma but no space.
Syntax
key {key}...
Example
:LIST SALES ABC DEF GHI
Restricts report to records ABC, DEF and GHI only.
Syntax
{value-string}... relational-operator value-string {{logical-connective} {relational-operator} value-
string}...
Syntax Elements
value-string is a text string enclosed in delimiters (usually single quotes but could be double quotes), which is
compared against record keys in the file. Can also include any or all of the following special characters:
Left ignore ([) at the beginning of the string to indicate that the record key may start with any
characters (for example, [DEF)
Right ignore (]) at the end to indicate that the record key may end with any characters (for example,
ABC]).
Left ignore ([) at the beginning and Right ignore (]) at the end of a string indicate that the record key
must contain the enclosed string. (for example, [DEF])
Notes
A value string can contain any printable character, excluding RETURN, LINE FEED, and system delimiters, but
it cannot contain the character with which it is delimited. For example, a value string enclosed in single quotes
may contain double quotes, but not single quotes. You are recommended to use single quotes within record
selection clauses and double quotes within ordinary selection criteria, except when you are searching for a record
key that includes single quotes.
Example 1
LIST SALES ABC DEF
Shows an explicit list of record keys. Accesses and reports on records ABC and DEF only.
Example 2
LIST SALES = ABC] DEF
Shows a record selection clause with an implied OR connective between the two value strings. Accesses all
records but only reports on records with keys that match ABCanything or DEF.
Example 3
:GET-LIST SALES.Q4
>LIST SALES GT DEF
Get an implied list (SALES.Q4). List only those records that are in the implied list and have keys greater than
DEF.
Syntax
WITH | IF {NOT} {EACH} field {value-selection clause} {{AND | OR} {WITH | IF} {NOT} {EACH}
field {value-selection clause}...}
value-selection-clause has the form:
{relational-operator} value string {{logical-connective} {relational-operator} value string}...
Syntax Elements
WITH or IF is the selection connective. Must be the first word of a selection criterion. WITH and IF are
synonymous. WITHOUT is a synonym for WITH NOT.
NOT inverts the test result of the selection criterion. NOT and NO are synonymous. WITHOUT is a synonym
for WITH NOT.
EACH specifies that every value in a multivalued or subvalued field must satisfy the value selection clause for
the record to be selected. EVERY is a synonym for EACH.
field is the name of a data definition record.
AND joins two or more selection criteria. All ANDed tests must yield true for the record to be selected. The
number of ANDed selection criteria that you can specify is virtually unlimited.
OR joins two or more sets of selection criteria that may or may not contain ANDed clauses. The OR connective
does not have to be used explicitly but is recommended to improve readability.
relational-operator tests for a relationship between the field data and the value string. Value strings which are
not preceded by a relational-operator are assumed to be preceded by the equal operator (=). The result of a
relational test is true or false. Valid operators are shown below.
Symbol Synonyms Meaning
= EQ Equal
# NE Not Equal
NOT Not Equal
NO Not Equal
> GT Greater Than
AFTER Greater Than
>= GE Greater Than or Equal
=> Greater Than or Equal
< LT Less Than
BEFORE Less Than
<= LE Less Than or Equal
=< Less Than or Equal
value-string is a text string enclosed in delimiters (usually single quotes but could be double quotes), which is
compared against the field data in the file. Can also include any or all of the following special characters:
Left ignore ([) at the beginning of the string to indicate that the data may start with any characters (for
example, [DEF)
Right ignore (]) at the end to indicate that the data may end with any characters (for example,
ABC]).
Wild card (^) anywhere within the string. Each wild card matches one character of any value (for
example, ABC^EF^HI).
Notes
A value string can contain any printable character, excluding RETURN, LINE FEED, and system delimiters, but
it cannot contain the character with which it is delimited. For example, a value string enclosed in double quotes
may contain single quotes, but not double quotes. You are recommended to use double quotes within the
selection criteria and single quotes within record selection clauses, except when you are searching for data that
includes double quotes.
Example 1
LIST SALES WITH S.CODE = ABC]
List the records in the SALES file in which the S.CODE field contains subvalues which start with ABC.
Example 2
LIST SALES WITH S.CODE = ABC] OR [DEF
List the records in the SALES file in which the S.CODE field contains subvalues which start with ABC or end
with DEF.
Example 3
LIST SALES WITH NO S.CODE = ABC] OR [DEF
List the records in the SALES file in which the S.CODE field does not contain subvalues which start with ABC
or end with DEF.
Example 4
LIST SALES WITH S.CODE = ABC AND WITH C.CODE = DEF
List the records in the SALES file in which the S.CODE field contains subvalues of ABC and the C.CODE field
contains subvalues of DEF.
Syntax
BY field
BY-DSND field
BY-EXP field {print-limiter}
BY-EXP-DSND field {print-limiter}
Syntax Elements
print-limiter has the form:
{relational-operator} value string {{logical-connective} {relational-operator} value string}...
field is the name of a data definition record.
BY specifies a single value sort that will order the records according to an ascending sequence based on the first
value in the specified field.
BY-DSND specifies a single value sort that will order the records according to a descending sequence based on
the first value in the specified field.
BY-EXP specifies a multivalue sort that will order the multivalues of the specified field according to an
ascending sequence based on the first subvalue in each multivalued element.
BY-EXP-DSND specifies a multivalue sort that will order the multivalues of the specified field according to a
descending sequence based on the first subvalue in each multivalued element.
Notes
Each sort clause comprises a sort connective followed by a field name. The sort connective can specify an
ascending or descending sort sequence of single or multivalued fields. If you include more than one sort criteria
clause, the processor ranks the clauses in a left to right, most to least important hierarchical sequence. The record
key is always used the as the least important sort value.
The precise sorting sequence depends on whether a field is left- of right-justified.
Example 1
SORT SALES WITH S.CODE = ABC] BY S.CODE
Selects the records in the SALES file in which the S.CODE field contains values which start with ABC. Outputs
the records in S.CODE order.
Example 2
SORT SALES WITH S.CODE = ABC] BY S.CODE BY-DSND VALUE
Selects the records in the SALES file in which the S.CODE field contains values which start with ABC. Outputs
the records in descending VALUE order within S.CODE order.
Example 3
SORT SALES BY-EXP P.CODE
Selects all the records in the SALES file and outputs the detail lines in key order within P.CODE order.
Using Clause
Comprises {DICT} filename{,data-section-name}, where DICT specifies the dictionary of filename, filename
specifies a file, and data-section-name specifies a secondary data section of filename.
Syntax
field {print-limiter}...
TOTAL field {print-limiter}...
BREAK-ON field {text}{option{option}...}{text}
Syntax Elements
TOTAL specifies that a running total of a numeric field is to be maintained.
field is the name of a data definition record.
print-limiter suppresses output of values (to subvalue level) that do not match the clause. Suppressed values are
replaced with blanks. Any detail lines that would, as a result, be left blank are suppressed. Any totals produced
include just the values that match the limiting clause.
BREAK-ON specifies that control break is to be performed and a break line displayed, each time the value of
the field changes.
text comprises any printable characters except RETURN, LINE FEED, double quotes, single quotes, or system
delimiters.
option is one or more of the following options:
B Break. Works in conjunction with the B option of the HEADING and FOOTING modifiers to
insert the break value in the heading or footing. See HEADING and FOOTING Modifier later.
D Data. Suppresses the break if only one detail line has been output since the last break.
L Line. Suppresses the blank line preceding the break data line. Overrides the U option if both are
specified.
P Page. Causes each break to start a new page.
R Rollover. Inhibits a page break until all the data associated with the current break has been output.
U Underlines. Puts underlines on the line above the accumulated totals if the TOTAL modifier was
specified. Ignored if used with the L option.
V Value. Causes the value of the control-break field to be inserted at this point in the BREAK-ON
output.
Notes
The order in which you specify the field names (with their connectives) controls the order in which they appear
in the report. However, a dependent field is always printed to the right of its controlling field.
If the sentence contains an output specification clause, any default data definition records in the dictionary will
be ignored.
TOTAL Connectives
The TOTAL connective specifies that a running total of the field is to be maintained, and that the total is to be
output at each control break and at the end of the report.
Use the GRAND-TOTAL modifier in the Format Specification clause to specify any text to be displayed on the
last total line.
TOTAL can also be used in conjunction with the BREAK-ON connective to display intermediate totals at the
control breaks.
BREAK-ON Connective
The BREAK-ON connective causes the immediately following field to be monitored for change.
Up to 15 breaks are allowed in one sentence. Breaks are treated in hierarchical left to right order. The first
BREAK-ON in the sentence is the highest level.
Example 1
SORT SALES P.CODE S.CODE = ABC
Selects all the records in the SALES file and outputs the P.CODE data. The S.CODE data will only be included
if it matches ABC - any other value will be shown as blank.
Example 2
SORT SALES BY P.CODE BREAK-ON P.CODE TOTAL VALUE
Selects all the records in the SALES file in P.CODE order. Outputs a line for each record until the P.CODE
changes. At this point a control break is triggered and the running total of VALUE will be output. At the end of
the report, a cumulative total for VALUE will be displayed.
Syntax
{HDR-SUPP} {COL-HDR-SUPP} {ID-SUPP} {DET-SUPP} {DBL-SPC} {HEADING {{text}{hf-
option{hf-option}...}...}
{FOOTING {{text}{hf-option{hf-option}...}...}
{GRAND-TOTAL {text}{gt-option{gt-option}...}{text}}
{NOPAGE} {LPTR}
Syntax Elements
HDR-SUPP suppresses the default heading line at the top of the report and the summary line at the bottom of
the report. SUPP is a synonym for HDR-SUPP. You could use the H option at the end of the sentence instead
of this modifier.
Example
SORT SALES BY S.CODE BREAK-ON S.CODE BL P.CODE TOTAL VALUE GRAND-TOTAL
Total HEADING Sales Code : B DL FOOTING Page CPP LPTR
Sort the SALES file by S.CODE. Output the S.CODE, P.CODE and VALUE fields.
Control break on a change in S.CODE and suppress the LINE FEED before the break. Reserve the break value
for use in the heading (B).
Maintain a running total of the VALUE field and output it at each control break.
Put the word Total on the grand-total line.
Set up a heading for each page which comprises the words Sales Code : , the sales code (from the break), a
date and a LINE FEED. Set up a footing which contains the text Page and a page number, centred on the line.
Produce the report on the currently assigned printer.
USING Clause
The USING clause specifies a file that is to be treated as the dictionary for the data file. This file is the source of
data definition records.
Syntax
USING {DICT} filename{,data-section-name}
Syntax Elements
USING specifies that the named file is to be used as the dictionary for the data file.
DICT specifies that the dictionary of filename is to be used.
filename names a file. If the DICT modifier is not specified, the data section of the file will be used.
data-section-name specifies a secondary data section of the file with a name different from the dictionary. It
must follow filename, separated by a comma but no space.
Notes
As many USING clauses required can be specified in a jQL sentence.
One main advantage of the USING clause is that you can share a dictionary between several files where, for
example, there are common data definition records.
Example
:SORT SALES.94 USING DICT SALES
File SALES.94 will be accessed by means of the data definition records in the dictionary of file SALES (DICT
SALES).
Command Options
Command options are letters enclosed in parentheses which modify the action of the jQL command sentence.
The options described here are common to most commands. Where options are command-specific, they are
described with the command.
Options
B Suppress initial LINEFEED prior to output.
C Suppresses column headings, page and date line at the start and summary line at the end of a report.
Equivalent to the COL-HDR-SUPP modifier.
D Suppress detail output. Equivalent to the DET-SUPP modifier
H Suppress page and date line at the start and summary line at the end of the report. Equivalent to the HDR-
SUPP modifier.
I Suppress record keys. Equivalent to the ID-SUPP modifier.
N Suppress automatic paging. Equivalent to the NOPAGE modifier.
P Output report to the printer. Equivalent to the LPTR modifier.
S Suppress summary line at the end of the report.
Example
:LIST SALES (HIP
List the SALES file (using the default data definition records) but suppress the output of a header and the record
keys. Send the output to the assigned printer.
Macros
Macros contain predefined or often-used elements of a jQL sentence. They are held on the system like Data
Definition records and are specified in the command sentence in a similar way.
When a command containing one or more macros is submitted for execution, the macro references are expanded
and included in the sentence before it is executed.
Macros can be substituted for any element of the command sentence except the command itself and the filename.
Macro definition records are searched for in the same way as Data Definition records. You should not use a jQL
keyword as the name (key) of a macro, but you can specify keys of 1, 2, 3 etc. that will be treated like the default
Data Definitions records.
The first field of a macro definition must contain the letter M. The remaining fields are either command elements
or comment lines (indicated by a leading asterisk * and a space).
Macros can be nested - a macro can refer to another macro - but the resulting command sentence must still
follow the same rules as a normal jQL sentence. When nesting macros, beware of infinite loops where, for
example, macro A calls macro B which calls macro A which calls macro B...
Example
SORT SALES BY S.CODE STD.HEADING
In this example, STD.HEADING is a macro which contains a standard heading clause:
STD.HEADING
001 M
002 * Standard heading for Sales reports
003 HEADING SALES - Company PrivateLLPage PL
004 LPTR
When the sentence is expanded, it will look like this:
BSELECT Command
Retrieves selected records and generates a list composed of data fields from those records as specified by any
explicit or default output specifications. Each subvalue within a field becomes a separate entry within the list.
Syntax
BSELECT file-specifier {record-list} {selection-criteria} {sort-criteria} {USING file-specifier}{output-
specification} {(options}
Notes
When the command terminates, the total number of entries in the generated list is displayed and the list is made
available as if it had been generated by a SELECT, GET-LIST or other list-providing command.
If you do not specify a sort-criteria clause, the record list will be unsorted.
If you do not specify an output-specification, the default data definitions 1, 2 etc. will be used.
Examples
BSELECT SALES WITH S.CODE = ABC] P.CODE
Creates a list containing all P.CODE values from all the records in the SALES file which have an S.CODE that
starts with ABC.
COUNT Command
Reports the total number of records found in a file that match the selection criteria specified.
Syntax
COUNT file-specifier {record-list} {selection-criteria} {USING file-specifier} {(options}
Syntax Elements
options can be one or more of the following:
B Suppress initial line-feed.
C{n} Display running counters of the number of records selected and records processed. Unless
modified by n, the counter increments after every 500 records processed or the total number of
records if less than 500.
The n specifies a number other than 500 by which to increment. For example, (C25) increments
the counter after every 25 records processed.
P Send the report to the printer.
Examples
:COUNT SALES WITH VALUE > 1000
91 Records counted
Count the number of records in the SALES file which have a value greater than 1000.
EDELETE Command
Deletes selected records from a file according to record list or selection criteria clauses.
Syntax
EDELETE file-specifier [record-list | selection-criteria]
Notes
EDELETE requires an implicit or explicit record list, or selection criteria. An implicit list can be provided by
preceding the command with a SELECT, GET-LIST or other list-providing command.
EDELETE will immediately delete the specified records.
To clear all the records in a file, use the CLEAR-FILE command.
Examples
:EDELETE SALES ABC DEF
2 Records deleted
Delete the records ABC and DEF based on the explicit list of records.
:EDELETE SALES IF P.CODE = GHI]
n Records deleted
Delete all records in the SALES file in which the P.CODE field starts with GHI.
:SELECT SALES WITH S.CODE = ABC
n Records selected
>EDELETE SALES
n Records deleted
Selects all records in the SALES file in which the S.CODE field contains ABC, and deletes them.
ESEARCH Command
Generates an implicit list of records in a file if they contain (or do not contain) one or more occurrences of
specified character strings..
Syntax
ESEARCH file-specifier {record-list} {selection-criteria} {sort-criteria}
{USING file-specifier} {(options}
Syntax Elements
options can be one or more of the following:
A ANDs prompted strings together. Records must contain all specified strings.
I Displays the keys of selected records.
L Saves the field numbers in which the specified strings were found. The resulting list contains the
record keys followed by multivalued line numbers. Ignores the A and N options if either or both are
specified.
N Selects only those records that do not contain the specified string(s).
S Suppresses the list but displays the record keys that would have been selected.
Notes
When the command terminates (unless the `S option is used), the total number of entries in the generated list is
displayed and the list is made available as if it had been generated by a SELECT, GET-LIST or other list-
providing command.
If you do not specify a sort criteria clause, the record list will be unsorted.
Example
:ESEARCH SALES (I
STRING: ABC
STRING: DEF
KEY1
KEY2
2 Records selected
>
Generates a list of all records in the SALES file which contain the strings ABC or DEF.
LIST Command
Generates a formatted report of records and fields from a specified file.
Syntax
LIST file-specifier {record-list} {selection-criteria} {sort-criteria}
{USING file-specifier} {output-specification} {format-specification} {(options}
Notes
If an output specification clause is not provided, the system will search for default data definition records (named
1, 2 and so on) in the file dictionary and then in the file specified in the JEDIFILENAME_MD environment
variable. If default data definition records cannot be found, the only the record keys will be listed.
The records will not be sorted unless you specify a sort criteria clause.
Example 1
:LIST SALES
List all the records in the SALES file and use the default data definition records (if found) to format the output.
Example 2
:LIST SALES ABC DEF GHI
List the records from the SALES file with key values of ABC, DEF or GHI. Use the default data definition
records (if found) to format the output.
Example 3
:GET-LIST SALES.Q4
>LIST SALES GT DEF
Example 4
:LIST SALES WITH S.CODE = ABC] OR [DEF
List the records in the SALES file in which the S.CODE field contains values which start with ABC or end with
DEF. Use the default data definition records (if found) to format the output.
Example 5
:LIST SALES WITH NO S.CODE = ABC] OR [DEF (P
List the records in the SALES file in which the S.CODE field does not contain values which start with ABC or
end with DEF. Output the report to the printer. Use the default data definition records (if found) to format the
output.
Example 6
:LIST SALES BY S.CODE BREAK-ON S.CODE BL P.CODE TOTAL VALUE GRAND-
TOTAL Total HEADING Sales Code : B DL FOOTING Page CPP LPTR
Sort the SALES file by S.CODE. Output the S.CODE, P.CODE and VALUE fields.
Control break on a change in S.CODE and suppress the LINE FEED before the break. Reserve the break value
for use in the heading (B).
Maintain a running total of the VALUE field and output it at each control break.
Put the word Total on the grand-total line.
Set up a heading for each page which comprises the words Sales Code : , the sales code (from the break), a
date and a LINE FEED. Set up a footing which contains the text Page and a page number, centred on the line.
Produce the report on the currently assigned printer.
LIST-LABEL Command
Outputs data in a format suitable for producing labels.
Syntax
LIST-LABEL file-specifier {record-list} {selection-criteria} {sort-criteria}
{USING file-specifier}{output-specification} {format-specification} {(options}
Prompts
You will be prompted to supply formatting criteria as follows:
COL,ROW,SKIP,INDENT,SIZE,SPACE{,C}:
COL Number of columns required to list the data across the page.
ROW Number of lines for each record. Each element of the output specification will be output on a separate
line, if more elements exist in the output specification than there are rows specified, the extra elements
will be ignored. If more rows are specified than elements, the output specification for these rows will
be blank.
SKIP Number of blank lines between each record.
INDENT Number of spaces for left margin.
SIZE Number of spaces required for the data under each column.
SPACE Number of horizontal spaces to skip between columns.
C Optional. Suppresses null or missing data. If absent, null or missing values are output as blanks. If
present the C must be upper case and not in quotes.
Example
LIST-LABEL SALES NAME ADDRESS STREET TOWN POSTCODE ID-SUPP (C
COL,ROW,SKIP,INDENT,SIZE,SPACE(,C): 2,5,2,0,25,4,C
NAME1 NAME2
ADDRESS1 ADDRESS2
STREET1 STREET2
TOWN1 TOWN2
POSTCODE1 POSTCODE2
NAME3 NAME4
ADDRESS3 ADDRESS4
STREET3 STREET4
TOWN3 TOWN4
POSTCODE3 POSTCODE4
.
.
.
LISTDICT Command
Generates a report of all data definition records in the first MD file found, or the specified file.
Syntax
LISTDICT {file-specifier}
Syntax Elements
file-specifier specifies a dictionary file other than a file named MD in the JEDIFILEPATH.
Notes
If you do not specify a file-name, LISTDICT will work with the first file named MD which is found in your
JEDIFILEPATH.
REFORMAT Command
REFORMAT is similar to the LIST command in that it generates a formatted list of fields, but its output is
directed to another file or the magnetic tape rather than to the terminal or printer.
Prompt
You will be prompted to supply the destination file:
FILE:
Enter a file name, or the word TAPE for output to a magnetic tape.
Notes
Records that already exist in the destination file will be overwritten.
When you reformat one file into another, each record selected becomes a record in the new file. The first value
specified in the output specification clause is used as the key for the new records. The remaining values in the
output specification clause become fields in the new records.
When you reformat a file to tape, the values specified in the output specification clause are concatenated
together to form one tape record for each record that is selected. The record output is either truncated or padded
at the end with nulls (X00) to obtain a record the same length as specified when the tape was assigned by the T-
ATT command.
Unless you specify HDR-SUPP or COL-HDR-SUPP, or a C or H option., a tape label containing the file name,
tape record length (in hexadecimal), the time, and date will be written to the tape first. If a HEADING clause is
specified, this will form the data for the tape label.
Record keys are displayed as the records are written to tape unless the ID-SUPP modifier or the I option is
specified.
Two EOF marks terminate the file on tape.
See also the SREFORMAT command.
Example
:REFORMAT SALES C.CODE NAME ADDRESS
FILE: ADDRESS
Creates new records in the ADDRESS file, keyed on C.CODE from the SALES file. Each record contains two
fields, one with the values from the NAME field and one with the values from the ADDRESS field.
SELECT Command
Generates an implicit list of record keys or specified fields based on the selection criteria specified.
Syntax
SELECT file-specifier {record-list} {selection-criteria} {sort-criteria} {output-criteria} {USING file-
specifier} {(options}
Syntax Elements
options are:
C{n} Display running counters of the number of records selected and records processed. Unless
modified by n, the counter increments after every 500 records processed or the total number of
records if less than 500.
n specifies a number other than 500 by which to increment. For example, C25 increments the
counter after every 25 records processed.
Example 1
:SELECT SALES WITH S.CODE = ABC]
23 Records selected
>LIST SALES WITH VALUE > 1000
Select all the records in SALES file with an S.CODE value that starts with ABC. Then, using the list, report on
the records in the SALES file which have a VALUE field greater than 1000.
Example 2
:SELECT SALES WITH S.CODE = ABC]
23 Records selected
>SAVE-LIST SALES.ABC
Select all the records in SALES file with an S.CODE value that starts with ABC. Then save the list as
SALES.ABC.
SORT Command
Generates a sorted and formatted report of records and fields from a specified file.
Syntax
SORT file-specifier {record-list} {selection-criteria} {sort-criteria}
{USING file-specifier} {output-specification} {format-specification} {(options}
Notes
Unless a different sort order is specified in the sort criteria, the records will be presented in an ascending order
based on the record key.
The data definition record (or the file definition record in the case of keys) determines whether a left or right sort
will be applied to the data.
If the field is left-justified, the data will be compared on a character-by-character basis from left to right, using
ASCII values. For example:
01
100
21
A
ABC
BA
Example 1
:SORT SALES
Sort all the records in the SALES file into key order and use the default data definition records (if found) to
format the output.
Example 2
:SORT SALES WITH S.CODE = ABC DEF GHI
Select the records in the SALES file in which the S.CODE field contains the values ABC, DEF or GHI. Sort the
records into key order.
Example 3
:GET-LIST SALES.Q4
>SORT SALES GT DEF BY S.CODE
Get the implicit list called SALES.Q4 and, using the list, report on the records in the SALES file which have a
key greater than DEF. Sort the report by S.CODE.
Example 4
:SORT SALES WITH S.CODE = ABC] OR [DEF BY-DSND S.KEY LPTR
Select the records in the SALES file in which the S.CODE field contains values which start with ABC or end
with DEF. Sort the report in descending order of S.KEY (a data definition record which points to field 0 - the
key) and output the report to the printer
Example 5
:SORT SALES BY S.CODE BREAK-ON S.CODE BL P.CODE TOTAL VALUE GRAND-
TOTAL Total HEADING Sales Code : B DL FOOTING Page CPP LPTR
Sort the SALES file by S.CODE. Output the S.CODE, P.CODE and VALUE fields.
Control break on a change in S.CODE and suppress the LINE FEED before the break. Reserve the break value
for use in the heading (B). Maintain a running total of the VALUE field and output it at each control break. Put
the word Total on the grand-total line.
Set up a heading for each page which comprises the words Sales Code : , the sales code (from the break), a
date and a LINE FEED. Set up a footing which contains the text Page and a page number, centred on the line.
Produce the report on the currently assigned printer.
SORT-LABEL Command
Outputs data in a format suitable for producing labels.
Prompts
You will be prompted to supply formatting criteria as follows:
COL,ROW,SKIP,INDENT,SIZE,SPACE(,C):
COL Number of columns required to list the data across the page.
ROW Number of lines for each record.
SKIP Number of blank lines between each record.
INDENT Number of spaces for left margin.
SIZE Number of spaces required for the data under each column.
SPACE Number of horizontal spaces to skip between columns.
C Optional. Suppresses null or missing data. If absent, null or missing values are output as blanks.
Notes
The total number of columns specified must not exceed the page width, based on the calculation:
COLs * (SIZE + SPACE) + INDENT <= page width
ROW must be a minimum of one for each field, plus one for the record key (if not suppressed). If record keys
are not suppressed, the first row of each label will contain the record key. The records will be sorted in key order
unless you specify a sort criteria clause.
If INDENT is not zero, you will be prompted to supply a series of HEADERs that will appear in the left margin
for each field. If a heading is not required for a particular line, press RETURN.
Multivalued fields appear on separate lines.
If COL-HDR-SUPP or HDR-SUPP, or the C or H options are specified, the page number, date, and time will not
be output and the report will be generated without page breaks.
See also the LIST-LABEL command.
SREFORMAT Command
SREFORMAT is similar to the SORT command in that it generates a formatted list of fields, but its output is
directed to another file or the magnetic tape rather than to the terminal or printer.
Syntax
SREFORMAT file-specifier {record-list} {selection-criteria}
{USING file-specifier} {output-specification} {format-specification} {(options}
Prompt
You will be prompted to supply the destination file:
FILE:
Enter a file name, or the word TAPE for output to a magnetic tape.
Notes
Records that already exist in the destination file will be overwritten.
When you reformat one file into another, each record selected becomes a record in the new file. The first value
specified in the output specification clause is used as the key for the new records. The remaining values in the
output specification clause become fields in the new records.
SSELECT Command
SSELECT generates an implicit list of record keys or specified fields, based on the selection criteria specified.
Syntax
SSELECT file-specifier {record-list} {selection-criteria} {sort-criteria} {output-criteria} {USING file-
specifier} {(options}
Syntax Elements
options are:
C{n} Display running counters of the number of records selected and records processed. Unless
modified by n, the counter increments after every 500 records processed or the total number of
records if less than 500.
n specifies a number other than 500 by which to increment. For example, C25 increments the
counter after every 25 records processed.
Notes
The records will be sorted in key order unless you specify a sort criteria clause.
See also the SELECT command.
If you specify an output-criteria clause, the generated list will comprise the data (field) values defined by the
clause, rather than the selected record keys.
When the command terminates, the total number of entries in the generated list is displayed and the list is made
available to the next command. This is indicated by the > prompt if you are in jSHELL.
If you use the BY-EXP or BY-EXP-DSND connectives on a multivalued field, the list will have the format:
record-key]multivalue#
where multivalue# is the position of the multivalue within the field specified by BY-EXP or BY-EXP-DSND.
multivalue# can be accessed by a READNEXT Var,n statement in a jBC program.
Example 1
:SSELECT SALES WITH S.CODE = ABC]
23 Records selected
>LIST SALES WITH VALUE > 1000
Select all the records in SALES file with an S.CODE value that starts with ABC. Sort the list into key order.
Then, using the list, report on the records in the SALES file which have a VALUE field greater than 1000.
Record Structure
The fields of a file definition record that affect jQL reports are:
Field 7 Conversion code for key, if required. For date, time, etc.
Field 8 V code to notify a multivalued (sublist) field, if required. See Sublists - V Code following.
Field 9 Justification for key. Can be one of the following:
L Left justified
R Right justified
T Text
U Unlimited
See 'Data Definition Records' later.
Field 10 Column width for key. Default is 14 characters.
Sublists - V Code
File records which contain sublists can be accessed with the COUNT and LIST commands and the WITHIN
modifier. For the commands and the modifier to function properly, you must include the V processing code in
field 8 of the file definition record. See the File Specifiers topic in the jQL Command Sentence Construction
topic for more details.
Syntax
V;;field-no
Syntax Elements
field-no is the number of the field which contains the sublist.
Example
Consider the STOCK file used by a camera factory where each data record can represent either an assembly or a
component part.
Take as an example the record set that defines a simple camera assembly. The data records contain the following
data:
Key A1 Key A21
001 CAMERA ASSY 001 LENS ASSY
002 A21]A22]A23 002 A210]A211
003 10 003 15
Record A1 represents assembled cameras. It points to the sub-assemblies (A21, A22 and A23) that are used to
make each camera. The sub-assemblies in turn point to their component parts; A21 points to A210 and A211,
A22 does not have any components, and A23 points to A230.
Having established the logical data relationships, we now need to ensure that the system understands that field 2
is a multivalued sublist. We do this by updating field 8 in the file definition record to read V;;2, like this:
STOCK
001 D
002
003
004
005
006
007
008 V;;2
009 L
010 10
Now all we need to do is to create three data definition records (see later) in the dictionary of STOCK - one for
each field. We will name them DESC, COMPONENTS, and QTY.
The final step is to issue a COUNT or LIST command which uses the WITHIN modifier:
:LIST WITHIN STOCK 'A1' DESC COMPONENTS QTY
PAGE 1 Time Date
LEVEL STOCK Description.... Components Qty
Record Layout
All data definition records are defined in the same way:
Field Description
1 D/CODE. Defines the record as a data definition record. Must be one of the following codes:
A marks a normal data definition record.
S obsolete but still supported. Was like the A type, but suppressed default column headings when
field 3 was blank. Replaced by the A type with a backslash in field 3 to defeat heading.
X forces the record to be ignored if selected as part of a default set of data definitions. Can only
be used when explicitly named. See Default Output Specification later.
2 FMC (field-mark count). A field number or special FMC (see Special Field-mark Counts later, for
more details). A field number refers to the corresponding field (or line) in a record.
The special FMC codes are:
0 Refers to the record key - field number 0 (zero).
9998 Ordinal number of record at output (used for numbering or counting).
9999 Size of the record in bytes (excluding the key).
3 Column heading. Can be heading text, null, or a backslash followed by text. If more characters are
entered here than the width in field 10 allows for, the width will be increased to accommodate the
heading text (this field wins). Column headings are not displayed if the statement uses the COL-HDR-
SUPP output modifier or the 'C' option.
Heading text is used as the column heading. If the text is less than the column width, it will be padded
with dots. Use spaces to produce a blank heading. Value marks, <CTRL ]>, can be used as
NEWLINE characters to place the following text on a new line.
If this field is left null, the key of the data definition record will be used as the column heading.
Implicit Defaults
If you do not explicitly specify any data definition records to be used for output, the system will search for a
predefined series of records, first in the implied dictionary (or the dictionary specified in a USING clause), and
then in the files specified in the JBCDEFDICTS environment variable. If the record is still not located, the file
defined by the JEDIFILENAME_MD environment variable will be searched.
You can therefore set up a series of data definition records that the system will use if a jQL command sentence
does not include any explicit output fields.
These default records must be named in a numeric sequence starting at 1 (1, 2, 3, and so on). The fields that
these records define will be output in the same sequence as the keys but they do not need to follow the same
sequence as the fields in the file.
When a jQL command sentence with no explicit output fields is issued, the system first looks in the dictionary
for a data definition record named 1, then for a record named 2, then 3, and so on until it fails to find a record
with the next number. If the record has a D/CODE of A, it will be used. If the record has a D/CODE of X, it will
be ignored, but it will not break the sequence.
A record with a D/CODE of X will only be skipped if it was found as the result of a search for defaults. Under
normal circumstances it can be used in the same way as any other data definition record.
This means that when you first set up a series of default data definition records, you should put an A in the
D/CODE field of each. If you subsequently need to remove one from the sequence, you can simply change the
D/CODE field to an X. This way you do not break the sequence or have to copy the remaining default records
to new names in order to fill the gap.
A data definition record with a number for a key can still be used in the same way as any other data definition
record.
Selections
Selection involves the comparison of file data in internal format against input data in intermediate format.
The processing steps are:
1. Obtain value to compare from selection clause
1. Apply inverted conversion code from field 7 to value to compare
1. Obtain file data in stored format
1. Apply conversion code in field 8 to file data
1. Compare the inverted value and the converted file data
Sorts
Sorts are performed on data in intermediate format.
The processing steps are:
1. Obtain file data in stored format
1. Apply conversion code in field 8 to file data
1. Append the converted data to sort key
TOTAL Connectives
When the TOTAL connective is used in a jQL command sentence, the system initialises a counter to accumulate
the values of the specified field (as defined by field 2 of the data definition record). The system organises
multiple counters in the same left to right sequence as it found the totalled fields in the sentence. This sequence
is important because you can specify more than one counter with the same FMC.
Only the fields qualified with the TOTAL connective are assigned counters.
Total Line
When the processor prepares a total for output, it first applies the field 7 (output) code. However, in this case,
the system handles format and function code definitions differently.
If a format code is used, the processor applies the code to the counter accumulated for the specified field, so that
what is displayed is derived from the total for that field.
If a function code (A, AE, F, FE, or FS) is encountered, the system resolves a field reference by using the FMC
associated with each total counter, not the field specified in the sentence.
Format codes used within functions follow the rules of the function.
Notes
Function codes can be used to calculate averages. For example, the ND (number of detail lines) operand could
be used to obtain the average of a sum.
If you want to suppress the output of detail values for a particular column in the report, for example if the total of
a column is only used by a function in another column, you can suppress the output of the column by putting a
backslash in field 3 or a zero in field 10 of the data definition record.
BREAK-ON Connectives
When a BREAK-ON field is used, the system will first apply the field 8 (pre-process) conversion code to move
the data into intermediate format.
The intermediate format is then used to check for any change in data values between one record and the next. In
other words, should the break be processed.
Having completed the check at the intermediate format stage, the system will then apply field 7 (output) codes to
produce the output format.
Processing
The processing steps are:
1. Obtain file data in stored format
1. Apply conversion code in field 8 (pre-process) to file data
1. Compare converted data for this record with that of the previous record for a change in value.
Remember result.
1. Apply conversion code in field 7 (output) to intermediate format data
1. If value has changed, perform control break. If not, output the data
Syntax Summary
The A code function uses an algebraic format. There are two forms of the A code:
A uses only the integer parts of stored numbers unless a scaling factor is included.
AE handles extended numbers. Uses both integer and fractional parts of stored numbers.
Syntax
A{n}{;expression}
AE;expression
Syntax Elements
n is a number from 1 to 6 that specifies the required scaling factor.
expression comprises operands, operators, conditional statements, and special functions.
Notes
The A code replaces and enhances the functionality of the F code. You will find A codes much easier to work
with than F codes.
Valid A codes formats are:
A;expression evaluates the expression.
An converts to a scaled integer.
An;expression converts to a scaled integer.
AE;expression evaluates the expression.
A;expression Format
Performs the functions specified in expression on values stored without an embedded decimal point.
An;expression Format
The An;expression format performs the functions specified in expression on values stored with an embedded
decimal point. The resulting value is then converted to a scaled integer.
AE;expression Format
The AE format uses both the integer and fractional parts of stored numbers. Scaling of output must be done with
format codes.
Format Codes
You can format the result of any A code operation by following the expression with a value mark, <CTRL ]>,
and then the required format code, like this:
An;expression]format
Format codes can also be included within the expression. See Format Codes for more information.
Summary of Operands
Operands that you can use in A code expressions include: FMCs (field numbers), field names, literals, operands
that return system parameters, and special functions.
You can format any operand by following it with one or more format codes enclosed in parentheses, and
separated by value marks, <CTRL ]>, like this:
operand(format-code{]format-code}...)
See Format Codes for more information.
Literal Operand
The literal operand supplies a literal text string or numeric value:
literal
Special Operands
Some operands allow you to use special functions. They are:
I(expression) Returns the integer part of expression.
R(exp1, exp2) Returns the remainder of exp1 divided by exp2.
S(expression) Returns the sum of all values generated by expression.
string[start-char-no, len] Returns the substring starting at character start-char-no for length len.
Summary of Operators
Operators used in A code expressions include arithmetic, relational and logical operators, the concatenation
operator, and the IF statement.
Arithmetic Operators
Arithmetic operators are:
+ Sum of operands
- Difference of operands
* product of operands
/ Quotient (an integer value) of operands
Relational Operators
Relational operators specify relational operations so that any two expressions can treated as operands and
evaluated as returning true (1) or false (0). Relational operators are:
= or EQ Equal to
< or LT Less than
=> or GT Greater than
<= or LE Less than or equal to
>= or GE greater than or equal to
# or NE Not equal
Logical Operators
The logical operators test two expressions for true or false and return a value of true or false. Logical operators
are:
AND Returns true if both expressions are true.
OR Returns true if any expressions is true.
Concatenation Operator
The concatenation operator is a colon (:)
IF Statement
The IF operator gives the A code its conditional capabilities. An IF statement looks like this:
IF expression THEN statement ELSE statement
Syntax Elements
field-number is the number of the field (FMC) which contains the required value.
R specifies that the value obtained from this field is to be applied repeatedly for each multivalue not present in a
corresponding part of the calculation.
RR specifies that the value obtained from this field is to be applied repeatedly for each subvalue not present in a
corresponding part of the calculation.
Notes
The following field numbers have special meanings:
0 Record key
9999 Record size in bytes
9998 Sequential record count
Example 1
A;2
Returns the value stored in field 2 of the record.
Example 2
A;9999
Returns the size of the record in bytes.
Example 3
A;2 + 3R
For each multivalue in field 2 the system also obtains the (first) value in field 3 and adds it. If field 2 contains
1]7 and field 3 contains 5 the result would be two values of 6 and 12 respectively. Where 3 does not have a
corresponding multivalue, the last non-null multivalue in 3 will be used.
Example 4
A;2 + 3RR
For each subvalue in field 2 the system also obtains the corresponding subvalue in field 3 and adds it. If field 2
contains 1\2\3]7 and field 3 contains 5\4 the result would be four values of 6, 6, 7, 12 and 4 respectively.
Syntax
N(field-name){R{R}}
Syntax Elements
field-name is the name of another field defined in the same dictionary or found in the list of default dictionaries
(see the JBCDEFDICTS environment variable).
R specifies that the value obtained from this field is to be applied repeatedly for each multivalue not present in a
corresponding part of the calculation.
RR specifies that the value obtained from this field is to be applied repeatedly for each subvalue not present in a
corresponding part of the calculation.
Example 1
A;N(S.CODE)
Returns the value stored in the field defined by S.CODE.
Example 2
A;N(A.VALUE) + N(B.VALUE)R
For each multivalue in the field defined by A.VALUE the system also obtains the corresponding value in
B.VALUE and adds it. If A.VALUE returns 1]7 and B.VALUE returns 5, the result would be two values of 6
and 12 respectively.
Example 3
A;N(A.VALUE) + N(B.VALUE)RR
For each subvalue in the field defined by A.VALUE the system also obtains the corresponding value in
B.VALUE and adds it. If A.VALUE returns 1\2\3]7 and B.VALUE returns 5 the result would be four values of
6, 7, 8 and 12 respectively.
Literal Operand
Specifies a literal string or numeric constant enclosed in double quotes.
Syntax
literal
Syntax Elements
literal is a text string or a numeric constant.
Notes
A number not enclosed in double quotes is assumed to be a field number (FMC).
Example 1
A;N(S.CODE) + 100
Adds 100 to each value (subvalue) in the field defined by S.CODE.
Example 2
A;N(S.CODE):SUFFIX
Concatenates the string SUFFIX to each value (subvalue) returned by S.CODE.
Syntax
system-operand
Syntax Elements
system-operand can be any of the following:
D Returns the system date in internal format.
LPV Returns the previous value transformed by a format code.
NA Returns the number of fields in the record.
NB Returns the current break level counter. 1 is the lowest break level, 255 is the GRAND TOTAL line.
ND Returns the number of records (detail lines) since the last control break.
NI Returns the record counter.
NL Returns the record length in bytes
NS Returns the subvalue counter
NU Returns the date of last update
NV Returns the value counter
T Returns the system time in internal format.
V Returns the previous value transformed by a format code
Special Operands
Integer Function
The Integer Function I(expression) returns the integer portion of expression.
Example
AE;I(N(COST) * N(QTY))
Returns the integer portion of the result of the calculation.
Remainder Function
The Remainder Function R(exp1, exp2) takes two expressions as operands and returns the remainder when the
first expression is divided by the second.
Example
A;R(N(HOURS) / 24)
Returns the remainder when HOURS is divided by 24.
Summation Function
The Summation Function S(expression) evaluates an expression and then adds together all the values.
Example
A;S(N(HOURS) * N(RATE)R)
Each value in the HOURS field is multiplied by the value of RATE. The multivalued list of results is then
totalled.
Syntax Elements
start-char-no is an expression that evaluates to the position of the first character of the substring.
len is an expression that evaluates to the number of characters required in the substring. Use - len (minus prefix)
to specify the end point of the substring. For example, [1, -2] will return all but the last character and [-3, 3] will
return the last three characters.
Example 1
A;N(S.CODE)[2, 3]
Extracts a sub-string from the S.CODE field, starting at character position 2 and continuing for 3 characters.
Example 2
A;N(S.CODE)[2, N(SUB.CODE.LEN)]
Extracts a sub-string from the S.CODE field, starting at the character position defined by field 2 and continuing
for the number of characters defined by SUB.CODE.LEN.
Format Codes
Specifies a format code to be applied to the result of the A code or an operand.
Syntax
a-code{]format-code...}
a-operand(format-code{]format-code}...)
Syntax Elements
a-code is a complete A Code expression.
a-operand is one of the A Code operands.
format-code is one of the codes described later - G(roup), D(ate) or M(ask).
] represents a value mark <CTRL ]> that must be used to separate each format-code.
Notes
You can format the result of the complete A code operation by following the expression with a value mark and
then the required format code(s). (This is actually a standard feature of the data definition records.)
Format codes can also be included within A code expressions. In this case, they must be enclosed in parentheses,
and separated with a value mark if more than one format code is used.
All format codes will convert values from an internal format to an output format.
Example 1
A;N(COST)(MD2]G0.1) * ...
Shows two format code applied within an expression. Obtains the COST value and applies an MD2 format code.
Then applies a group extract to acquire the integer portion of the formatted value. The integer portion can then
be used in the rest of the calculation.
Could also have been achieved like this:
A;I(N(COST)(MD2)) * ...
Operators
Operators used in A code expressions include arithmetic, relational and logical operators, the concatenation
operator, and the IF statement.
Arithmetic Operators
Arithmetic operators are:
+ Sum of operands
- Difference of operands
* product of operands
/ Quotient (an integer value) of operands
Relational Operators
Relational operators specify relational operations so that any two expressions can treated as operands and
evaluated as returning true (1) or false (0). Relational operators are:
= or EQ Equal to
< or LT Less than
=> or GT Greater than
<= or LE Less than or equal to
>= or GE greater than or equal to
# or NE Not equal
Logical Operators
The logical operators test two expressions for true (1) or false (0) and return a value of true or false. Logical
operators are:
AND Returns true if both expressions are true.
OR Returns true if any expressions is true.
The words AND and OR must be followed by at least one space. The AND operator takes precedence over the
OR unless you specify a different order by means of parentheses. OR is the default operation.
Concatenation Operator
A colon (:) is used to concatenate the results of two expressions.
For example, the following expression concatenates the character Z with the result of adding together fields 2
and 3:
A;Z:2 + 3
IF Statement
The IF statement gives the A code conditional capabilities.
Syntax
IF expression THEN statement ELSE statement
Syntax Elements
expression must evaluate to true or false. If true, executes the THEN statement. If false, executes the ELSE
statement
statement is a string or numeric value.
Example 1
A;IF N(QTY) < 100 THEN N(QTY) ELSE ERROR!
Tests the QTY value to see if it is less than 100. If it is, output the QTY field. Otherwise, output the text
ERROR!.
Example 2
A;IF N(QTY) < 100 AND N(COST) < 1000 THEN N(QTY) ELSE ERROR!
Same as example 1 except that QTY will only be output if it is less than 100 and the cost value is less than 1000.
Example 3
A;IF 1 THEN IF 2 THEN 3 ELSE 4 ELSE 5
If field 1 is zero or null, follow else and use field 5. Otherwise test field 2. If field 2 is zero or null, follow else
and use field 4. Otherwise use field 3.
Field 3 is only used if both fields 1 and 2 contain a value.
Syntax
C{;}n{xn}...
Syntax Elements
; is optional. It has no function other than to provide compatibility.
n can be one of the following:
a field number (FMC)
a literal enclosed in single quotes, double quotes, or backslashes
an asterisk (*) to specify the last generated value of a previous operation.
x is the character to be inserted between the concatenated elements. If you specify a semicolon (;), no separator
will be used. Any non-numeric character except a system delimiters (value, subvalue, field, start buffer, and
segment marks) is valid.
Notes
See the descriptions of the function codes (A, F, FS and their variants) for other concatenation methods.
Input Conversion
Input conversion does not invert. The concatenation is applied to the input data.
Example 1
C1;2
Concatenates the contents of field 1 with field 2, with no intervening separator character.
Example 2
C1*2
Concatenates the contents of field 1 with an asterisk (*) and then the content of field 2.
Example 3
C1*ABC 2/3
Concatenates the contents of field 1 with an asterisk (*), the string ABC, a space, field 2 a forward slash (/) and
then field 3.
Syntax
B;{filename}subname
CALL{X} {filename}subname
Syntax Elements
filename is ignored but provided for compatibility with older systems.
subname is the name of the called subroutine (or function). This subroutine must reside in one of the libraries
defined for the user.
Notes
Use the B or CALL code when you need to perform processing that is not possible with other available codes.
All necessary variables are pre-defined in a COMMON block that you must INCLUDE in your subroutine. See
the Advanced Programmers Reference Manual for more information on constructing C functions.
Subroutine programs must start with these lines:
SUBROUTINE subname {(parameter)}
INCLUDE qbasiccommon
Option parameter is only used when the JBCEMULATE environment variable is set to AP.
qbasiccommon is a standard header file provided with jBASE. You may need to include a different
qbasiccommon block, depending on the emulation in use. If required, you can create your own version of the
code. See the Advanced Programmers Reference Manual for more information.
qbasiccommon defines the following COMMON data values:
file descriptor variables for the current file and dictionary
name of the file being processed
current record key
current record being processed - as a dynamic array
current data value (the data which will subsequently be output)
number of records processed so far
current values of the field, value and subvalue mark counts
number of detail lines output since the last break line
a value to indicate the current status of the process. One of the following
0 processing a detail line
1 - 15 processing a break line - break level is indicated by the value
127 processing a GRAND-TOTAL line
-1 processing a SORT or SELECT
Example 1
LIST SALES COMMENTS
COMMENTS (in DICT of SALES file)
001 A
002 3
003 Comments
004
Syntax
D{p}{n}{s}
Syntax Elements
p is the special processing operator. Can be any one of the following:
D Returns only the day of the month as a numeric value.
I Returns only dates stored in the external format in internal format. You can use this in field 7 or 8.
J Returns the Julian day (1 - 365, or 1 - 366 for a leap year).
M Returns the number of the month (1 - 12).
MA Returns the name of the month in uppercase letters.
Q Returns the number of the quarter (1 - 4)
W Returns the day of the week as a numeric value (Monday is 1).
WA Returns the day of the week in uppercase letters (MONDAY - SUNDAY).
Y Returns the year (up to four digits).
n is a number from 0 to 4 that specifies the how many digits to use for the year field. If omitted, the year will
have four-digits. If n is 0, the year will be suppressed.
s is a non-numeric character to be used as a separator between month, date, and year. Must not be one of the
special processing operators.
Notes
Dates are stored internally as integers which represent the number of days (plus or minus) from the base date of
December 31, 1967. For example:
Date Stored Value
22 September 1967 -100
30 December 1967 -1
31 December 1967 0
01 January 1968 1
09 April 1968 100
26 September 1967 1000
14 January 1995 9876
If you do not specify a special processing operator (see later) or an output separator, the default output format is
two-digit day, a space, a three-character month, a space, and a four-digit year.
If you specify just an output separator, the date format defaults either to the US numeric format 'mm/dd/yyyy' or
to the international numeric format 'dd/mm/yyyy' (where / is the separator). You can change the numeric format
for the duration of a logon session with the DATE-FORMAT command.
Pre-processor Conversion
Field 8 codes are valid but, generally, it is easier to specify the D code in field 7 for input conversion. Dates in
output format are difficult to use in selection processing.
If you are going to use selection processing and you want to use a code which reduces the date to one of its parts,
such as DD (day of month), the D code must be specified in field 8.
Input/Output Conversion
Field 7 input and output conversions are both valid.
Generally, for selection processing, you should specify D codes in field 7. An exception is when you use a
formatting code, such as DM, that reduces the date to one of its parts.
If no year is specified in the sentence, the system assumes the current year on input conversion. If only the last
two digits of the year are specified, the system assumes the following years:
Examples
D Code Internal Value Value Returned
D 9904 11 FEB 1995
D2/ 9904 11/02/95
D- 9904 11-02-1995
D0 9904 11 FEB
DD 9904 11
DI 11 FEB 1995 9904
DJ 9904 41
DM 9904 2
DMA 9904 FEB
DQ 9904 1
DW 9904 6
DWA 9904 SATURDAY
DY 9904 1995
DY2 9904 95
Syntax
D1;fmcd{;fmcd}...
D2;fmcc
Syntax Elements
fmcd is the field number (FMC) of an associated dependent field.
fmcc is the field number (FMC) of the associated controlling field.
Notes
You can logically group multivalued fields in a record by using a controlling multivalued field and associating
other fields with it. You could, for example, group the component parts of an assembly on an invoice.
The D1 code in field 8 defines the controlling field and nominates the associated dependent fields. Each
dependent field will have a D2 code in field 8.
IMPORTANT: The D1 and D2 codes must be in field 8 of the data definition record and must
be the first code specified. The code can be followed by other codes (separated by a value
mark), but it must be the first code.
The values in the dependent associative fields are output in the order in which they are specified in the field 8 of
the controlling field. The order in which the dependent fields are specified in the output specification clause is
irrelevant.
Dependent fields are marked on the output by an asterisk just below the column heading.
If the output for a controlling field is suppressed, the values in the dependent fields will also be suppressed.
Example
LIST INVOICE ABC123 PARTS QTY PRICE
The records in data file INVOICE have 3 associated, multivalued fields. The fields are named PARTS, QTY and
PRICE, and numbered 7, 2 and 5 respectively.
PARTS is the controlling field because, for each multivalue in this field there will a corresponding value in the
other fields, and also because PARTS should appear first on the report. The data definition record for PARTS
will have D1;2;5 in field 8.
The data definition records for QTY and PRICE will both have D2;7 in field 8.
The report generated by the command will look something like this:
INVOICE PART QTY PRICE
* *
ABC123 AAA 1 10.00
BBB 11 4.00
CCC 2 3.30
... .. ...
Syntax Summary
There are three forms of the F code:
F Uses only the integer parts of stored numbers unless a scaling factor is included. If the JBCEMULATE
environment variable is set to ROS, the operands for -, / and concatenate are used in the reverse
order.
FS Uses only the integer parts of stored numbers.
FE Uses both the integer and fraction parts of stored numbers.
Syntax
F{n};elem{;elem}...
FS;elem{;elem}...
FE;elem{;elem}
Syntax Elements
n is a number from 1 to 9 used to convert a stored value to a scaled integer. The stored value's explicit or implied
decimal point is moved n digits to the right with zeros added if necessary. Only the integer portion of this
operation is returned.
elem is any valid operator. See later.
Notes
F codes use the Reverse Polish notation system. Reverse Polish is a postfix notation system where the operator
follows the operands. The expression for adding two elements is a b +. (The usual algebraic system is an infix
notation where the operator is placed between the operands, for example, a + b).
The F code has operators to push operands on the stack. Other operators perform arithmetic, relational, and
logical operations on stack elements. There are also concatenation and string operators.
Operands that are pushed on the stack may be constants, field values, system parameters (such as data and time),
or counters (such as record counters).
The Stack
F codes work with a pushdown stack.
Operators push values onto the stack, perform arithmetic and other operations on the stack entries, and pop
values off the stack.
The term push is used to indicate the placing of an entry (a value) onto the top of the stack so that existing
entries are pushed down one level. Pop means to remove an entry from the top of the stack so that existing
entries pop up by one level.
Arithmetic functions typically begin by pushing two or more entries onto the stack. Each operation then pops the
top two entries, and pushes the result back onto the top of the stack. After any operation is complete, the result
will always be contained in entry 1.
Order of Operation
F code operations are typically expressed as F;stack2;stack1;operation. Under most emulations, this will be
evaluated as stack2 operation stack1. If JBCEMULATE is set to ROS, this example is evaluated as stack1
operation stack2, effectively reversing the order of operations.
Input Conversion
Input conversion is not allowed.
Example 1
F;C3;C5;-
Push a value of 3 onto the stack. Push a value of 5 onto the stack.
Take entry 1 from entry 2 (3 - 5) and push the result (-2) back onto the stack as entry 1. ROS emulations will
subtract 3 from 5 and return a result of 2.
Example 2
FS;C3;C5;-
Push a value of 3 onto the stack. Push a value of 5 onto the stack.
Take entry 2 from entry 1 (3 - 5) and push the result (-2) back onto the stack. This works in the same way for all
emulations.
Example 3
F;C2;C11;C3;-;/
Push a value of 2 onto the stack. Push a value of 11 onto the stack. Push a value of 3 onto the stack.
Subtract entry 1 from entry 2 (11 - 3) and push the result (8) back onto the stack. Now divide entry 2 by entry 1
(2 divided by 8) and push the result (0) back onto the stack.
Under ROS emulation, this would evaluate as 3 - 11 = -8, followed by -8 / 2 = -4.
Push Operators
A push operator always pushes a single entry onto the stack. Existing entries are pushed down one position. Push
operators are:
literal Literal. Any text string enclosed in double or single quotes.
field-number{R{R}}{(format-code)}
field-number is the value of the field from the current record.
R specifies that the last non-null value obtained from this field is to be applied repeatedly for each
multivalue that does not exist in a corresponding part of the calculation.
RR specifies that the last non-null value obtained from this field is to be applied repeatedly for each
subvalue that does not exist in a corresponding part of the calculation.
(format-code) is one or more format codes (separated by value marks <CTRL ]>) enclosed in
parentheses. Applied to the value before it is pushed onto the stack.
Cn Constant. Where n is a constant (text or number) of any length up to the next semicolon or system
delimiter.
D Current system date.
NA Number of fields in the record.
NB Current break level number:
-1 = during SORT or SELECT processing
0 = detail line
1 = lowest break level
255 = GRAND-TOTAL line
ND Number of records since the last BREAK on a BREAK data line. Equal to the record counter on a
GRAND-TOTAL line. Used to compute averages.
Arithmetic Operators
The arithmetic F code operators work on just the top stack entry or the top two stack entries. They are:
+ Add the top two stack entries together and push result into entry 1.
- Subtract stack entries and push result into entry 1:
F subtract entry 1 from entry 2
FS, FE subtract entry 1 from entry 2
ROS emulation:
F subtract entry 2 from entry 1
*{n} Multiply the top two stack entries and push result into entry 1. If n is specified, the result is
divided by 10 raised to the power of n.
/ Divide stack entries and push quotient into entry 1:
F divide entry 2 by entry 1
FS, FE divide entry 2 by entry 1
ROS emulation:
F divide entry 1 by entry 2
R Compute remainder from the top two stack entries and push result into entry 1:
F remainder of entry 2 / entry 1
FS, FE remainder of entry 2 / entry 1
ROS emulation:
F remainder of entry 1 / entry 2
I Return the integer part of entry 1 to the top of the stack.
S Replace the multivalued entry 1 with the sum of the multivalues and subvalues.
Miscellaneous Operators
Miscellaneous operators control formatting, exchanging stack entries, popping the top entry, concatenation, and
string extraction. They are:
_ Exchange the top two entries.
^ Pop last entry from the stack and discard. All other entries are pushed up.
(format-code) Perform the specified format code on last entry and replace last entry with the result.
: Concatenate stack entries:
F Concatenates Entry 1 to the end of Entry 2
FS, FE Concatenates Entry 1 to the end of Entry 2
ROS emulation:
F Concatenates Entry 2 to the end of Entry 1
[] Extract a substring from stack entry 3. The starting column is specified in stack entry 2 and
the number of characters is specified in entry 1.
Logical Operators
Logical operators include a logical AND test and a logical inclusive-OR test.
Logical operators are:
& AND stack entries 1 and 2. If both entries contain non zero, a 1 is pushed onto stack entry 1,
otherwise, a 0 is pushed.
! OR stack entries 1 and 2. If either of the entries contains non zero, a 1 is pushed onto stack entry
1; otherwise, a 0 is pushed.
Multivalues
A powerful feature of F and FS code operations is their ability to manipulate multivalues. Individual multivalues
can be processed, one-by-one, or you can use the R (or RR) modifier after a field number, to repeat a value and
thus combine it with each of a series of multivalues.
Field operands may be valued and subvalued. When mathematical operations are performed on two multivalued
lists (vectors), the result is also multivalued. The result has an many values as the longer of the two lists. Zeros
are substituted for the null values in the shorter list if the R option is not specified.
Repeat Operators
To repeat a value for combination with multivalues, follow the field number with the R operator. To repeat a
value for combination with multiple subvalues, follow the FMC with the RR operator.
Syntax
f-code{]format-code...}
field-number(format-code{]format-code}...)
(format-code{]format-code}...)
Syntax Elements
f-code is a complete F Code expression.
field-number is the field number in the record from which the data is to be retrieved.
format-code is any valid format codes.
] represents a value mark <CTRL ]> that must be used to separate each format-code.
Notes
To process a field before it is pushed on the stack, follow the FMC with the format codes enclosed in
parentheses.
To process the top entry on the stack, specify the format codes within parentheses as an operation by itself.
To specify more than one format code in one operation, separate the codes with the value mark, <CTRL ]>.
All format codes will convert values from an internal format to an output format.
Example
F;2(MD2]G0.1);100;-
Obtain the value of field 2. Apply an MD2 format code. Then apply a group extract to acquire the integer
portion of the formatted value, and push the result onto the stack. Subtract 100 from the field 2 value. Return this
value. Note that under ROS emulation, the value returned would be the result of subtracting the integer value
from the group extract, from 100. In other words:
100 - OCONV(OCONV(Field2, MD2), G0.1).
Syntax
G{m}xn
Syntax Elements
m is the number of strings to skip. If omitted or zero, extraction begins with the first character.
x is the separation character.
n is the number of strings to be extracted.
Notes
The field value can consist of any number of strings, each separated by the specified character. The separator can
be any non-numeric character, except a system delimiter.
If m is zero or null and the separator x is not found, the whole field will be returned. If m is not zero or null and
the separator x is not found, null will be returned.
Input Conversion
Input conversion does not invert. It simply applies the group extraction to the input data.
Example 1
G0.1
If the field contains 123.45, 123 will be returned. You could also use G.1 to achieve the same effect.
Example 2
G2/1
If the field contains ABC/DEF/GHI, GHI will be returned.
Example 3
G0,3
If the field contains ABC,DEF,GHI,JKL, ABC,DEF,GHI will be returned. Note that the field separators are
included in the returned string.
Syntax
L{{min,}max}
Syntax Elements
min specifies that the process is to return an element if its length is greater than or equal to the number min.
max specifies that the process is to return an element if its length is less than or equal to the number max.
Notes
The L code by itself returns the length of an element.
When used with max, or min and max, the L code returns the element if it is within the length specified by min
and/or max.
Input Conversion
Input conversion does not invert. It simply applies the length processing to the input data.
Example 1
L
Assuming a value of ABCDEF, returns the length of the value - in this case, 6.
Example 2
L4
If JBCEMULATE is set to ROS, L4 is translated as return the value if its length is less than or equal to 4 - the
equivalent of L0,4. Assuming a value of ABCDEF, L4 will return null - the value is longer than 4 characters.
If JBCEMULATE is not set to ROS, L4 is translated as return the value if its length is exactly equal to 4 - the
equivalent of L4,4. Assuming a value of ABCDEF, L4 will return null - the value is longer than 4 characters.
Example 3
L4,7
L4,7 is translated as return the value if its length is greater than or equal to 4 and less than or equal to 7.
Assuming a value of ABCDEF, L4,7 will return ABCDEF.
Summary
MC codes are:
MCA Extract only alphabetic characters
MC/A Extract only non-alphabetic characters.
MCAB{S} Convert ASCII character codes to binary representation. Use S to suppress spaces.
MCAX or MX Convert ASCII character codes to hexadecimal representation.
MCB Extract only alphabetic and numeric characters.
MC/B Extract only special characters that are neither alphabetic nor numeric.
MCBA Convert binary representation to ASCII characters.
MCBX Convert a binary value to its hexadecimal equivalent.
MCC;x;y Change all occurrences of character string x to character string y.
MCDR Convert a decimal value to its equivalent Roman numerals. Input conversion is effective.
MCDX or MCD Convert a decimal value to its hexadecimal equivalent. Input conversion is effective.
MCL Convert all upper case letters (A-Z) to lower case.
MCN Extract only numeric characters (0-9).
MC/N Extract only non-numeric characters.
MCNP{c} Convert paired hexadecimal digits preceded by a tilde or character c to ASCII code.
MCP{c} Convert each non-printable character (X'00' - X'IF', X'80' - X'FE') to a tilde (~) or to character
c.
MCPN{c} Same as MCP but insert the two-character hexadecimal representation of the character
immediately after the tilde or character c.
MCRD or MCR Convert Roman numerals to the decimal equivalent. Input conversion is effective.
MCT Convert all upper case letters (A-Z) in the text to lower case, starting with the second character
in each word. Change the first character of each word to upper case if it is a letter.
MCU Convert all lower case letters (a-z) to upper case.
MCXA or MY Convert hexadecimal representation to ASCII characters.
MCXB{S} Convert a hexadecimal value to its binary equivalent. Use S to suppress spaces between each
block of 8 bytes.
MCXD or MCX Convert a hexadecimal value to its decimal equivalent. Input conversion is effective.
Input Conversion
Input conversion does not invert. The conversion code will be applied to the input data.
Example 1
MCL
Assuming a source value of AbCdEf, MCL will return abcdef.
Example 2
MCT
Assuming a source value of AbC dEf ghi, MCT will return Abc Def ghi.
Example 3
MCU
Assuming a source value of AbCdEf, MCU will return ABCDEF.
Extracting Characters
The MC codes that can be used to extract characters from a string are:
MCA Extract only alphabetic characters.
MC/A Extract only non-alphabetic characters.
MCB Extract only alphanumeric characters.
MC/B Extract only special characters that are neither alphabetic nor numeric.
MCN Extract only numeric characters (0-9).
MC/N Extract only non-numeric characters.
Input Conversion
Input conversion does not invert. The original code will be applied to input data.
Example 1
MCA
Assuming a source value of ABC*123!DEF, MCA will return ABCDEF.
Example 2
MC/A
Assuming a source value of ABC*123!DEF, MC/A will return *123!.
Example 3
MCB
Assuming a source value of ABC*123!DEF, MCB will return ABC123DEF.
Example 5
MCN
Assuming a source value of ABC*123!DEF, MCN will return 123.
Example 6
MC/N
Assuming a source value of ABC*123!DEF, MC/N will return ABC*!DEF.
Replacing Characters
Some MC codes replace one set of characters with other characters. These codes can:
exchange one character string for another;
replace non-printable characters with a marker character;
replace non-printable characters with a marker character and the character's hexadecimal
representation;
replace the marker and hexadecimal representation with the ASCII code.
The codes are:
MCC;x;y Change all occurrences of character string x to character string y.
MCP{c} Convert each non-printable character (X'00' - X'IF', X'80' - X'FE') to character c, or tilde (~) if c is
not specified.
MCPN{c} Same as MCP but insert the two-character hexadecimal representation of the character
immediately after character c, or tilde (~) if c is not specified..
MCNP{c} Convert paired hexadecimal digits preceded by a tilde or character c to ASCII code. The opposite
of the MCPN code.
Input Conversion
Input conversion does not invert. The original code will be applied to input data.
Example 1
MCC;X5X;YYY
Assuming a source value of ABC*X5X!DEF, MCC will return ABC*YYY!DEF.
Example 2
MCPN.
Assuming a source value of ABC]]DEF where ] represents a value mark, <CTRL ]>, MCPN will return
ABC.FC.FCDEF.
Converting Characters
The MC codes that convert ASCII character codes to their binary or hexadecimal representations or vice versa
are:
MCAB{S} Convert ASCII character codes to binary representation (Use S to suppress spaces).
MCAX or MY Convert ASCII character codes to hexadecimal representation
MCBA Convert binary representation to ASCII characters.
MCXA or MX Convert hexadecimal representation to ASCII characters.
Input Conversion
Input conversion does not invert. The original code will be applied to input data.
Example 1
MCAX
Assuming a source value of ABC, MCAX will return 414243.
Example 2
MCXA
Assuming a source value of 414243, MCXA will return ABC.
Example 3
MCAB
Assuming a source value of AB, MCAB will return 01000001 01000010.
Example 4
MCABS
Assuming a source value of AB, MCABS will return 0100000101000010.
Example 5
MCBA
Assuming a source value of 01000001 1000010, MCBA will return AB. Note the missing binary digit at the start
of the second element of the source value.
Example 6
MCBA
Assuming a source value of 0100000101000010, MCBA will return AB.
Input Conversion
Input conversion is effective for MCDR, MCDX, MCRD and MCXD.
Input conversion is not inverted for the other codes. The original code will be applied to input data.
Example 1
MCBX
Assuming a source value of 01000001 1000010, MCBX will return 4142. Would return the same value if there
was no space between the binary source elements.
Example 2
MCRD
Assuming a source value of MLXVI, MCRD will return 1066.
Example 3
MCDX
Assuming a source value of 1066, MCDX will return 42A.
Syntax
MDn{m}{Z}{,}{$}{ix}{c}
Syntax Elements
n is a number from 0 to 9 that specifies how many digits are to be output after the decimal point. Trailing zeros
are inserted as necessary. If n is omitted or 0, the decimal point is not output.
m is a number from 0 to 9 which represents the number of digits that the source value contains to the right of the
implied decimal point. m is used as a scaling factor and the source value is descaled (divided) by that power of
10. For example, if m=1, the value is divided by 10; if m=2, the value is divided by 100, and so on.
If m is omitted, it is assumed to be equal to n (the decimal precision). If m is greater than n, the source value is
rounded up or down to n digits. The m option must be present if the ix option is used and both the Z and $
options are omitted. This to remove ambiguity with the ix option.
Z suppresses leading zeros. Note that fractional values which have no integer will have a zero before the decimal
point. If the value is zero, a null will be output.
, specifies insertion of the thousands separator symbol every three digits to the left of the decimal point. The type
of separator (comma or period) is specified through the SET-THOU command. (Use the SET-DEC command to
specify the decimal separator.)
$ appends an appropriate currency symbol to the number. The currency symbol is specified through the SET-
MONEY command.
ix aligns the currency symbol by creating a blank field of 'i' number of columns. The value to be output
overwrites the blanks. The 'x' parameter specifies a filler character that can be any non-numeric character,
including a space.
c appends a credit character or encloses the value in angle brackets (< >). Can be any one of the following:
- Appends a minus sign to negative values. Positive or zero values are followed by a blank.
C Appends the characters CR to negative values. Positive or zero values are followed by two blanks.
< Encloses negative values in angle brackets (< >).
Input Conversion
Input conversion works with a number that has only thousands separators and a decimal point.
Examples
MD Code Source Value Returned Value
MD2 1234567 12345.67
MD2, 1234567 12,345.67
MD2,$ 1234567 12,345.67
MD2,$12* 1234567 **12,345.67
MD2,$12 - -1234567 12,345.67-
MD42Z,$ 001234567 12,345.6700
MD42Z,$15 < -001234567 < 12,345.6700>
Syntax
MKn
Syntax Elements
n is a number that represents the field width. This will include the letter and a minus sign, if present.
Notes
If a number will fit into the specified field width, it will not be changed.
If the number is too long but includes a decimal fraction, the MK code first attempts to round the fractional part
so that the number will fit the field. If the number is still too long, the code rounds off the three low-order integer
digits, replacing them with a K. If the number is still too long, the code rounds off the next three digits, replacing
them with an M. If that is still too long, the code rounds off three more digits, replacing them with a G. If the
number still does not fit the specified field, the code displays an asterisk.
If the field size is not specified or is zero, the code outputs null.
Input Conversion
Input conversion does not invert. It simply applies the metric processing to the input data.
Examples
Code/Output
Source Data MK3 MK4 MK5 MK7
1234 1K 1234 1234 1234
123456789 * 123M 123M 123457K
123456789012345 * * * 123457G
999.9 1K 1000 999.9 999.9
-12.343567 -12 -12 -12.3 -12.344
-1234.5678 -1K -1K -1235 -1234.6
-0.1234 -.1 -.12 -.123 -0.1234
Syntax
ML{n{m}}{Z}{,}{c}{$}{fm}
MR{n{m}}{Z}{,}{c}{$}{fm}
Syntax Elements
ML provides left justification of the result.
MR provides right justification of the result.
n is a number from 0 to 9 that defines the decimal precision. Specifies the number of digits to be output
following the decimal point. The processor inserts trailing zeros if necessary. If n is omitted or is 0, a decimal
point will not be output.
m is a number that defines the scaling factor. The source value is descaled (divided) by that power of 10. For
example, if m=1, the value is divided by 10; if m=2, the value is divided by 100, and so on. If m is omitted, it is
assumed to be equal to n (the decimal precision).
Z suppresses leading zeros. Note that fractional values which have no integer will have a zero before the decimal
point. If the value is zero, a null will be output.
, is the thousands separator symbol. It specifies insertion of thousands separators every three digits to the left of
the decimal point. You can change the display separator symbol by invoking the SET-THOU command. (Use the
SET-DEC command to specify the decimal separator.)
c appends a credit character or encloses the value in angle brackets (< >). Can be any one of the following:
C Print the literal CR after negative values.
D Print the literal DB after positive values.
E Enclose negative values in angle brackets <>.
M Print a minus sign after negative values.
N Suppresses embedded minus sign.
If a value is negative and you have not specified one of these indicators, the value will be displayed with a
leading minus sign. If you specify a credit indicator, the data will be output with either the credit characters or an
equivalent number of spaces, depending on its value.
$ specifies that a currency symbol is to be included. A floating currency symbol is placed in front of the value.
The currency symbol is specified through the SET-MONEY command.
fm specifies a format mask. A format mask can include literal characters as well as format codes. The format
codes are as follows:
Code Function
#{n} Spaces. Repeat space n times. Output value is overlaid on the spaces created.
*{n} Asterisk. Repeat asterisk n times. Output value is overlaid on the asterisks created.
%{n} Zero. Repeat zeros n times. Output value is overlaid on the zeros created.
Notes
The justification specified by the ML or MR code is applied at a different stage from that specified in field 9 of
the data definition record. The sequence of events starts with the data being formatted with the symbols, filler
characters and justification (left or right) specified by the ML or MR code. The formatted data is then justified
according to field 9 of the definition record and overlaid on the output field - which initially comprises the
number of spaces specified in field 10 of the data definition record.
Input Conversion
Input conversion works with a number that has only thousands separators and a decimal point.
Examples
Source DDR Fields Returned Value (Columns)
Code Value 9 10 12345678901234567890
MR2#10 1234 L 15 12.34
MR2#10 1234 R 15 12.34
ML2%10 1234 L 15 12.3400000
MR2%10 1234 R 15 0000012.34
ML2*10 1234 L 15 12.34*****
MR2*10 1234 R 15 *****12.34
MR2,$#15 12345678 L 20 123,456.78
MR2,&$#15 12345678 L 20 123,456.78
ML2,&*$#15 12345678 L 20 123,456.78*****
MR2,& $#15 12345678 L 20 123,456.78
MR2,C&*$#15 -12345678 L 20 ***123,456.78CR
ML& ###-##-#### 123456789 L 12 123-45-6789
ML& #3-#2-#4 123456789 L 12 123-45-6789
ML& Text #2-#3 12345 Text 12-345
ML&((Text#2) #3) 12345 (Text12) 345
In the last example, the leading and trailing parenthesis are ignored.
Syntax
MP
Notes
The MP code most often used as an output conversion. On input, the MP processor combines pairs of 8-bit
ASCII digits into single 8-bit digits as follows:
The high order four bits of each ASCII digit are stripped off.
The low order four bits are moved into successive halves of the stored byte.
A leading zero will be added (after the minus sign if present) if the result would otherwise yield an
uneven number of halves.
Leading plus signs (+) are ignored.
Leading minus (-) signs are stored as a four-bit code (D) in the upper half of the first internal digit.
When displaying packed decimal data, you should always use an MP or MX code. Raw packed data is almost
certain to contain control codes that will upset the operation of most terminals and printers.
Input Conversion
Input conversion is valid. Generally, for selection processing you should specify MP codes in field 7 of the data
definition record.
Examples
OCONV -1234 MP
yields 0x D01234
ICONV 0x D01234 MP
yields -01234
Syntax
MS
Notes
Use of the MS code is only relevant when used in a field 8 pre-process code and applied to a field that is
specified in a sort clause. In all other cases it will be ignored.
The sort sequence to be used is defined in a special record named SEQ that you must create in the ERRMSG
file. Field 1 of this record contains a sequence of ASCII characters that define the order for sorting.
Example
SEQ (defined in ERRMSG file)
001 aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY
zZ9876543210 ,.?!;:+-*/^=()[]{}<>@#$%&`~\|
INV.CODE (data definition record)
001 A
.
.
008 MS
Syntax
MT{H}{S}
Syntax Elements
H specifies 12-hour format. If omitted, 24-hour format will be used.
S specifies that seconds are to be included.
Notes
Time is stored internally as the number of seconds since midnight. The stored value can be output in 12 hour or
24 hour (international) format.
12:00PM is defined as noon and 12:00AM is defined as midnight.
For output conversions, AM and PM designators are automatically displayed. For example: 09:40AM and
06:30PM.
Input Conversion
Input conversion is valid. Generally, for selection processing you should specify MT codes in field 7 of the data
definition record.
AM or PM designators are taken into account.
Examples
Input Conversion
Code Input Result
MT 00:00 0
MTH 12:00AM 0
MT 01:00AM 3600
MT 01:00 3600
MTH 01:00 3600
MTH 01:00AM 3600
MT 01:00PM 46800
MTH 01:00PM 46800
MTS 01:00:30 3630
Output Conversion
Code Source Value Result
MTS 0 00:00:00
MTHS 0 12:00:00AM
MT 3600 01:00
MTH 3600 01:00AM
MT 46800 13:00
MTS 46800 13:00:00
MTH 46800 01:00PM
MTHS 46800 01:00:00PM
Syntax
P{#}(element){;(element)}...
Syntax Elements
# returns null if the source matches the pattern, or the source if it does not.
element is one or more of the following:
nA tests for n alphabetic characters
nC tests for n alphabetic or numeric characters
nN tests for n numeric characters
nP tests for n printable characters
nX tests for n characters
literal tests for the presence of the literal.
Notes
If the value does not match any of the patterns, a null will be returned.
Input Conversion
Input conversion does not invert. It simply applies the pattern matching to the input data.
Example 1
P(2A*3N/2A)
Will match and return AA*123/BB or xy*999/zz. Will fail to match AAA*123/BB or A1*123/BB, and will
return null.
Example 1
P(2A*3N/2A);(2N-2A)
Will match and return AA*123/BB, xy*999/zz, 99-AA or 10-xx. Will fail to match AA&123/BB, A1*123/BB,
9A-AA or 101-xx, and will return null.
Syntax
Rn,m{;n,m}...
Syntax Elements
n is the starting integer of the range. Can be positive or negative.
m is the ending integer of the range. Can be positive or negative, but must be equal to or greater than n.
Notes
If the value does not fall within the range(s), a null will be returned.
Input Conversion
Input conversion does not invert. It simply applies the range check to the input data.
Example 1
R1,10
Will return any value that is greater than or equal to 1 and less than or equal to 10.
Example 2
R-10,10
Will return any value that is greater than or equal to -10 and less than or equal to 10.
Example 3
R-100,-10
Will return any value that is greater than or equal to -100 and less than or equal to -10.
Syntax
S;Var1;Var2
Syntax Elements
Var1 specifies the value to be substituted if the referenced value is not null or zero. Can be a quoted string, an
FMC (field number), or an asterisk. An asterisk indicates that the value of the referenced field should be used.
Var2 specifies the value to be substituted if the referenced value is null or zero. Can be a quoted string, an FMC
(field number), or an asterisk.
Example 1
S;*;NULL VALUE!
If the referenced field is null, this example will return the string NULL VALUE!. Otherwise it will return the
referenced value.
Example 2
S;*;3
If the referenced field is null, this example will return the content of field 3 of the data record. Otherwise it will
return the referenced value.
Example 3
S;4;5
If the referenced field is null, this example will return the content of field 5 of the data record. Otherwise it will
return the content of field 4.
Syntax
T{m,}n
Syntax Elements
m specifies the starting column number.
n is the number of characters to be extracted.
Notes
If m is specified, the content of field 9 of the data definition record has no effect - characters are counted and
extracted from left to right, for n characters.
If m is not specified, the content of field 9 of the data definition record will control whether n characters are
extracted from the left or the right-hand end of the value. If field 9 does not contain an R, the first n characters
will be extracted from the value. If field 9 does contain an R (right justify), the last n characters will be extracted
from the value.
Input Conversion
Input conversion does not invert. It simply applies the text extraction to the input data.
Examples
Source DDR
Code Value Field 9 Result
T3,4 ABCDEFG L CDEF
T3,4 ABCDEFG R CDEF
T2 ABCDEFG L AB
T3 ABCDEFG R EFG
T3 ABCDEFG T ABC
Syntax
T[*|DICT]file-specifier;c{n};{i-fmc};{o-fmc}
Syntax Elements
* or DICT indicates that the dictionary of the specified file is to be used, rather than the data section.
file-specifier identifies the reference file by name in the format file-name{,data-section-name}.
c specifies a translation code. Can be any one of the following:
C If reference record does not exist or the specified FMC is null, output the value unchanged.
I Input verify. Functions as a C code for output and as a V code for input.
O Output verify. Functions as a C code for input and as a V code for output.
V Reference record must exist and the specified FMC must contain a translatable value. If the
record does not exist or the FMC contains a null, an error message will be output.
X If reference record does not exist or the specified FMC is null, return a null.
n specifies a value mark count to return one specific value from a multivalued field. If omitted, all values are
returned.
i-fmc is the field number for input translation. If omitted or the value is null, no input translation takes place.
o-fmc is the field number for output translation. If the value is null, no output translation takes place.
Notes
The current data value is used as the record key for searching the specified reference file.
A data field, or a single value from a data field, is returned from the record.
Tfile codes can be used in fields 7 or 8 of the data definition record. Use field 8 if translation of a multivalued
field or comparisons and sorts are required.
If selection criteria might be applied, you can either use field 8, or you can use field 7 and set up special records
in the reference file to perform any input translation you require.
The special records in the reference file have as record keys values that the field subject to translation may be
compared with in a jQL sentence. Field i-fmc within these records contains the translate value that will be
compared to values on file. Typically, values in a jQL sentence are output values, so that the special input
translation records are effectively the inverse of the output translation records.
Tfile codes can be embedded in other conversion codes but you must still follow the syntactical conventions of
the host code. For example, if you include a Tfile code in an F code conversion, the Tfile code must be
enclosed in parentheses.
Input/Output Conversion
Output conversion is valid. The Tfile code has a parameter (o-fmc) that specifies the field in the translation
record to use for output conversion.
Input conversion is valid. The Tfile code has a parameter (i-fmc) that specifies the field in the translation record
to use for input conversion.
Example 1
TSALES;X;;2
Using this Tfile code in field 8 of a data definition record, which also has a 0 in field 2, will cause the key of the
current record to be used as the key when accessing the reference file SALES. If the record cannot be found, a
null will be returned. If the record is found, the value of field 2 will be returned.
Example 3
A;3(TSALES;X;;2)
Using this embedded Tfile code in field 8 of a data definition record will cause field 3 of the current record to be
used as the key when accessing field 2 of the reference file SALES. If the record cannot be found a null will be
returned. If the record is found, the value of field 2 will be returned.
Syntax
Uxxxx
Syntax Elements
xxxx is the hexadecimal identity of the routine.
Notes
jBASE user exits are customised routines specially produced to perform extraordinary processing.
Input Conversion
Routine dependent.
COPY-LIST
Copies a saved list to another list or to another file.
Syntax
COPY-LIST {from_listname} {from_accountname} {(options}
TO: {to_spec}
Syntax Elements
from_listname specifies the source list. If you do not specify from_listname, the default list will be used.
from_ accountname specifies the source account if different to the current account.
options can be one or more of the following:
O Overwrite destination list or record if it already exists.
D Delete source list after successfully copying it.
L Synonymous with S option.
N Suppresses auto paging. Only used with T.
P Sends the list to the printer.
S Suppresses line numbers. Only used with T or P.
T Sends the list to the screen.
X Outputs in hexadecimal notation. Only used with T or P.
to_spec specifies the destination list. Can be:
{to_listname} {to_accountname}
or
({DICT }to_filename {to_record_key}
Use the first variant if you want to copy the list or change the account its attached to.
Use the second variant if you want to copy the list to a data file Each key becomes a separate field in the
list record. Note use of the left parenthesis before to_filename.
If you do not specify to_spec, the list will be copied to the default list.
Example 1
: COPY-LIST A.SALES (O
TO: B.SALES
List A.SALES copied to 'B.SALES'
Copies A.SALES (a previously saved list) to B.SALES, and overwrites if necessary.
Example 2
: COPY-LIST A.SALES
TO: A.SALES ACCOUNTS
List A.SALES copied to 'A.SALES ACCOUNTS'
Example 3
: COPY-LIST A.SALES
TO: (SALES.LISTS APRIL.SALES
List A.SALES written to record 'APRIL.SALES' in file SALES.LISTS
Copies A.SALES (a previously saved list) to record APRIL.SALES, in file SALES.LISTS.
DELETE-LIST
Deletes a saved list.
Syntax
DELETE-LIST {listname {account-name}}
Syntax Elements
listname specifies the name of the list to be deleted. If you do not specify listname, the default list will be
deleted.
account-name is the name of the account from which the list was saved. If you do not specify account-name, the
current account is assumed.
Example
: DELETE-LIST A.SALES
List 'A.SALES' deleted
EDIT-LIST
Invokes an ED editor session to allow you to create, modify, merge or delete a select list.
Syntax
EDIT-LIST {list-name {account-name}} {(options}
Syntax Elements
list-name specifies the name of the list to be edited. If the list does not already exist it will be created. If you do
not specify a list name, the default list will be used.
account-name is the name of the account from which the list was saved. If you do not specify account-name, the
current account name will be used.
options can be:
ED=editor editor is the name of the editor you want to use. Default is ED.
Notes
The EDIT-LIST command is used when you want to edit the contents of a new or existing saved list. The
command will convert the list into an editable record and pass it to the editor. When the edit session is finished,
the record will be reconverted to a list and stored under its original name.
You can specify an editor other than ED by naming the editor in the ED option.
Example
EDIT-LIST A.SALES
.jBASE.el.portnumber
TOP
FORM-LIST
Creates a select list from a record in a file.
Syntax
FORM-LIST filename record-key {(n}
Syntax Elements
filename is the name of the file which contains record-key.
record-key is the name of the record to be converted into a select list.
n is the field number in the record from which the list is to start. If n is omitted the list will start from field 1.
Notes
If you issue the FORM-LIST command without specifying a record key, you will be prompted to supply one.
The command will open file filename, read the record record-key and create a select list using each field in the
record as a separate element for the list. The list formed becomes the active select list and will be inherited by
the next jBASE command or program.
Examples
:FORM-LIST SALES.LISTS APRIL.SALES
200 records SELECTED
>LIST CUSTOMERS
A record named APRIL.SALES in file SALES.LISTS contains a list of customer keys. Each key occupies a
separate field. The FORM-LIST command generates an active list of customers. You can then issue a subsequent
command such as LIST CUSTOMERS which will use the active list .
GET-LIST
Retrieves a previously stored list from the common area and makes it the current active (default) list.
Syntax
GET-LIST {list-name {account-name}}
Syntax Elements
list-name specifies the name of the list to be retrieved. If you do not specify a list name, the default list will be
used.
account-name is the name of the account from which the list was saved. If you do not specify account-name, the
system will use the current account name.
Notes
The GET-LIST command is used to retrieve a list previously stored using the SAVE-LIST command. If the list
is retrieved successfully, it will become the current active (default) list and will be inherited by the next jBASE
command or program.
Example
:GET-LIST A.SALES
200 Records selected
>LIST SALES
LIST-LISTS
Displays a list of all select lists currently available in the common area.
Syntax
LIST-LISTS
NEW-GET-LIST
Retrieves a previously stored list from a file or the common area and makes it the current active (default) list.
Syntax
NEW-GET-LIST {file-name} list-name
Syntax Elements
file-name specifies the name of the file which contains the saved list. If you do not specify a file-name the system
will use the common area.
list-name is the name of the saved list.
Notes
The NEW-GET-LIST command is used to retrieve a list previously saved to a file using the NEW-SAVE-LIST
command. If the list is retrieved successfully, it will become the current active (default) list and will be inherited
by the next jBASE command or program.
Example
:NEW-GET-LIST SALES.LISTS APRIL.SALES
200 records selected
>LIST CUSTOMERS
Retrieves a list named APRIL.SALES from file SALES.LISTS and generates an active list. You can then issue a
subsequent command such as LIST CUSTOMERS which will use the active list .
NEW-SAVE-LIST
Saves a list to a specified file and leaves the list as the active list.
Syntax
NEW-SAVE-LIST file-name list-name
Syntax Elements
file-name specifies the name of the file which is to contain the list.
list-name is the name (key) of the saved list.
Notes
If the specified list already exists, it will be overwritten.
Example
:FORM-LIST SALES.LISTS APRIL.SALES
200 records selected
>SELECT CUSTOMERS WITH POST.CODE = MK]
NEW-SORT-LIST
Sorts a list previously saved by NEW-SAVE-LIST.
Syntax
NEW-SORT-LIST file-name list-name
Syntax Elements
file-name is the name of the file which contains the saved list.
list-name is the name (key) of the saved list.
Example
>SELECT CUSTOMERS WITH POST.CODE = MK]
400 records selected
>NEW-SAVE-LIST SALES.LISTS SALES.MK
>NEW-SORT-LIST SALES.LISTS SALES.MK
:
QSELECT
Generates a select list from the fields of specified items and makes it the current active (default) list.
Syntax
QSELECT {{file-name} record-list} {(n}
Syntax Elements
file-name specifies the source file name.
record-list is a list of record keys, or an asterisk (*) to signify all records.
n is the field number in each record, from which the list is to be created. If n is not specified, all the fields in the
source records will be used to generate the list elements.
Notes
If you issue the QSELECT command without specifying an record list, you will be prompted to supply one.
QSELECT is similar to the FORM-LIST command but has the additional capability of creating a list from more
than one source record. Also, FORM-LIST creates a list from all the attributes of a single record, QSELECT can
create a list from multiple records, and you can specify that each record is only to contribute one field.
Example 2
:QSELECT SALES ABC DEF GHI (3
3 records selected
>SAVE-LIST CUSTOMERS
Creates a list containing the values from field 3 of records ABC, DEF and GHI in the SALES file. The list is
then saved as CUSTOMERS.
SAVE-LIST
Saves the currently active select list to a named list record.
Syntax
SAVE-LIST {list-name}
Syntax Elements
list-name specifies the name under which the list is to be stored. If you do not specify a list name, the default list
will be used
Notes
The SAVE-LIST command is used to store the currently active (default) select list under a permanent list name.
If the specified list name already exists, it will be overwritten.
Example
:SSELECT CUSTOMERS WITH POST.CODE = MK]
40 records selected
>SAVE-LIST CUSTOMERS.MK
:
Sorts and selects records from the CUSTOMER file which have a POST.CODE value that starts with MK. Saves
the list as CUSTOMERS.MK.
SEARCH Command
The SEARCH command is used to create a list of all records in a file which contain one or more text sequences.
Syntax
SEARCH filename
Fist String to search for : string
Second String to search for : string
...
Syntax Elements
filename is the name of the file to be searched.
Notes
The SEARCH command will scan the file specified by filename looking for records which contain the specified
text string(s). If it finds any records that match the criteria, it will create a select list containing the record keys.
This list then becomes the default select list and will be inherited by the next jBASE command or program.
SORT-LIST
Sorts a saved select list.
Syntax
SORT-LIST {list-name{account-name}}
Syntax Elements
list-name specifies the name under which the list is to be stored.
account-name is the name of the account from which the list was saved. If you do not specify account-name, the
system will use the current account name.
Notes
The SORT-LIST command will sort a list previously saved with the SAVE-LIST command.
SORT-LIST is useful for sorting lists which have modified by EDIT-LIST, or for avoiding an extra SSELECT
when working with a large file.
Example
:SELECT CUSTOMERS
4000 records selected
>SAVE-LIST CUSTOMERS.MK
:SORT-LIST CUSTOMERS.MK
Selects records from the CUSTOMER file which have a POST.CODE value that starts with MK. Saves the list
as CUSTOMERS.MK and then sorts it using the SORT-LIST command.
XSELECT
Generates a select list (or display) of all keys in a file which do not match given selection criteria.
Syntax
XSELECT file-name
Syntax Elements
file-name specifies the name of the file to be searched.
Notes
If you issue the XSELECT command while a select list is active, the process will return with a list of all the
records in the file which are not in the active list.
If you issue the XSELECT command without an active select list, you will be prompted initially for the name of
a saved list to use. If you supply a list name the process will return with a list of all the records in the file which
are not in the named list. If you do not supply a list name but press <RETURN> to this prompt, you will be
asked to supply selection criteria (in normal jQL format) which will identify all the records in the file that you do
not want in the returned list.
Example 1
:GET-LIST CUSTOMERS.MK
>XSELECT CUSTOMERS
Input save list name: CUSTOMERS.NOT.MK
GET-LIST makes the CUSTOMERS.MK list active. XSELECT then creates a list of all the records in the
CUSTOMERS file which are not in the active list, and save it as CUSTOMERS.NOT.MK.
Example 2
:XSELECT CUSTOMERS
Input list name: CUSTOMERS.MK
Input save list name: CUSTOMERS.NOT.MK
XSELECT first prompts for the name of a list to use. It then creates a list of all the records in the CUSTOMERS
file which are not in the specified list, and save the new list as CUSTOMERS.NOT.MK.
Example 3
:XSELECT CUSTOMERS
Input list name: <RETURN>
Input selection criteria: WITH POST.CODE = MK]
Input save list name: CUSTOMERS.NOT.MK
XSELECT first prompts for the name of a list to use. Because a list name is not supplied, it prompts for the anti-
selection criteria to use. A list is then created which contains all the keys of the CUSTOMERS file where the
records do not match the selection criteria. The new list is saved as CUSTOMERS.NOT.MK.
Editor Screen
A typical jED editor session might look like this:
*File PROGS, Record cust_rep.b Insert 10:45:55
Command->
001
002
003
-----------------End of Record--------------------------------------
The screen is divided into three sections; the editor status line at the top, followed by the command line and then
the data editing area which fills the rest of the screen.
Invoking jED
Call the jED editor from the UNIX command line.
Syntax
jed pathname {pathname..}
jed {DICT} filename{,filesection} {record-list} {(options)}}
If you simply issue the command jed, the editor will open the last file that was used, and the cursor will be
positioned wherever it was when the last edit session was closed. In other words, you can carry on from exactly
where you left off.
The command, jed pathname, will either open an existing file or create a new one if the file referenced by
pathname does not exist. The will contents of the file will be displayed in the edit window. If you specify a list
files, the editor will present the next file as you finish with each one.
When the editor is supplied with the name of a file resident in a database (such as a j-file), it scans the rest of the
command line looking for a list of records keys. If no record keys were specified, the jED editor will prompt for
a list. Otherwise the list of record keys will be edited one after the other.
Note that because the editor uses the jEDI interface to access the records, it can be used to edit records in any
file system that jEDI recognises.
Examples
jed test.b
Opens the test.b file for editing, initially in insert mode with automatic indentation turned on. If the file does not
exist, it is created and the text New Record is shown at the top of the screen.
jed test.b (B5,2
The jBC program test.b is edited with automatic indentation set. The initial indent is set at 10 spaces for all lines,
and each additional indentation level is set at 5 spaces.
jed invoices.b subs.c
The jBC program invoices.b will be edited, followed by the 'C' program subs.c.
jed BP menu1.b menu1.1.b
The jBASE file records menu1.b and menu1.1.b are successively edited. Record locks are taken on the records
as they are edited to prevent multiple edits on the same record.
JED ORDERS 0012753 0032779 (R
The records 0012753 and 0032779 from the file ORDERS will be successively edited in read-only mode.
:SSELECT ORDERS WITH CUST.NAME = "UPA"
>JED ORDERS
The orders of the customer UPA will be successively edited in sorted order. Record locks will be automatically
set during the editing period to prevent simultaneous updates by other users.
jed -F BP \*
Command Mode
When the editor is invoked, the record or text file is displayed, and the user is placed in input mode with the
cursor at the input position.
To change to command mode simply press the <ESC> key on the keyboard.
The cursor now moves to the top portion of the screen and the editor awaits input of a command. Once a valid
command has been executed, control passes back to the Edit mode if appropriate.
Edit Mode
Edit mode is used when entering or modify data. This is the default mode for an editor session.
Keyboard control sequences are available to perform a variety of functions such as cursor positioning, scrolling
and marking text for a subsequent action.
Some command line operations are also available from keyboard control sequences.
Keyboard Personalisation
The jED editor allows a considerable number of functions and commands to be performed whilst in edit mode,
mostly by combining the <CTRL> key and one other key.
Most keys have a default value (which can be reset using the E option when invoking jED). These can be
reconfigured for each command. The keystroke sequence can be chosen to suit the keyboard, the installation
environment or personal preference.
The keystroke environment is usually be set up by modifying the UNIX terminfo file parameters. This is
described in more detail later in the chapter.
Command Options
R specifies that, after the file has been written to disk, it should be executed. Additional parameters can be added
to this option and passed to the program. The editor issues the command filename {parameters} to execute the
program. Note that the .b suffix is removed.
K or T option specifies that if the editor was working from a list of records, the list should be discarded and that
the editor should exit directly to the shell (or to the calling process).
O specifies that the confirmation request normally issued with the FD and EX commands should be suppressed.
The R option is particularly useful to jBC programmers.
Examples
FIK
Exits the record and writes it to disk. If in the middle of a list of records being edited, the list is abandoned and
the editing session is terminated.
FDO
Delete the current record being edited. The normal confirmation of this action is not given.
Locating Strings
The editor allows the user to search and locate any string held in the body of the text being edited.
There is also a keystroke command sequence (default <CTRL N>) to allow the user to find the next occurrence
of the string used in the previous locate command.
The locate command syntax is as follows:
L{nnn}dstring{doption}
nnn is the numeric value of the number of lines to search from the cursor position. If omitted, the search
continues to the end of the file or record. If this optional parameter has been specified then all occurrences of the
string will be located over the specified number of lines. If only a single occurrence is found then the cursor is
placed at this point in the file. If multiple occurrences of the string are found then each one is listed below the
editing screen.
d is the delimiter used to enclose the string to be located. It can be any character that does not form part of the
string.
string is the string to locate.
option can be one or more of the following:
F specifies that the search is to begin at the start of the file or record.
C performs a case insensitive search. Otherwise the search defaults to match the cases as provided in the
string.
Examples
L/report
Searches the record from the current position for the string 'report' and halts at the first occurrence found, with
the cursor at the start.
L9 FORM
Replacing Strings
The editor allows the user to replace any occurrence of a string on any line with another from the command line.
This is in addition to the overwrite mode.
The command syntax is as follows:
R{U}{nnn}dstring1dstring2{doption}
U replaces ALL occurrences of string1 with string2 on the current line only.
nnn is a numeric value for the number of lines, starting from the current one, over which to perform the replace
operation. If this optional parameter is specified and more than a single occurrence of string1 is found then all
replacements are listed beneath the current editing screen.
d is the delimiter character used to separate the string values. It can be any character not in either of the strings.
string1 is the string that is to be replaced.
string2 is the replacement string. This can be shorter or longer than the original.
option can be one or more of the following:
F executes the replace command from the first line of the file or record.
* replaces ALL occurrences of string1 with string2 on the current line.
nnn numeric value for the number of times to repeat the replace operation on the current line.
Examples
R/ABC/DEF
Replaces the first occurrence (reading from the left) of ABC in the current line with DEF.
R9/*/!
Replace on the next 9 lines, the first occurrence on the line of '*' with a '!'. The changed lines are displayed
before moving on.
RU9/*/!
Replace any occurrence of '*' with '!' over 9 lines (the current line and the next 8).
R999//*/F
Place a '*' character at the start of every line starting from the first. All lines changed are shown before returning
to the original line.
R/^/AM/*
All occurrences of the '^' character on the line are replaced with 'AM'.
R9/*//
Removes (replaces with null) the first occurrence of '*' on the next 9 lines.
R/x//10
Removes the first 10 'x' characters on the current line.
Marking Text
Text can be marked whilst in edit mode by using the appropriate keystroke command (default <CTRL G>) to
mark the start and end of the block.
To highlight a block, move the cursor to the first line to be highlighted and press <CTRL G> (or the reassigned
ones). Then move the cursor to the last line to be highlighted and again press the <CTRL G>. The start and end
lines can be marked in any order.
To cancel the marked text, simply press <CTRL G> again, which will remove the markers.
Once the text is marked the cursor should be positioned on the line to which the text is to be copied or moved
before invoking the command line or key sequence required.
Miscellaneous Commands
DE{nnn} Deletes the number of lines specified by nnn, starting from the current cursor position. If nnn is
omitted it defaults to a value of one line.
?S or S? Displays the size of the record being edited in bytes. It includes field delimiter marks in the body
of the record.
!{command} Executes command. Can be any valid UNIX or jBASE command.
!! Re-executes the command specified in the most recent ! command executed.
U{nn} Scrolls the screen up by nn lines. If omitted, nn defaults to one line.
D{nn} Scrolls the screen down by nn lines. If omitted, nn defaults to one line.
I{nn} Inserts nn blank lines after the line holding the cursor. If omitted, nn defaults to one line.
nn Positions the cursor on line nn, which is positioned at the top of the screen if the number of
remaining lines still allows a screens worth of data to be displayed.
IN Equivalent to the <F10> key.
IP Equivalent to the <F9> key.
? Displays the main help screen menu.
jkeys
The jkeys program provides a method of defining keystrokes for terminfo databases. It is invoked by typing
jkeys at the shell prompt.
The jkeys menu allows you to list the terminfo string names and define values for them. Option 2 from the menu
will ask for the name of a terminal (which must exist in the terminfo database), to use as the basis for your new
definition. The program will then allow the definition of any or all keyboard sequences for the terminfo entry.
When you have specified a parameter to be changed a countdown timer will be displayed and you will prompted
to hit the key (or keys) sequence that you wish to be stored in the database for this sequence. You may continue
to define as many terminfo strings as you wish. When you have finished defining keyboard strings you should
type in .q to leave the definition screen.
Account Management
These commands are documented in the Maintenance chapter of the System Administrators Manual:
ACCOUNT-RESTORE ACCOUNT-SAVE
Editing
These commands are documented in the Editors chapter of the Programmers Reference Manual:
ED EDIT JED
File Management and Searching
These commands are documented in the File Management chapter of the System Administrators Manual:
CLEAR DELETE jgrep
CLEAR-FILE DELETE-FILE jstat
COPY jchmod SEL-RESTORE
CREATE-FILE jrf
General
These commands are documented in the General Utilities chapter of the System Administrators Manual:
ADDD DTX MULX
ADDX ECHO NOHUSH
BKOFF ECHO-OFF OFF
BKON ECHO-ON SLEEP
BREAK-KEY-ENABLE ENABLE-BREAK-KEY SUBD
BREAK-KEY-OFF HUSH SUBX
BREAK-KEY-ON LISTDICTS TERM
CP LISTF TERMINAL
CT LISTU TIME
DATE-FORMAT LOGOFF WHERE
DIVD MSG WHO
DIVX MULD XTD
Internationalisation
These commands are documented in the Internationalisation and General Utilities chapters of the System
Administrators Manual:
DATE-FORMAT SET-LANG SET-THOU
SET-DEC SET-MONEY
jBC
These commands are documented in the jBC chapter of the Programmers Reference Manual:
BASIC DECATALOG RUN
CATALOG DELETE-CATALOG
jBTP
These commands are documented in the jBTP chapter of the System Administrators Manual:
LIST-JOB PH-LINES STARTSCHED
PH-ALLOCATE PH-RESUME STOPSCHED
PH-CLEAR PH-START Z
PH-DELETE PH-STATUS ZH
PH-KILL PH-SUSPEND
List Processing
These commands are documented in the List Processing chapter of the Programmers Reference Manual:
COPY-LIST LIST-LISTS SAVE-LIST
DELETE-LIST NEW-GET-LIST SEARCH
EDIT-LIST NEW-SAVE-LIST SORT-LIST
FORM-LIST NEW-SORT-LIST XSELECT
GET-LIST QSELECT
These statements are documented in the jBC chapter of the Programmers Reference Manual:
READLIST READNEXT WRITELIST
These commands are documented in the jCL chapter of the Programmers Reference Manual:
PQ-RESELECT PQ-SELECT
These commands are documented in the jQL chapter of the Programmers Reference Manual:
BSELECT SELECT
ESEARCH SSELECT
Migration
This command is documented in the Migration chapter of the Programmers Reference Manual. See also the
Advanced Migration chapter of the Advanced Programmers Reference Manual:
Tape Operation
These commands are documented in the Tape Operations chapter of the System Administrators Manual:
T-ATT T-ERASE T-RETENSION
T-BCK T-FWD T-REW
T-CHK T-LOAD T-STATUS
T-DET T-RDLBL T-UNLOAD
T-DUMP T-READ T-WEOF
Variable: JBASETMP
Description: jBASE programs make use of a work file for various internal processes such as passing STOP
codes to calling programs, SAVE-LISTs, etc. The name of the work file can be changed by
modifying this environment variable. Note though that this variable is provided for JAC support
purposes and is unlikely to need changing by the programmer.
Values: Valid file path.
Default: $JBCRELEASEDIR/tmp/jBASEWORK
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBASETMP=/home/alternative/workfile
export JBASETMP
Variable: JBC_ENDRESTART
Description: Enables the Break/End Restart feature.
Values: Restart Program.
Default: Break/End Restart feature disabled.
Setting: Create the JBC_ENDRESTART environment variable in the .profile before the jbcconnect
program is executed. The environment variable should contain the UNIX command string to
execute when the debugger is entered/exited.
To later enable the feature, use the BITSET(-3). To later disable the feature, use the BITRESET(-
3).
Variable: JBC_TCLRESTART
Description: Enables the Command Level Restart feature.
Values: Restart Program.
Default: Command Level Restart feature disabled.
Setting: Create the JBC_TCLRESTART environment variable in the .profile before the jbcconnect is
executed. The environment variable should contain the UNIX command string to execute when the
user would otherwise go to a shell prompt.
To later enable the feature, use the BITSET(-2). To later disable the feature, use the BITRESET(-
2).
Variable: JBCEMULATE
Description: When importing legacy applications, this variable tells the compiler what system it originally ran
on. Note that programs and subroutines imported from different systems may be freely mixed.
Values: ROS, R83, PRI, ULT, ADS, FUJ, UNV, UND, AP
Default: The default is R83, which will suit most imported applications.
Setting: Normal UNIX environment variable. Can be set at any time by the commands:
JBCEMULATE=Value
export JBCEMULATE
Variable: JBCERRFILE
Description: Default error messages are held in the file $JBCRELEASEDIR/jbcmessages. This may be
overridden by the JBCERRFILE variable - only useful if you wish to customise the error messages
for your own application.
Values: Valid file path.
Default: $JBCRELEASEDIR/jbcmessages
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCERRFILE=/home/alternative/errmsgfile
export JBCERRFILE
Variable: JBCGLOBALDIR
Description: Defines the global directory for the jBASE system locks. Config file for jPML, jRLA, jBTP,
jBASEWORK, tape device status.
Values: Valid file path.
Default: /usr/jbc
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCGLOBALDIR=/usr/jbc
export JBCGLOBALDIR
Variable: JBCLOGNAME
Description: The account name as perceived by commands such as WHO or conversions such as U50BB will
normally be returned as the login name of the UNIX user (LOGNAME variable). However, if you
want users to login with personal id's but execute as if they were all on the same account you can
set this variable to override the default. The account name will be returned from this environment
variable.
Values: Any character string.
Default: None.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCLOGNAME=PAYROLL
export JBCLOGNAME
Variable: JBCOBJECTLIST
Description: Defines the directory in which user shared object libraries of user subroutines are located.
Values: Colon separated file paths.
Default: $HOME/lib.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCOBJECTLIST=$HOME/lib:$ANOTHERHOME/lib
export JBCOBJECTLIST
Variable: JBCPORTNO
Description: Defines your current port number. Can be very useful when particular users need to keep the same
port number whenever they log on. It takes a sensible default defined by UNIX, but note that this
default may change if you modify the UNIX configuration.
Values: Decimal port number.
Default: None.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCPORTNO=1000
export JBCPORTNO
Variable: JBCPRINTER_WIDTH
Description: Specifies page width for paged spooler output. Overrides the value specified by the TERM type.
Values: Decimal number
Default: None.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCPRINTER_WIDTH=112
export JBCPRINTER_WIDTH
Variable: JBCRELEASEDIR
Description: Defines the release directory for jBASE system executables and libraries.
Values: Valid file path.
Default: /usr/jbc.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCRELEASEDIR=/usr/jbc
export JBCRELEASEDIR
Variable: JBCSCREEN_DEPTH
Description: Specifies page depth for paged terminal output. Overrides the value specified by the TERM type.
Values: Decimal number
Default: None.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCSCREEN_DEPTH=10
export JBCSCREEN_DEPTH
Variable: JBCSCREEN_WIDTH
Description: Specifies page width for paged terminal output. Overrides the value specified by the TERM type.
Values: Decimal number
Default: None.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCSCREEN_WIDTH=132
export JBCSCREEN_WIDTH
Variable: JBCTTYNAME
Description: Defines your UNIX TTY name. If this variable is not defined, jBASE will use the UNIX system
call ttyname() to define it. On some systems this function call is very slow and the use of this
variable will greatly improve execution start-up times.
Values: Any character string.
Default: None.
Setting: Normal UNIX environment variable. Should be set in the .profile before the jbcconnect command:
JBCTTYNAME=JimTerm.
export JBCTTYNAME
Variable: JEDIFILENAME_MD
Description: Use this variable if you want the MD file to hold Qpointers, jCL programs or entries for the jQL
language. If you have loaded an account-save into your home directory then you will probably
need to set this variable.
Once the variable is set, you can:
Execute jCL programs directly from the MD (using jsh, EXECUTE, CHAIN, etc.).
Support Qpointers in the MD file (you may also need to set
JBCFILENAME_SYSTEM).
Create cross reference records for executables (from original name to new name) to
support systems which have a 14 character filename limit.
Values: Valid file path.
Default: None.
Setting: Normal UNIX environment variable. Can be set at any time by the commands :
JEDIFILENAME_MD=./MD
export JEDIFILENAME_MD
Variable: JEDIFILENAME_SYSTEM
Description: If you are using Qpointers in a defined MD file, you may well need to create a SYSTEM file to
define the home directories of other accounts. By default, Qpointers are resolved by using the
$JBCRELEASEDIR/src/SYSTEM file. This can be changed by setting the
JEDIFILENAME_SYSTEM variable to an alternative hash file or directory.
Values: Valid file path.
Default: None.
Setting: Normal UNIX environment variable. Can be set at any time by the commands :
JEDIFILENAME_SYSTEM=/home/alternative/SYSTEM
export JEDIFILENAME_SYSTEM
Variable: LIBPATH
Description: This variable is specific to AIX systems only. It should always be set to /usr/jbc/lib.
Values: Colon separated library file paths.
Default: None.
Setting: Normal UNIX environment variable. Can be set at any time by the commands :
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/jbc/lib export
LD_LIBRARY_PATH
Variable: LD_LIBRARY_PATH
Description: This variable is specific to SVR4 systems only. It should always be set to /usr/jbc/lib.
Values: Colon separated library file paths.
Default: None.
Setting: Normal UNIX environment variable. Can be set at any time by the commands :
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/jbc/lib export
LD_LIBRARY_PATH
Variable: PATH
Description: Contains a list of all directories that hold executable programs. As a minimum, this should contain
the shell default value and the /usr/jbc/bin path so that jBASE commands can be found by the
shell. You will also need to add the path of your application executable directory - such as
${HOME}/bin.
Values: Any directory the user has privileges for.
Default: Depends on your particular UNIX system and how it has been set up.
Setting: Normal UNIX environment variable. Can be set at any time by the commands :
PATH=$PATH:/usr/jbc/bin
export PATH
Variable: TERM
Description: Set this variable to your terminal type as defined by the UNIX terminfo database.
Values: Any valid terminfo database entry.
Default: Depends on your particular UNIX system and how it has been set up.
Setting: Normal UNIX environment variable. Can be set at any time by the commands :
TERM=vt220
export TERM
Note that when you inspect the PATH variable you will not see the string {HOME} as this is
translated into the path name of your home directory (base directory of your UNIX account).
You can determine the path name of your home directory by typing:
pwd
Note also that these commands should be issued using ksh. If you are using jsh then you can
change to ksh by typing F2 (function key 2).
Your application migration is now complete and you may proceed to test its functionality.
Portbas
jBASE is supplied with a tool for converting a BASIC source code file into a jBC directory. This tool is called
Portbas and is run against each file in turn.
Note: You should take care to ensure that only BASIC code exists in the file before using the portbas
utility. Portbas cannot readily distinguish between BASIC code and any other type of data so you should
use the COPY or DELETE commands to remove records that do not contain BASIC source code. The
tool will ignore records whose name begins with a as these are assumed to contain BASIC object
code, which is no longer required.
Finally, the program will have renamed any include files with the suffix .b as it cannot see that they are to be
INCLUDEd in another source code. You should use the UNIX mv command to rename any INCLUDE records
by removing the .b suffix. However, if you are intending to use the makemake utility (described next) to build
your Makefiles, then you may leave this utility to rename included source records.
You have now completed the migration of the BASIC source code file to the jBASE system
Building Makefiles
If you have used the totalmake utility to build your makefiles then you may ignore this section, if you ran
Portbas manually then read on. At this stage you have one or more directories containing jBC source files but no
means to compile them other than manually. The best way to control application compilation in UNIX
environments is to use the make utility described in the UNIX manuals.
The make utility requires a file in the source code directory, which describes the relationship between all the
component parts of the application. This file is (by default) called Makefile or makefile although it may be
named otherwise.
You may wish to use the template supplied in the file /usr/jbc/src/Makefile as the basis to build your Makefile as
this is a relatively straightforward process. By building your Makefile manually, you will learn all about
compiling on UNIX systems and have a very neat Makefile.
Building Makefile manually can be a tedious process however, so the jBASE system is supplied with a tool
called makemake, which will build a Makefile for you. As Makefiles can be complicated for the unfamiliar user
you may wish to seek assistance with this aspect of your port. JAC and their VARs will be pleased to provided
help in this area.
Maintaining Makefiles
Once a Makefile has been generated it will remain fairly static. As the application is developed however, there
will be additions and deletions to the source records in each directory. When this happens you will need to
update the Makefile to reflect the changes.
In most cases this maintenance will be very simple. If you are deleting a source record then you need only
remove its reference in the Makefile. If you are adding a standalone program then you need only add an entry for
it in the relevant make rule. A cursory inspection of the Makefile will show the changes required.
If you are adding a new subroutine to the application you will need to choose a library to archive the subroutine
within. You will then need to ensure that all programs calling this subroutine link with the relevant library. It
usually a good idea to place the new subroutine in a library that the prospective callers already link with.
However, it is possible to create a new library and update the list of dependencies to ensure that this library is
linked to all calling programs.
On SVR3.2 systems (or equivalent), when a subroutine is changed and recompiled, then all programs calling that
subroutine must be relinked with the library. By default the Makefile produced will cause all programs to be
recompiled when the subroutines they are dependant on are changed. On SVR4 systems all application libraries
are compiled as dynamic libraries, which means that programs dependant upon the libraries need only be
recompiled if the subroutine parameters have changed. You may change the Makefile to reflect this if you wish,
but must consider that all programmers should be aware of the necessary implications.
Once the application has been successfully compiled the PATH environment variable for the current user should
be updated to include the {HOME}/bin directory. Compiled jBC programs may then be invoked from the shell
prompt by typing in their name. The .profile in the {HOME} directory should be updated to accommodate this.
Account Vs User
The jBASE developer may allow users access to the live application in a number of ways. It is likely that the
existing application is executed from a single ACCOUNT that all users login to. This is, of course, still possible
within the jBASE scenario. All users may login to the same UNIX user, with the .profile file in the {HOME}
directory invoking the start up program of the application. The UNIX user name will normally be a lower case
version of the original account name.
Some applications rely on the account name to implement their own user security routines and it may be that the
account name has been hard coded in Upper case characters. The jBASE system allows the effective login (or
ACCOUNT name) to be changed as far it is concerned by setting a new environment variable to the old
ACCOUNT name. This is achieved by issuing the shell commands:
JBCLOGNAME=ACCNAME ; export JBCLOGNAME
These commands should be added into the .profile file of the login user.
UNIX systems are able to implement security routines on a user by user basis. It is therefore worth considering
creating a UNIX user for each application user on the system. They may all utilise the same {HOME} directory
and by using the JBCLOGNAME environment variable they will all appear to be logged on to the same account.
However, different users may then be granted individual group and execution permissions providing useful
security checks in the application.
Index
C functions, 2-38, 2-61 debugger, 2-1, 2-2, 2-4, 2-13, 2-31, 2-54, 2-60, 2-
C jCL comment, 3-19 67, 2-99, 2-105, 2-117, 2-119
C programs, 2-1 Debugging, 3-13
C++, 1-1 DECATALOG, 2-12, 7-1
CALL, 2-24, 2-38, 2-50, 2-105, 2-111, 4-47, 4-49 DEFC, 2-38, 2-60
CASE, 2-37, 2-51, 6-5, 6-10 DEL, 2-61
CATALOG, 2-11, 7-1, 9-1 DELETE, 2-62, 7-1
CHAIN, 2-51, 2-55, 2-59, 3-3, 3-5, 3-6 DELETE-CATALOG, 2-12, 7-1
CHANGE, 2-52, 2-57 DELETE-FILE, 7-1
CHAR, 2-52 DELETELIST, 2-62
CHDIR, 2-14, 2-53, 2-71 DELETE-LIST, 5-3, 7-2
CHECKSUM, 2-53 development and live environments, 9-9
CHECK-SUM, 4-4 development tools, 1-1
CLEAR, 2-53, 7-1 DIMENSION, 2-39, 2-62
CLEARFILE, 2-54 dimensioned arrays, 2-39, 2-41, 2-55
CLEAR-FILE, 4-19, 7-1 directory layouts, 9-8
CLOSE, 2-54 DIVD, 7-1
COL1( ) & COL2( ), 2-55 DIVX, 7-1
COLLECTDATA, 2-56, 2-66 DTX, 2-63, 7-1
Command Level Restart, 8-1 dynamic arrays, 2-39, 2-40, 2-68, 2-105
command syntax, 2-27, 5-12
comment lines, 2-34 E
COMMON, 2-25, 2-26, 2-38, 2-39, 2-50, 2-51, 2-
EBCDIC, 2-63
55, 2-63, 2-64, 2-111, 4-49
ECHO, 2-64, 7-1
Conditional Operations, 3-12
ECHO OFF, 2-64
constants, 2-28
ECHO ON, 2-64
CONTINUE, 2-37, 2-56, 2-71, 2-82
ECHO-OFF, 7-1
conversion codes, 2-36, 4-34
ECHO-ON, 7-1
CONVERT, 2-57
EDELETE, 4-1, 4-4, 7-2
CONVERT function, 2-57
EDELETE jQL command, 4-19
COPY, 7-1
EDIT-LIST, 5-3, 5-8, 7-2, 9-4
COPY-LIST, 5-2, 7-2
Editor
COS, 2-57
command line operations, 6-6
COUNT, 2-50, 2-58, 4-4, 4-29, 4-30, 7-2
key commands, 6-4
COUNT jQL command, 4-18
Editors, 6-1
CP, 7-1
ENABLE-BREAK-KEY, 7-1
CREATE-FILE, 2-90, 7-1
ENTER, 2-64
CRT, 2-35, 2-58, 2-70, 2-74, 2-93
environment variables, 2-1, 2-10, 2-11, 2-12, 2-71,
CT, 7-1
2-72, 2-92, 2-96, 4-1, 8-1, 9-10
EQUATE, 2-63, 2-65
D
ESEARCH, 3-7, 3-61, 4-4, 4-5, 5-12, 7-2
D code, 4-51 ESEARCH jQL command, 4-19
D jCL command, 3-20 EXECUTE, 2-2, 2-56, 2-59, 2-65, 2-93, 2-96, 2-
D1 / D2 codes, 4-53 106, 2-112, 3-3, 3-5, 3-6, 9-7
DATA, 2-59, 3-6 EXIT, 2-37, 2-50, 2-56, 2-66
data definition records, 4-31 EXP, 2-67
Data Movement Commands, 3-11 export list, 2-11
data records, 2-28 EXTRACT, 2-67
DATE, 2-59, 2-88, 3-9
DATE-FORMAT, 4-51, 7-1 F
DCOUNT, 2-60
F code, 4-54
DE jCL command, 3-20
F jCL command, 3-21
DEBUG, 2-13, 2-60
F jCL command, 3-11
debug facilities, 2-3
FB, 3-7
DEBUG jCL command, 3-21
FB jCL command, 3-27
DEBUG jCL command, 3-13
FB jCL command, 3-12
DEBUG statement, 2-13
F-C jCL command, 3-23
Index
F-C jCL command, 3-12 GETLIST, 2-72, 2-98
F-CLEAR jCL command, 3-23 GET-LIST, 3-7, 3-56, 3-61, 4-2, 4-3, 4-5, 4-6, 4-
F-CLEAR jCL command, 3-12 18, 4-19, 4-20, 5-2, 5-4, 7-2
F-D jCL command, 3-23 G-F jCL command, 3-30
F-D jCL command, 3-12 GO B, 3-12, 3-46, 3-47
F-DELETE, 3-24, 3-26 GO B jCL command, 3-29
F-DELETE jCL command, 3-23 GO B jCL command, 3-12
F-DELETE jCL command, 3-12 GO F, 3-12, 3-46, 3-47
F-F jCL command, 3-24 GO F jCL command, 3-30
F-F jCL command, 3-12 GO F jCL command, 3-12
F-FREE, 3-26 GO jCL command, 3-28
F-FREE jCL command, 3-24 GO jCL command, 3-11
F-FREE jCL command, 3-12 GO{TO}, 2-73
FIELD, 2-55, 2-68, 2-73 GO-B jCL command, 3-29
field definition records, 4-31 GOSUB, 2-17, 2-24, 2-36, 2-37, 2-38, 2-72, 2-90,
File Buffers, 3-7 2-105, 2-111, 3-15, 3-38, 3-53, 3-54
file definition records, 4-29 GOSUB jCL command, 3-31
file handling, 2-41 GOSUB jCL command, 3-12
File Operations, 3-12 GOTO, 2-8, 2-36, 2-37, 2-73, 2-90
file systems, 1-1 GOTO B jCL command, 3-29
FIND, 2-68, 2-69, 2-81 GOTO F jCL command, 3-30
FINDSTR, 2-69, 2-81 GOTO jCL command, 3-28
F-K jCL command, 3-24 GOTO jCL command, 3-11
F-K jCL command, 3-12 GROUP, 2-73
F-KLOSE, 3-25
F-KLOSE jCL command, 3-24 H
F-KLOSE jCL command, 3-12
H jCL command, 3-32
FLOAT, 2-60
H jCL command, 3-11
F-O jCL command, 3-25
HEADING, 2-70, 2-74, 2-92, 2-112, 4-2, 4-12, 4-
F-O jCL command, 3-12
14, 4-16, 4-23, 4-27
FOOTING, 2-70, 2-92, 2-112, 4-12, 4-14
HUSH, 7-1
F-OPEN, 3-12, 3-23, 3-24, 3-26, 3-27, 3-28
F-OPEN jCL command, 3-25
I
F-OPEN jCL command, 3-12
FOR, 2-37, 2-56, 2-70, 2-73 IBH, 3-6, 3-42
formatting variables, 2-35 IBH jCL command, 3-33
FORM-LIST, 3-7, 3-61, 4-5, 5-2, 5-4, 5-6, 7-2 IBH jCL command, 3-11
F-R jCL command, 3-25 IBN, 3-6, 3-35, 3-43, 3-44
F-R jCL command, 3-12 IBN jCL command, 3-34
F-READ, 3-28 IBN jCL command, 3-11
F-READ jCL command, 3-25 IBP, 3-34, 3-43, 3-44
F-READ jCL command, 3-12 IBP jCL command, 3-35
F-UR jCL command, 3-26 IBP jCL command, 3-11
F-UR jCL command, 3-12 ICONV, 2-36, 2-75
F-UREAD, 3-12, 3-24, 3-27 IF, 2-36, 2-37, 2-75, 3-17, 3-28, 4-40, 4-45, 6-5
F-UREAD jCL command, 3-26 IF (masked) jCL command, 3-38
F-UREAD jCL command, 3-12 IF (multivalued) jCL command, 3-37
F-W jCL command, 3-27 IF ... THEN, 2-37
F-W jCL command, 3-12 IF E, 3-5
F-WRITE, 3-24, 3-26 IF E jCL command, 3-39
F-WRITE jCL command, 3-27 IF E jCL command, 3-12
F-WRITE jCL command, 3-12 IF jCL command, 3-36
IF jCL command, 3-12
G IF S jCL command, 3-40
IFN, 3-12, 3-36
G code, 4-59
IFN jCL command, 3-41
G jCL command, 3-28
IH, 3-6, 3-33
GETCWD, 2-71
IH jCL command, 3-41
GETENV, 2-71
IH jCL command, 3-11
Index
Importing Accounts, 9-3 JEDIFILENAME_MD, 8-5
Importing jCL, 9-7 JEDIFILENAME_SYSTEM, 8-5
IN, 2-76, 3-34, 3-35, 3-44 JEDIFILEPATH, 8-6
IN jCL command, 3-43 jfb command, 2-7, 2-8
IN jCL command, 3-11 jgrep, 7-1
INCLUDE, 2-38, 4-49, 9-4, 9-5, 9-6 jLP, 1-1, 3-46, 7-2
include files, 2-4, 2-10, 9-4, 9-5, 9-6 jPML, 7-3, 8-2
INDEX, 2-76 jQL, 1-1, 2-107, 3-5, 3-22, 3-33, 3-42, 3-45, 3-46,
INHIBIT-BREAK-KEY, 2-15 3-52, 3-56, 3-57, 4-1, 7-2, 8-3, 8-5
INPUT, 2-35, 2-77, 2-78, 3-6 jQL command sentence, 4-3
Input Buffer Commands, 3-11 jrestore, 1-1, 7-3
Input/Output Buffer Operations, 3-11 jrf, 7-1
INPUTNULL, 2-78 jRLA, 8-2
INS, 2-78, 2-79 JRLA, 7-3
INSERT, 2-79 jsh, 8-5
INT, 2-60, 2-79 jSHELL, 2-3, 3-3, 3-4, 4-3, 4-24, 4-27, 5-1
IP, 3-6, 3-34, 3-35, 3-43 jspprint, 7-3
IP jCL command, 3-44 jstat, 7-1
IP jCL command, 3-11 Jump and Branch Operations, 3-11
IT jCL command, 3-45
IT jCL command, 3-11 L
L code, 4-60
J
L jCL command, 3-45
j1, 1-1, 2-9, 9-3 LD_LIBRARY_PATH, 8-1, 8-6
j2, 1-1, 2-9, 9-3 LEN, 2-80
j3, 2-9 LIBPATH, 8-1, 8-6
jbackup, 1-1, 7-3 line continuation, 2-34
JBASETMP, 8-1 linked libraries, 2-3
jBC, 1-1, 2-1, 2-30, 3-3, 3-4, 3-5, 3-6, 3-56, 3-57, LIST, 4-1, 4-4, 4-14, 4-23, 4-29, 4-30, 7-2
4-5, 4-11, 4-24, 4-27, 4-35, 4-47, 4-49, 5-10, 6- LIST jQL command, 4-20
1, 6-3, 6-5, 6-7, 6-10, 7-1, 7-2, 9-2, 9-5, 9-6 LISTDICT, 7-2
JBC_ENDRESTART, 8-1 LISTDICT jQL command, 4-22
JBC_TCLRESTART, 8-1 LISTDICTS, 7-1
jbcconnect, 7-3, 8-1, 8-2, 8-3, 8-4, 8-5 LISTF, 7-1
JBCDEFDICTS, 8-2 LIST-JOB, 7-1
JBCEMULATE, 8-2 LIST-LABEL, 4-4, 7-2
JBCERRFILE, 8-2 LIST-LABEL jQL command, 4-21
JBCGLOBALDIR, 8-2 LIST-LISTS, 5-5, 7-2
JBCIDLEN, 8-3 LISTPEQS, 7-2
JBCLOGNAME, 8-3 LISTPTR, 7-2
JBCOBJECTLIST, 8-3 LISTU, 7-1
JBCPORTNO, 8-3 LN, 2-80
JBCPRINTER_DEPTH, 8-4 LOCATE, 2-80
JBCPRINTER_WIDTH, 8-4 LOCK, 2-41, 2-81, 2-117
JBCRELEASEDIR, 8-4 logical operators, 2-31
JBCSCREEN_DEPTH, 8-4 Login jCL Programs, 3-4
JBCSCREEN_WIDTH, 8-4 LOGOFF, 7-1
JBCSPOOLDIR, 8-5 LOOP, 2-37, 2-56, 2-73, 2-78, 2-81
JBCTTYNAME, 8-5 looping constructs, 2-37
jBTP, 2-113, 7-1, 8-2
jchmod, 7-1 M
jCL, 1-1, 2-52, 2-65, 2-94, 2-95, 2-110, 3-1, 4-5, 5-
M jCL command, 3-46
11, 7-2, 8-5, 9-7, 9-8
M jCL command, 3-12
F, 3-22
makefiles, 2-3, 2-5, 2-10, 9-2, 9-4, 9-5, 9-6
jCL commands, 3-11
building, 9-5
jED, 2-3, 2-6, 2-7, 2-40, 2-42, 3-3, 3-6, 6-2
maintaining, 9-6
jEDI, 1-1, 2-5, 2-11, 2-40, 6-2
makeproc, 9-7
Index
MAT, 2-82, 2-111 P
MATBUILD, 2-83, 2-84
P code, 4-73
MATCH{ES}, 2-82
P jCL command, 3-51
MATPARSE, 2-84
PAGE, 2-92
MATREAD, 2-39, 2-85
PATH, 8-1, 8-6
MATREADU, 2-39, 2-42, 2-85, 2-120
pattern matching, 2-35
MATWRITE, 2-42, 2-86, 2-87, 2-100, 2-102, 2-
PERFORM. See EXECUTE
120, 2-121
PH-ALLOCATE, 7-1
MATWRITEU, 2-42, 2-87, 2-100, 2-102, 2-121
PH-CLEAR, 7-1
MC codes, 4-61
PH-DELETE, 7-1
MD code, 4-66
PH-KILL, 7-2
MD file, 8-5
PH-LINES, 7-1
migration, 9-1
PH-RESUME, 7-1
MK code, 4-67
PH-START, 7-1
ML/MR codes, 4-68
PH-STATUS, 7-1
MOD, 2-88
PH-SUSPEND, 7-2
MP code, 4-70
PICK, 2-2
MS, 3-5
port number, 8-3
MS code, 4-71
Portbas, 9-4, 9-5
MS jCL command, 3-47
PORTBAS, 7-3
MS jCL command, 3-11
PORT-DESPOOL, 7-2
MSG, 7-1
PQ and PQN Differences, 3-63
MT code, 4-72
PQ-RESELECT, 3-7, 3-61, 5-11, 7-2
MULD, 7-1
PQ-RESELECT jCL command, 3-61
MULX, 7-1
PQ-SELECT, 3-7, 3-32, 3-61, 5-11, 7-2
MV, 3-6, 3-8, 3-19, 3-23, 3-34, 3-43, 3-55, 3-56
PQ-SELECT jCL command, 3-61
MV jCL command, 3-47
PRECISION, 2-50, 2-67, 2-93, 2-108, 2-110, 2-
MV jCL command, 3-11
111, 2-113
MVA jCL command, 3-49
Primary Input Buffer, 3-5
MVA jCL command, 3-11
Primary Output Buffer, 3-5
MVD jCL command, 3-50
PRINT, 2-35, 2-93, 2-94
MVD jCL command, 3-11
PRINTER ON|OFF|CLOSE, 2-94
PRINTERR, 2-94
N
PROCREAD, 2-94, 2-95, 3-5
naming conventions, 2-8 PROCWRITE, 2-95, 3-5
NEW-GET-LIST, 5-5, 7-2 PROGRAM, 2-95
NEW-SAVE-LIST, 5-5, 5-6, 7-2 program and library files, 2-4
NEW-SORT-LIST, 5-6 program files, 2-35
NOHUSH, 7-1 program memory requirements, 2-11
NOT, 2-31, 2-88 PROMPT, 2-96, 2-113
NULL, 2-88 PUTENV, 2-72, 2-96
NUM, 2-89 PWR, 2-96
numeric strings, 2-31
Q
O
QSELECT, 3-7, 3-61, 4-5, 5-6, 7-2
O jCL command, 3-51
OCONV, 2-36, 2-59, 2-75, 2-89 R
OFF, 2-17, 7-1
R code, 4-74
ON .... GOSUB, 2-37
READ, 2-40, 2-91, 2-97
ON...GOSUB, 2-90
READLIST, 2-72, 2-98, 2-118, 5-10, 7-2
ON...GOTO, 2-90
READNEXT, 2-98, 2-107, 4-11, 4-24, 4-27, 5-10,
OPEN, 2-41, 2-54, 2-62, 2-85, 2-86, 2-87, 2-91, 2-
7-2
97, 2-100, 2-101, 2-102, 2-103, 2-118, 2-119,
READT, 2-99
2-120, 2-121
READU, 2-40, 2-42, 2-97, 2-100, 2-120
OUT, 2-92
READV, 2-40, 2-101
Output Buffer Commands, 3-11
READVU, 2-40, 2-42, 2-101
record locking, 2-41
Index
REFORMAT, 4-4, 4-27, 7-2 SORT-LABE, 7-2
REFORMAT jQL command, 4-23 SORT-LABEL, 4-4
REGEXP, 2-102 SORT-LABEL jQL command, 4-26
relational expression, 2-33 SORT-LIST, 3-56, 5-2, 5-8, 7-2
RELEASE, 2-42, 2-100, 2-102, 2-103, 2-120, 2- SOUNDEX, 2-109
121 SPACE, 2-110
REM, 2-34, 2-88 SP-ALIGN, 7-2
REMOVE, 2-103 SP-ASSIGN, 2-93, 3-46, 7-2
REPLACE, 2-104 SP-CLEAR, 7-2
reserved words, 2-29 SP-CLOSE, 7-2
RETURN, 2-36, 2-37, 2-38, 2-105, 2-111 SP-COPIES, 7-2
REWIND, 2-105 SP-CREATE, 7-2
RI, 3-6, 3-34, 3-43 SP-DELETE, 7-2
RI jCL command, 3-52 SP-DEVICE, 7-2
RI jCL command, 3-11 SP-EDIT, 7-2
RND, 2-105 SP-EJECT, 7-2
RO, 3-19, 3-56 SP-FORM, 7-2
RO jCL command, 3-53 SP-FQDELETE, 7-2
RO jCL command, 3-11 SP-JOBS, 7-2
RQM. See SLEEP SP-KILL, 7-2
RSUB, 3-31 SP-LOOK, 7-2
RSUB jCL command, 3-53 SP-MOVEQ, 7-2
RSUB jCL command, 3-12 spooler, 1-1, 3-10, 4-4, 4-15, 8-4, 8-5
RTN, 3-15 SP-OPEN, 7-2
RTN jCL command, 3-54 SP-OPTS, 7-2
RTN jCL command, 3-12 SP-PRIORITY, 7-2
RTNDATA, 2-66, 2-106 SP-PURGEQ, 7-2
RUN, 7-1 SP-RESUME, 7-2
RUN command, 2-12 SP-SKIP, 7-2
run-time components, 1-1 SP-STATUS, 7-2
SP-STOP, 7-2
S SP-SUSPEND, 7-2
SP-SWITCH, 7-2
S code, 4-75
SP-TAPEOUT, 7-2
S jCL command, 3-55
SP-TRANSLATE, 7-2
S jCL command, 3-11
SP-TYPE, 7-2
SAVE-LIST, 2-62, 2-72, 2-98, 5-4, 5-7, 5-8, 7-2
SQL, 1-1, 2-1
SEARCH, 3-7, 3-61, 4-5, 5-2, 5-7, 7-2
SQL Database, 2-1
Secondary Input Buffer, 3-5
SQRT, 2-110
Secondary Output Buffer, 3-6
SREFORMAT, 4-4, 4-23, 7-2
SELECT, 2-72, 2-99, 2-106, 3-7, 3-40, 4-1, 4-2, 4-
SREFORMAT jQL command, 4-26
3, 4-4, 4-5, 4-6, 4-11, 4-18, 4-19, 4-20, 4-27, 5-
SSELECT, 2-98, 2-107, 3-7, 3-61, 4-4, 4-5, 4-24,
12, 6-3, 7-2, 9-4
5-8, 5-12, 6-3, 7-2
SELECT jQL command, 4-23
SSELECT jQL command, 4-27
Select Registers, 3-7
STARTSCHED, 7-1
SEL-RESTORE, 7-1
statements and statement labels, 2-34
SENTENCE, 2-107
STOFF, 3-6
SEQ, 2-107
STOFF jCL command, 3-55
SET-DEC, 4-66, 4-68, 7-1
STOFF jCL command, 3-11
SET-LANG, 7-1
STON, 3-6, 3-56
SET-MONEY, 4-66, 4-68, 7-1
STON jCL command, 3-56
SET-THOU, 4-66, 4-68, 7-1
STON jCL command, 3-11
shared libraries, 2-5, 2-11
STOP, 2-110, 2-111, 2-112
shared library objects, 2-11, 2-12
STOP codes, 8-1
SIN, 2-108
STOPSCHED, 7-1
SLEEP, 2-106, 2-108, 7-1
STR, 2-110
SORT, 2-109, 4-3, 4-4, 4-14, 4-26, 7-2
strings and string operations, 2-32
SORT jQL command, 4-24
structured coding, 2-8
Index
SUBD, 7-1 T-UNLOAD, 7-3
SUBROUTINE, 2-50, 2-105, 2-111, 4-49, 9-5 T-WEOF, 7-3
subroutine objects, 2-11
subroutines, 2-38, 2-111 U
SUBX, 7-1
U code, 4-79
SVR4, 8-6
U jCL command, 3-59
symbol tables, 2-26
UNASSIGNED, 2-116
SYSTEM, 2-43, 2-64, 2-99, 2-105, 2-111, 2-117,
UNIX, 1-1, 1-2, 2-1, 2-2, 2-3, 2-4, 2-5, 2-6, 2-7, 2-
2-119
9, 2-11, 2-15, 2-18, 2-50, 2-51, 2-61, 2-65, 2-
SYSTEM file, 8-5
67, 2-71, 2-93, 2-95, 2-102, 2-103, 2-112, 2-
113, 3-2, 3-3, 3-12, 3-51, 3-52, 6-2, 6-4, 6-6, 6-
T
7, 6-9, 6-10, 6-11, 8-1, 8-3, 8-5, 8-6, 9-1, 9-3,
T code, 4-76 9-4, 9-5, 9-7, 9-8, 9-9, 9-10
T jCL command, 3-56 UNIX directory, 2-53
TAN, 2-113 UNLOCK, 2-41, 2-81, 2-117
tape devices, 2-99, 2-117, 2-119
T-ATT, 2-99, 2-119, 4-23, 4-27, 7-3, 9-1, 9-3 V
T-BCK, 7-3
VAR, 2-60
T-CHK, 7-3
variables, 2-28
T-DET, 7-3
T-DUMP, 4-4, 4-5, 7-2, 7-3
W
T-ERASE, 7-3
TERM, 2-112, 6-11, 7-1, 8-4, 8-6 WEOF, 2-117
TERMINAL, 7-1 WHERE, 7-1
Tfile code, 4-77 WHO, 7-1, 8-3
T-FWD, 7-3 Windows, 1-1, 1-2
TIME, 2-114, 3-9, 7-1 WRITE, 2-42, 2-91, 2-100, 2-102, 2-103, 2-117, 2-
TIMEDATE, 2-59, 2-114 120, 2-121
T-LOAD, 4-4, 7-2, 7-3 WRITELIST, 2-62, 2-72, 2-98, 2-118, 5-10, 7-2
totalmake Command, 9-4 WRITET, 2-119
TR jCL command, 3-58 WRITEU, 2-42, 2-100, 2-102, 2-118, 2-119, 2-121
trace table, 2-15, 2-16, 2-17, 2-18, 2-19, 2-20, 2-21, WRITEV, 2-42, 2-100, 2-102, 2-120, 2-121
2-22, 2-24 WRITEVU, 2-42, 2-120, 2-121
TRANSABORT, 2-114, 2-115
TRANSEND, 2-114, 2-115 X
TRANSQUERY, 2-115
X jCL command, 3-60
TRANSTART, 2-115
XSELECT, 5-8, 7-2
T-RDLBL, 7-3
XTD, 2-121, 7-1
T-READ, 7-3
T-RETENSION, 7-3
T-REW, 7-3 Z
TRIM, 2-115, 2-116 Z, 7-1
TRIMB, 2-116 ZH, 7-1
TRIMF, 2-116
T-STATUS, 7-3, 9-3
Index