You are on page 1of 10

Comparison of CLIST language and REXX

Literals. CLIST has no way of designating a literal and no consistent way of indicating that something is a variable. REXX, by contrast, has an excellent way of showing a literal: quotation marks or apostrophes. Variables are easily spotted in REXX's simply formed instructions. Variables. The ampersand (&) is used capriciously in CLISTs along with variables. Sometimes you use it; sometimes you don't. REXX makes it easy for you to show the difference between literals and variables, but forgives most lapses you might make. String manipulation. In order to manipulate strings of characters, you sometimes have to nest the &STR and &SUBSTR functions, which leads to very obscure coding. REXX is the queen of string manipulation. Its PARSE instruction and a multitude of functions make it easy to do anything you want with character data. Mathematics. CLIST does not take mathematics very seriously and should be used only for the simplest of calculations. CLIST may be adequate for calculating JCL SPACE requirements but for little else. REXX can do enough arithmetic to please almost anyone. Those who really like trigonometric functions and fractional exponents will probably forgive REXX for not having them when they see that REXX can do arithmetic to any precision. Control structures. CLIST now has adequate control structures, but one still finds many confusing programs that date back to the time when CLIST's control structures were poor. I feel sorrow and pity for the archaeologists in the twenty-third century who will spend innumerable days and nights poring over ancient CLISTs trying to fathom their meaning. Control structures and REXX grew up together. REXX fulfills every programmer's dreams about control structures. Rat's nest programs are possible in REXX, but REXX's designer took steps to penalize anyone who would abuse structured programming concepts. Clarity. CLIST programs often tax the poor programmer's analytical capabilities as he or she tries to understand how CLIST attempts to interpret data strings as expressions and then tries valiantly to prevent it from doing so. CLIST language is the incarnation of obscurity.

REXX does not think data is to be analyzed. It contents itself with analyzing verbs, variables, literals, functions, and labels, but not, thank you, REXX, data! Once you acquire the skill to write CLISTs, you find that it is akin to knowing how to repair an Edsel. The CLIST language is like nothing else in the entire spectrum of programming languages: it is best called a white elephant. REXX is becoming a kind of Esperanto, or universal language, in the programming world. It looks a lot like BASIC, PLI (especially) and C (a little ? nothing else really looks like C!). I have used REXX in IBM's VM/CMS programming system, in OS/2, and in PC-DOS, and have found that it is the same in each environment. REXX is your key to other IBM programming environments. Here in tabular form are the major differences between CLIST and REXX: Usefulness.

CLIST
Old Bad for data strings Lots of &&&&& Obscure at times Good control structures Bad for math Few useful functions Unique Prompts for positional parms Execution Differences

REXX
New Good string handling English-like Clear Excellent control structures Good for math Many good functions Common No prompting for positional parms

CLISTs are contained in libraries (PDSs) whose names end in ".CLIST." TSO is informed of the library by means of the TSO command ALLOCATE, which specifies the name of the library and the DDNAME (data definition name, abbreviated DDN) SYSPROC. The ALLOCATE command is done like this:

ALLOC DDN(SYSPROC) SHR REUSE DSN(MYPROGS.CLIST) An ALTLIB command may also be done: ALTLIB ACTIVATE APPL(CLIST) DA(MYPROGS.CLIST) REXX programs may be in the same libraries as CLISTs. This makes it much easier for everyone to start using REXX. The only penalty to pay for this peaceful coexistence is that your REXX programs must start off by telling TSO they are written in REXX, not CLIST with the comment shown. /*REXX */ ARG USERID "SEND 'HELLO' USER("USERID")"

Corresponding Features in CLIST and REXX

Conversion of one language to another requires a knowledge of both languages and how they function. CLISTs and REXX share many features. Both have good control structures such as DO WHILE. These can usually be converted without any problem. However, CLIST GOTOs cannot always be converted to REXX SIGNALs, because the latter destroy any loop or control structure they are in. You may have to rewrite the logic of CLIST GOTOs. Changing the value of a loop variable in REXX affects the outcome of the loop. An example of this is DO I = 1 to 10 and changing the value of I within the loop. CLIST does not function the same way. REXX has nothing even near GLOBAL variables. You can use ISPF Variable Services to produce the same results. CLIST examines a program statement and processes it repeatedly until all "&" variables are resolved. REXX examines a statement once only, unless you use the INTERPRET instruction. CLIST statements containing variables within variables may severely tax your conversion abilities.

The CLIST PROC statement works differently from REXX ARG. There is no one-toone correspondence. You will have to execute REXX differently without reliance on keyword parameters. REXX has no WRITENR which displays a message and leaves the cursor at the end of the line. You might consider using ISPF panels, although this is considerably more involved.

CLIST Features
AND IF &A = 1 AND &B = 2 ATTN ATTN DO ... END CLOSFILE Concatenation by juxtaposition All spaces remain. WRITE HI NICE DAY! -> HI NICE DAY! Concatenation with operator SET &NAME = WILL FRED CONTROL LIST CONTROL NOMSG CONTROL PROMPT CONTROL SYMLIST CONLIST

REXX Equivalents
& IF A = 1 & B = 2 HALT trap SIGNAL ON HALT

