User talk:Idrougge
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)
- Then you'll need to include some sort of statement reflecting the needs of your REXX program so that it can be executed correctly. You should probably also add a: {{works|Regina with the option AREXX_BIFFS}} to the REXX section header. You may also want to add that it ONLY works with Regina REXX.
- I did not (and can not) see where it states that the REXX program requires Regina REXX (or the AREXX REXX interpreter) and that it also requires a special Regina option to work. This is what the {{works|xxx ...}} template is for, and it doesn't require the casual reader to delve into reading the opening comments within a program. The same should be done with the first example: add a {{works| CMS and TSO REXX compiler}}. If you don't know how add that, I could insert the appropriate templetes so you can include them in the future. -- Gerard Schildberger (talk) 04:17, 13 September 2015 (UTC)
Perhaps I'm doing something silly, but Regina REXX (3.9.1) is still giving me fits:
───────────────────────────────────────────────────────────────────09/12/2015 23:29:37 c:\►regina -oAREXX_BIFS 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 23:29:42 c:\►regina --options=AREXX_BIFS 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 23:29:57 c:\►r391 --options=AREXX_BIFS 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 23:32:47 c:\►
Is there something that I'm (easily) overlooking or am I doing something wrong but can't see it?
I also tried to run it with having the environmental variable REGINA_OPTIONS to have the AREXX_BIFS option included. Still no joy. -- Gerard Schildberger (talk) 04:30, 13 September 2015 (UTC)
- Try this:
<lang rexx> /* Include a file and INTERPRET it; this code uses ARexx file IO BIFs */ OPTIONS AREXX_BIFS OPTIONS AREXX_SEMANTICS say 'This is a program running.' if Open(other,'other.rexx','READ') then do
say "Now we opened a file with another chunk of code. Let's read it into a variabl"
othercode=
do until EOF(other) othercode=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 </lang>