[USflag] The American Programmer [USflag]
Home Programming Books for Computer Professionals Privacy Terms
           Home   > Programming   > REXX Programming   > REXX Language   > REXX and CLIST
           Home   > Programming   > Manuals   > REXX Manuals   > REXX and CLIST

Books on REXX

REXX Manuals

Books on TSO

TSO Manuals

Tutorial: Comparison of CLIST language and REXX

This will help you to convert CLIST to 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!

Usefulness.The CLIST language is like nothing else in the entire spectrum of programming languages.

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:

 

CLIST				      REXX         
    	                                       
Old 					New            
                                             
Bad for data strings		        Good string handling       
                                            
Lots of &&&&&			        English-like   
                                             
Obscure at times 			Clear          
                                             
Good control structures		        Excellent control structures
                                             
Bad for math  			        Good for math  
                                             
Few useful functions		        Many good functions
  
Unique      			        Common         
                                             
Prompts for positional parms	        No prompting for positional parms        

Execution Differences

CLISTs are generally contained in libraries (PDSs) whose names end in ".CLIST." (.CLIST not required, but recommended) 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 are generally contained in libraries (PDSs) whose names end in ".EXEC." (.EXEC not required, but recommended) 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) SYSEXEC.

The ALLOCATE command is done like this:

ALLOC DDN(SYSEXEC) SHR REUSE DSN(MYPROGS.EXEC)

An ALTLIB command may also be done:

ALTLIB ACTIVATE APPL(EXEC) DA(MYPROGS.EXEC)

REXX programs may be in the same libraries as CLISTs. If you do that, please start your REXX program with the comment shown just below. An explanation of when you need the comment and when you don't, is beyond the scope of this short paper

