REXX/ARexx Program Conversion

Most non-file I/O ARexx and Quercus Personal REXX statements can be used unchanged. There are however some signifcant differences between Personal REXX and ARexx when it comes to file handling functions. ARexx functions, such as Writech() and Writeln() which output characters and lines to files, are not functions found in standard REXX.

Also ARexx is not fussy about the statement format used when calling functions and subroutines. You can make parenthesis style calls to subroutines which have no return value, and call functions which have return values effectively throwing away the result. The former option is useful because it allows you to place subroutine arguments in parenthesis (which to my mind helps draw attention to the fact that some 'routine' is being called). Throwing away return values is also convenient, eg for discarding error values returned by a function that you know for certain will not fail.

Personal REXX is less forgiving of such liberties and in this, and other areas, tends to follow the definition of the REXX language rather more closely than ARexx itself. The Personal REXX file handling functions are based on the REXX Stream() function and you can ONLY use Call statements containing 'parenthesized arguments' if the routine has a return value (ie is a function in the true sense of the word).

Other differences include the fact that ARexx's end-of-file function, EOF(), does not exist in standard REXX so with Personal REXX functions like Lines() need to be used instead. The bottom line is that, although the structure of code does not change when porting aplicatons between the two language forms, the various file I/O functions always have to be altered. For example, a procedure that looks like this in ARexx...

   InsertFile: Procedure
   parse arg dest, source_name
   if Open(source,source_name,'r') then
     do    
       line=Readln(source) /* skip title line */    
       do while ~EOF(source)
          line=Readln(source)                
          Writeln(dest,line)                            
       end
       Close(source)  
     end
   return

would, with Personal REXX, need to be changed to something like...

   InsertFile: Procedure
   parse arg dest,source
   if Stream(source,C,OPEN READ)='READY:' then
       do		    
	   do while Lines(source)
	     line=Linein(source)
             d=Lineout(dest,line)  
	   end
	   d=Stream(source,C,CLOSE) 	
       end
   return d

One last important thing to mention concerns file contents. Even when you open a file for writing with Personal REXX - the data always gets appended to any existing contents. If you specifically want the file emptied it's necessary to use the Dosdel() function to physically remove the file. With ARexx this is not necessary - when a file is opened for writing any existing contents are lost!


Go back toReturn to page at previous level

Go back toReturn to main index page

Page last updated 21-Nov-96