EXECIO with FINIS option Concatenation by juxtaposition > 1 spaces become 1 space SAY HI NICE DAY! -> HI NICE DAY! Concatenation with operator NAME = "WILL" "FRED" TRACE C CALL MSG "OFF" CALL PROMPT "ON" TRACE I

DATA LISTCAT LISTDS ENDDATA &DATATYPE IF &DATATYPE(&NUM1) = NUM "NUM" DO WHILE Error trap ERROR DO ... END &EVAL EXIT CODE(number EXIT CODE(10) EXIT QUIT File IO GETFILE

Environment commands in quotes "LISTCAT" "LISTDS"

DATATYPE function IF DATATYPE(NUM1)

DO WHILE ERROR, SYNTAX traps SIGNAL ON ERROR SIGNAL ON SYNTAX

No equivalent EXIT number EXIT 10 No equivalent EXECIO EXECIO 1 DISKR INFILE No equivalent

INFILE

GLOBAL variables GLOBAL &V1 &V2 &V3 IF ... AND IF ... OR IF (null

IF ... & IF ... IF ... NOP

GOTO GOTO ENDPROG &LASTCC and &MAXCC set after all instructions &LENGTH &LENGTH(ABCD) LISTDSI dsn Literal has no delimiter, or uses &STR() WRITE HELLO &MAXCC set after all instructions NGLOBAL NGLOBAL VAR1 &NRSTR OPENFILE PROC keyword parameters with default PROC 0 TRACE(NO) PROC keyword parameters without default PROC 0 TRACE

SIGNAL label SIGNAL ENDPROG RC set after environment commands LENGTH function LENGTH("ABCD") CALL LISTDSI "dsn" Literal uses " or ', or no delimiter SAY "HELLO"

RC set after environment commands No equivalent

No equivalent EXECIO No equivalent

No equivalent

PROC prompts for positionals PROC 1 VAR1 ARG VAR1 PROC statement PROC 1 VAR1 PUTFILE READ &var READ &NAME

ARG does not prompt

ARG VAR1

ARG (approximate)

EXECIO DISKW PULL (approximate)

PULL NAME

READ (goes into &SYSDVAL) RETURN SELECT subroutine label SUBR: PROC 1 VAR1 subroutine END subroutine SYSREF (approximate) SYSREF VAR1 &SUBSTR WRITE &SUBSTR(1:3,ABC) &STR

No equivalent RETURN (approximate) SELECT subroutine label: SUBR: ARG VAR1 subroutine RETURN subroutine EXPOSE VAR1 SUBSTR function SAY SUBSTR("ABC",1,3) No exact equivalent. Consider literal delimiters No exact equivalent. Consider PARSE [UPPER] EXPOSE

&SYSASIS

SYSCALL SYSCALL SUBROUT &SYSCAPS &SYSCPU &SYSDATE, &SYSTIME WRITE &SYSDATE &SYSDLM &SYSDSN &SYSDVAL &SYSENV &SYSFLUSH &SYSHSM &SYSICMD

CALL CALL SUBROUT PARSE UPPER SYSVAR(SYSCPU) function DATE function SAY DATE() No equivalent SYSDSN function No equivalent SYSVAR(SYSENV) function No equivalent SYSVAR(SYSHSM) function No equivalent but see PARSE SOURCE) INDEX function SYSVAR(SYSISPF) function No equivalent

&SYSINDEX &SYSISPF &SYSLC

&SYSJDATE &SYSLTERM &SYSLRACF &SYSNEST &SYSNSUB &SYSOUTLINE SET &LINE = &&SYSOUTLINE&ctr varying I) &SYSOUTTRAP OUTTRAP function SET &SYSOUTTRAP = 200 SET &SYSOUTTRAP = 0 &SYSPCMD &SYSPREF &SYSPROC WRITE THE PROC = WRITE &SYSPROC &SYSRACF &SYSSCAN &SYSSCMD

DATE("J") function SYSVAR(SYSLTERM) function SYSVAR(SYSLRACF) function SYSVAR(SYSNEST) function No equivalent OUTTRAP function LINE = LINE.I (in loop

CALL OUTTRAP "LINE.", 200 CALL OUTTRAP "OFF" No equivalent SYSVAR(SYSPREF) function SYSVAR(SYSPROC) function SAY "THE PROC = " SAY SYSVAR(SYSPROC) SYSVAR(SYSRACF) function No equivalent No equivalent

&SYSSDATE &SYSSRV &SYSSTIME &SYSTIME &SYSTSOE &SYSUID WRITE YOU ARE &SYSUID &SYSWTERM function TERMIN Variable starts with & WRITE &NAME WRITE WRITE PLEASE ENTER NAME WRITENR + - continuation WRITE PLEASE ENTER + NAME

DATE("S") function SYSVAR(SYSSRV) function TIME() function TIME() function SYSVAR(SYSTSOE) function USERID() function SAY "YOU ARE " USERID() LINESIZE function or SYSVAR(SYSWTERM)

No equivalent Variable starts no special way SAY NAME SAY SAY "PLEASE ENTER NAME" No exact equivalent continuation with "," SAY "PLEASE ENTER", "NAME"

You might also like