include a file

I tried to run your latest REXX entry (Rosetta code task: "include a file") and I got three different errors, one with Regina, another with R4, and also with Personnel REXX (all are the latest versions):

link to the Rosetta Code page:   ──►   [Include a file/REXX]


 
───────────────────────────────────────────────────────────────────09/12/2015 22:05:57
c:\►regina include
This is a program running.
     3 +++ if Open(other,'SYS:Rexxc/otherprogram.rexx','READ') then do
Error 40 running "c:\include.rex", line 3: Incorrect call to routine
Error 40.4: Too many arguments in invocation of "OPEN"; maximum expected is 2

───────────────────────────────────────────────────────────────────09/12/2015 22:06:04
c:\►r4 include
This is a program running.
Error 43 : Routine not found (or source program does not begin with a comment) (SYNTAX
)
Information: Could not find: Open  (or source file does not begin with a comment)
Error occurred in statement# 3
Statement source: if Open(other,'SYS:Rexxc/otherprogram.rexx','READ')
Statement context: c:\include.rex, procedure: include

───────────────────────────────────────────────────────────────────09/12/2015 22:06:12
c:\►type include.rex
/* Include a file and INTERPRET it; this code uses ARexx file IO BIFs */
say 'This is a program running.'
if Open(other,'SYS:Rexxc/otherprogram.rexx','READ') then do
   say "Now we opened a file with another chunk of code. Let's read it into a variabl"

   do until EOF(other)
      othercode=ReadLn(other) || ';'
      end
   call Close(other)
   say 'Now we run it as part of our program.'
   interpret othercode
   end
say 'The usual program resumes here.'
exit 0

───────────────────────────────────────────────────────────────────09/12/2015 22:07:14
c:\►rexx include.rex
This is a program running.
     3 +++ if Open(other,'SYS:Rexxc/otherprogram.rexx','READ')
Error 43 on line 3 of C:\INCLUDE.REX: Routine not found

───────────────────────────────────────────────────────────────────09/12/2015 22:10:46
c:\►

Is the REXX program expected to only be executed by a certain REXX interpreter or only under a certain operating system?   -- Gerard Schildberger (talk) 03:06, 13 September 2015 (UTC)

You need the ARexx BIFs and semantics (they're available in Regina) in order to use this Open syntax. I'm not familiar with any other REXX file I/O. --Idrougge (talk) 03:24, 13 September 2015 (UTC)
Return to the user page of "Idrougge".