/*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-to-one 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                               REXX Equivalents


AND						&
 IF &A = 1 AND &B  = 2			        IF A = 1 & B = 2 

	
ATTN						HALT trap
 ATTN DO					 SIGNAL ON HALT
  ...
 END


CLOSFILE					EXECIO with FINIS option


Concatenation by juxtaposition		        Concatenation by juxtaposition
 All spaces remain.			         > 1 spaces become 1 space
 WRITE HI   NICE      DAY!		          SAY HI     NICE    DAY!
 -> HI   NICE     DAY!			          -> HI NICE DAY!


Concatenation with operator		        Concatenation with operator
 SET &NAME = WILL ¦ FRED	 	 	NAME = "WILL" ¦ "FRED"


CONTROL LIST					TRACE C


CONTROL NOMSG				        CALL MSG "OFF"


CONTROL PROMPT			         	CALL PROMPT "ON"


CONTROL SYMLIST CONLIST			        TRACE I


DATA						Environment commands in quotes
 LISTCAT					 "LISTCAT"
 LISTDS					         "LISTDS"
ENDDATA

  
&DATATYPE					DATATYPE function
 IF &DATATYPE(&NUM1) = NUM		         IF DATATYPE(NUM1) = "NUM" 


DO WHILE					DO WHILE


Error trap					ERROR, SYNTAX traps
 ERROR DO	  				 SIGNAL ON ERROR
  ...	  					 SIGNAL ON SYNTAX
 END


&EVAL				                No equivalent


EXIT CODE(number				EXIT number
 EXIT CODE(10)				        EXIT 10


EXIT QUIT					No equivalent


File IO					        EXECIO
 GETFILE	 INFILE			        EXECIO 1 DISKR INFILE


GLOBAL variables				No equivalent
 GLOBAL &V1 &V2 &V3

 
IF ... AND			 		IF ... &


IF ... OR					IF ... ¦


IF (null					IF ... NOP


GOTO						SIGNAL label
 GOTO ENDPROG				         SIGNAL ENDPROG


&LASTCC and &MAXCC				RC
 set after all instructions 		         set after environment commands


&LENGTH					        LENGTH function
 &LENGTH(ABCD)				         LENGTH("ABCD")


LISTDSI dsn					CALL LISTDSI "dsn"


Literal has no delimiter, 		        Literal uses " or ', or no delimiter
or uses &STR()				        SAY "HELLO"
WRITE HELLO	 


&MAXCC						RC 
 set after all instructions	 	         set after environment commands


NGLOBAL					        No equivalent
 NGLOBAL VAR1


&NRSTR						No equivalent


OPENFILE					EXECIO


PROC						No equivalent
keyword parameters with default
 PROC 0 TRACE(NO)


PROC						No equivalent
keyword parameters without default
 PROC 0 TRACE


PROC prompts for positionals		        ARG does not prompt
 PROC 1 VAR1	 ARG VAR1

		
PROC statement				        ARG (approximate)
 PROC 1 VAR1	 ARG VAR1


PUTFILE					        EXECIO DISKW


READ &var					PULL (approximate)
 READ &NAME	 PULL NAME


READ (goes into &SYSDVAL)		        No equivalent

	
RETURN						RETURN (approximate)


SELECT						SELECT


subroutine label 				subroutine label: 
 SUBR: PROC 1 VAR1	 			SUBR: ARG VAR1


subroutine END				        subroutine RETURN


subroutine SYSREF				subroutine EXPOSE (approximate)
 SYSREF VAR1	 				EXPOSE VAR1


&SUBSTR					        SUBSTR function
 WRITE &SUBSTR(1:3,ABC)	 		        SAY SUBSTR("ABC",1,3)


&STR						No exact equivalent.
	 					Consider literal delimiters


&SYSASIS					No exact equivalent.
						 Consider PARSE [UPPER] 


SYSCALL						CALL
 SYSCALL SUBROUT					 CALL SUBROUT


&SYSCAPS					PARSE UPPER


&SYSCPU						SYSVAR(SYSCPU) function


&SYSDATE, &SYSTIME				DATE function
 WRITE &SYSDATE					 SAY DATE()


&SYSDLM						No equivalent

	
&SYSDSN						SYSDSN function


&SYSDVAL 					No equivalent


&SYSENV						SYSVAR(SYSENV) function


&SYSFLUSH					No equivalent


&SYSHSM						SYSVAR(SYSHSM) function


&SYSICMD					No equivalent
	 					(but see PARSE SOURCE)


&SYSINDEX					INDEX function


&SYSISPF					SYSVAR(SYSISPF) function


&SYSLC						No equivalent


&SYSJDATE					DATE("J") function


&SYSLTERM					SYSVAR(SYSLTERM) function


&SYSLRACF					SYSVAR(SYSLRACF) function


&SYSNEST					SYSVAR(SYSNEST) function


&SYSNSUB					No equivalent


&SYSOUTLINE	 				OUTTRAP function
 SET &LINE = &&SYSOUTLINE&ctr	 	         LINE = LINE.I (in loop varying I)


&SYSOUTTRAP	OUTTRAP function
 SET &SYSOUTTRAP = 200	 		        CALL OUTTRAP "LINE.", 200

	
 SET &SYSOUTTRAP = 0			        CALL OUTTRAP "OFF"


&SYSPCMD					No equivalent


&SYSPREF					SYSVAR(SYSPREF) function


&SYSPROC					SYSVAR(SYSPROC) function
 WRITE THE PROC =   			        SAY "THE PROC = " 
 WRITE &SYSPROC	 			        SAY SYSVAR(SYSPROC)


&SYSRACF					SYSVAR(SYSRACF) function

	
&SYSSCAN					No equivalent

	
&SYSSCMD					No equivalent


&SYSSDATE					DATE("S") function


&SYSSRV					        SYSVAR(SYSSRV) function


&SYSSTIME					TIME() function


&SYSTIME					TIME() function


&SYSTSOE					SYSVAR(SYSTSOE) function


&SYSUID					        USERID() function
 WRITE YOU ARE &SYSUID	 		        SAY "YOU ARE " USERID()


&SYSWTERM					LINESIZE function 
						 or SYSVAR(SYSWTERM) function


TERMIN						No equivalent


Variable starts with &			        Variable starts no special way
 WRITE &NAME					SAY NAME


WRITE						SAY
 WRITE PLEASE ENTER NAME	 		SAY "PLEASE ENTER NAME"


WRITENR					        No exact equivalent


+ - continuation				continuation with ","
 WRITE PLEASE ENTER +			        SAY "PLEASE ENTER",
 NAME	 					"NAME"


The IBM Manual on REXX/CLIST

Top of Page































































































[Books Computer]

Home Programming Books for Computer Professionals Privacy Terms Contact |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |

[link page]