User talk:Idrougge

From Rosetta Code

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.
It says so in the opening comment. And it also works with ARexx, from which Regina has inherited these BIFs. Not that it matters much, since it's a demonstration of INTERPRET rather than file I/O. --Idrougge (talk) 04:01, 13 September 2015 (UTC)
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>

--Idrougge (talk) 12:38, 13 September 2015 (UTC)




Thanks, that did the trick.   I never seen the AREXX_SEMANTICS Regina option before and it was a surprise to learn of it;   that particular option which is needed to make it execute properly was introduced in Regina REXX release 3.8.   It seems strange to me that when specifying the AREXX_BIFs option, you need another option to make use of some of those BIFs.   In any case, it would be a nice idea to include what Regina option(s) a user needs to run your Rosetta Code program without errors.

Why not just include the above options in the Rosetta Code REXX program to begin with?   Also nice would be an inclusion of the

{{works|REGINA 3.8 and later, with options: AREXX_BIFS and AREXX_SEMANTICS}}


statement.   -- Gerard Schildberger (talk) 18:24, 13 September 2015 (UTC)




My apologies:   I got the syntax wrong, it should be:

{{works with|REGINA 3.8 and later, with options: AREXX_BIFS and AREXX_SEMANTICS}}


-- Gerard Schildberger (talk) 20:39, 13 September 2015 (UTC)

local/global variables

In the Rosetta Code task   Include a file   where you mentioned:

  ... This means that including a file in your program is usually not necessary, unless you want them to share global variables.'

Did you mean to say   local   variables instead?

There are very few global variables:   RC, RESULT, and SIGL,   and those might not even be considered global   (Regina REXX has a few others as well).   Also, there are things like "ON" conditions, the settings for OPTIONS, TRACE, DIGITS, FORM, FUZZ, ADDRESS, and the like which may be considered global, at least in the sense that those values are carried forward into "lower levels" of subroutines/functions.   -- Gerard Schildberger (talk) 20:39, 13 September 2015 (UTC)

If you use AFunction: PROCEDURE, it has private variables. External programs called as functions are treated as PROCEDUREs, aren't they? --Idrougge (talk) 22:31, 13 September 2015 (UTC)
Well, not quite.   External routines (programs) don't inherit any of the following:
  •   "ON" conditions
  •   numeric DIGITS
  •   numeric FUZZ
  •   numeric FORM
  •   setting for ADDRESS
  •   settings for TRACE
  •   settings for OPTIONS
  •   usage of the EXPOSE option
  •   usage of duplicated labels (routine names)

and probably some other things as well   (such as the use of the REXX API interface, but that's too complicated to get into).   But,   in general,   external programs can be thought of as PROCEDUREs, ignoring the above exceptions, and possibly others.   -- Gerard Schildberger (talk) 22:47, 13 September 2015 (UTC)

Hence, they don't share global variables with the calling program. --Idrougge (talk) 23:34, 13 September 2015 (UTC)


adding other examples

When adding other examples, please add them after any existing examples.   This is the custom at Rosetta Code, as the previous examples may refer to each other, and adding an example before those would invalidate any ordinal references.   -- Gerard Schildberger (talk) 02:22, 14 September 2015 (UTC)

I didn't do it for attention, I just wanted the least convoluted example to come first so as to ease the learning curve. --Idrougge (talk) 11:01, 14 September 2015 (UTC)
I only assumed it was done accidentally or absentmindedly, and I made no comment or implication concerning the why.   But if we all had to judge another's efforts as to being more or less convoluted than our own, and then entering one's own solution first because it's less, er ... convoluted, there would be no end to the jockeying around of various implementations (examples) --- not to mention the wars that would start.   Essentially, generally it's first come, first in the list of examples/entries.   But I wouldn't want to be a person to say another programmer's code is (more) convoluted;   that would just lead to making judgements about other peoples coding efforts and quality.   If someone's code is more concise, or shorter, or better documented, or quicker, has more options, or easier to peruse, ... (or pick a quality) ...   then let the example/entry speak for itself.   There isn't any reason to get insulting about other programming efforts (and I'm assuming that calling a solution convoluted could be construed as insulting to most programmers) in an open forum such as here on Rosetta Code.   In addition, I'm not sure about your meaning behind the learning curve;   I never assumed that Rosetta Code is about teaching people on learning how to program in a particular programming language, only to show a method (or methods) in solving a particular (Rosetta Code) task, and also to show (multiple) algorithms in solving problems (so as to illustrate different approaches with the tools that a particular programming language has), and see how a solution(s) could be implemented.   Most computer programming languages have many excellent tutorials on teaching how to learn that language.   If teaching is part of your intent, then plenty of comments in the program explaining what the statements do (specifically or generally) would be a good start.   -- Gerard Schildberger (talk) 20:21, 14 September 2015 (UTC)
I don't want to get involved in any conflict, so I'll refrain from further comments. --Idrougge (talk) 21:59, 14 September 2015 (UTC)
There is nothing wrong about asking questions or having a disagreement, as long as the statements aren't inflammatory or if the argument starts getting condescending, insulting, and/or judgmental (or in another words, casting stones).   If one can't make comments without getting offensive, then nothing said is the wiser choice.   Too often (alas, even among Rosetta Code old-timers), a programmer's ego creeps into the best intended discussion, and those words will be there forever.   -- Gerard Schildberger (talk) 00:01, 15 September 2015 (UTC)


And, if nobody else said it, a belated welcome to Rosetta Code!   I'm sure you're going to enter some noteworthy entries/examples/solutions.   There are plenty of unsolved/unentered Rosetta Code tasks (with regarding to REXX).   Just in case you're new to the navigation around Rosetta Code, check out this link:

[Reports: tasks not implementd in REXX].


  -- Gerard Schildberger (talk) 00:01, 15 September 2015 (UTC)

palindrome detection

You're using a non-ANSI function, compress.   You could just use the SPACE(xxx,0) BIF instead.

The upper function isn't available in most REXXes.   You could just use the translate BIF instead.

Failing that, you could add the   {{works with}}   template thingy for AREXX and/or Regina with the AREXX stuff.

-- Gerard Schildberger (talk) 02:45, 14 September 2015 (UTC)




I just noticed that the text of the Rosetta Code task   palindrome detection   had changed (apparently, some time ago), so I deleted my 2nd REXX version and re-did version 1 to comply with the new task's requirements.   Even after the wording in the task prologue and task requirements changed, it still seems a bit fuzzy and slightly contradictory (see the talk section).   But, it was the author's first attempt at a Rosetta Code task, so there's that.   -- Gerard Schildberger (talk) 02:45, 14 September 2015 (UTC)


Loops/For

The Rosetta Code task requirement(s)   Loops/For   states:

       Show how two loops may be nested within each other, 
       with the number of iterations performed by the 
       inner  for  loop being controlled by the 
       outer  for  loop.


(The highlighting was added by me.   Note that both inner and outer loops are both FOR loops.)

This particular Rosetta Code task isn't about using the simplest DO loop,   but to demonstrate how the outer DO loop with a FOR construct is to control the inner DO loop with a FOR construct.   I do agree that the inner DO loop can be coded more simpler,   (and indeed, it could've even been coded without a DO loop),   but the task's requirements dictated/directed otherwise.   I don't know if the task's author had in mind DO loops or FOR loops,   but I interpreted the author's intent as a DO loop with a FOR keyword to control the number of iterations,   which is the closest construct that REXX has to mimic a FOR statement that is used in other computer programming languages.     -- Gerard Schildberger (talk) 19:49, 4 June 2020 (UTC)