User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 4:37 am

Greetings, back in the day (mid '90s) while working with IBM at Rochester MN
(USA) I had the need for the square root function, in REXX (believe it or not).

I wrote a routine for REXX (for the S370 system) that provides not only the
square root function sqrt(n) but also the transcedental functions--
trigonometric, exponential, logarithmic, hyperbolic -- and I placed these
routines in a REXX script called COMPUTE.REX/

When Dougie Lawson (also former IBMer) pointed me to oorexx on the RPi, I got
very nostalgic for my COMPUTE.REX and the memory of a day when the sqrt(n)
function was missing from a 'computer' language. I pulled it out of my archives
and decided to share it with yous guys.

oorexx (regina-rexx) is available on the repositories; so, I downloaded it
and voila-- COMPUTE.REX still works, no hits, no runs, no errors (if you
can stand the baseball metaphor (the season is fast approaching!)

I read the man page for regina-rexx (after downloading for RPi) and found that
it 'still' has no sqrt(n) function! BIG surprise...

You can download regina-rexx with:

Code: Select all

sudo apt-get install regina-rexx
Read through the man page with:

Code: Select all

man rexx
For historical purposes (and just fun) I have uploaded my COMPUTE.REX module
from 1993 right here in this forum so that every RPi REXX user can 'finally'
have a sqrt(n) function... as well as arbitrary precision, and transcendentals;
including a couple of ways to calculate PI.

I'm not going to gaurantee that COMPUTE.REX is suitable for any purpose
what-so-ever, nor that it is complete, nor that it doesn't have bugs! :)
And, as always, we are somewhat embarrassed by our own old code... we would
surely not have done it 'that way' would we?

But, here it is for fun and enjoyment (and a bit of history to boot).

The script can be run embedded, can be placed into another script, or
can be run interactively. To start, I'll just show you how to call it in
regina-rexx at the command line to compute sqrt(2) !

To expand the tarball use:

Code: Select all

cd ~/working_directory
tar -xvf compute.tar.gz --gunzip
From within the directory where you expand the tarball, run:

Code: Select all

rexx ./compute.rex 'sqrt(2)'
Now, for a little fun...

Code: Select all

rexx ./compute.rex 'sqrt(2)@75'

Code: Select all

rexx ./compute.rex 'pia()@200'
PS This is the shasum for the tarball

Code: Select all

a6cf2412916c346b50bc699a59d965d44ff25c2b   compute.tar.gz
Attachments
compute.tar.gz
COMPUTE.REX
(4.03 KiB) Downloaded 280 times
marcus
:ugeek:

User avatar
DougieLawson
Posts: 38549
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 11:49 am

Nice.

Here's my latest rexx program

Code: Select all

#!/usr/bin/rexx
/* Rexx */

days.1 = 'Monday'
days.2 = 'Tuesday'
days.3 = 'Wednesday'
days.4 = 'Thursday'
days.5 = 'Friday'
days.6 = 'Saturday'
days.7 = 'Sunday'
say date('d')
dayname = date('w')

do i = 1 to 7
  if days.i = dayname then daynum = i
end

weeknum = (date('d') - daynum + 10) % 7

say weeknum
it's crude and ugly but it gets the job done. It's a much cleaner syntax than yucky python.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 5:48 pm

DougieLawson wrote: Here's my latest rexx program ...
Thanks Dougie, and for someone who may be watching but hasn't grown up with BASIC or REXX @mathboy4life;

... the highlight of REXX is that everything is a string (yes, everything); numbers, arrays, the code, objects--- all of it is represented by 'strings' which are interpreted as stuff like numbers (what is called a REXX number) or objects like lists of 'things' but represented as only 'strings'.

The simple idea behind REXX was to provide a language for IBM managers (simple people, most of which have had full frontal labotomies), operators, secretaries, support reps, accountants, etc... all of which had a singon to a 370 system mainframe (usually using a $5000 color 3279 terminal sitting in their office where an iMac sits today) to get their mail, and to do tasks involving metrics, data mining, 'managing' all sorts of stuff--- WITHOUT having to become a full fledged competant programmer. Mike Cowlishaw (UK IBMer) dreamt this up while the rest of the mainframe world was using klunky scripting tools like exec2. Well, it caught on big time, Mike was awarded a fellowship with IBM (five years of funding to do whatever he liked), and many people 'programmed' who were not necessarily programmers... even us professional programmers used it!

This was the same goal exactly the same goal of Kemeny and Kurtz at Dartmouth college in the US; ca. 1964. BASIC in combination with DTSS (Dartmouth Time Sharing System) became a way for non-programmers to program... there were terminals all over campus at Dartmouth in 1964 (first college ever to have an IT department which taught computer science classes to English majors!

But, BASIC had datatypes (numbers, and strings). REXX has no types. Everything is a string, and strings of characters are what people typically know how to use; without much study. Cowlishaw's book was about the size of the C K&R, and was an easy two hour read. VM's Conversational Monitor System (CMS) and REXX gave IBMers and their customers the ability to leverage the full power of the 370 system mainframes with elegance and ease.

There is still a huge REXX language following on the net today; and thousands of people are still leveraging the power of the king of languages--- REXX. (or Qeen, Regina) Long live the Queen)

Peace
marcus
:ugeek:

User avatar
Douglas6
Posts: 4850
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 6:00 pm

MarkHaysHarris777 wrote:if you can stand the baseball metaphor (the season is fast approaching!)
Um, actually, the season started almost two weeks ago.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 6:05 pm

Douglas6 wrote:
MarkHaysHarris777 wrote:if you can stand the baseball metaphor (the season is fast approaching!)
Um, actually, the season started almost two weeks ago.
ha! :D yeah, I'm talking about the 'Honkers' season (Rochester MN, um we have geese) and hotdogs, and beer, and sitting out in our little local stadium under the sun ... you know ... this summer!

We don't do cricket here (now there's a game for you... baseball for men!) We had a local Brit from Austrailia explain the game to a bunch of us at church one Saturday morning... whew, that is a serious sport...

... are hot dogs and beer a 'thing' at cricket matches?
marcus
:ugeek:

User avatar
Douglas6
Posts: 4850
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 6:14 pm

MarkHaysHarris777 wrote:are hot dogs and beer a 'thing' at cricket matches?
I haven't a clue. But they probably put ketchup on the hot dogs, yuck.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 7:05 pm

Ah lovely old REXX - I used to enjoy that as Amiga ARexx, then again on OS/2 Warp. I really should get familiar with it again.

asandford
Posts: 1998
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat Apr 16, 2016 11:22 pm

DougieLawson wrote:Nice.

Here's my latest rexx program

Code: Select all

#!/usr/bin/rexx
/* Rexx */

days.1 = 'Monday'
days.2 = 'Tuesday'
days.3 = 'Wednesday'
days.4 = 'Thursday'
days.5 = 'Friday'
days.6 = 'Saturday'
days.7 = 'Sunday'
say date('d')
dayname = date('w')

do i = 1 to 7
  if days.i = dayname then daynum = i
end

weeknum = (date('d') - daynum + 10) % 7

say weeknum
it's crude and ugly but it gets the job done. It's a much cleaner syntax than yucky python.
Did you use XEDIT to write it?

User avatar
DougieLawson
Posts: 38549
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Apr 17, 2016 1:20 am

I use the rexxla OOREXX, it was initially installed to run some code on my machine that's written by a friend who had three years in Kingston, NY working as a VM/CMS developer. Steve logs in to my RPi B+ from his house and uses half of our shared 2TB NAS box for backing up his data (off-site, remotely).

That NAS for his off-site backups has been online since 2011, it's been running on a B+ since Feb 2015.

I've not used a real (modern) VM system or xedit since July 2003. I do most of my REXX programming on z/OS, TSO & ISPF rather than VM, CMS and XEDIT. My VM skills are a little bit rusty.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Dutch_Master
Posts: 362
Joined: Sat Jul 27, 2013 11:36 am

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Apr 17, 2016 2:09 am

MarkHaysHarris777 wrote:... are hot dogs and beer a 'thing' at cricket matches?
Shocking, utterly shocking my dear fellow! :o :shock: The noble Art of Cricket requires proper nutrition, hence it's tea and strawberry cake, occasionally someone slips in some raspberries somewhere, but that indulgence is allowed, in moderation, of course.

Thus would answer a true Englishman, based on my observations of a) the game when it's covered on the BBC, and b) the public visible on said coverage :roll: :mrgreen:

(always wondered why Americans insist on naming a game where one carries the oddly-shaped oval(-ish) ball in the hand as "football" where it clearly isn't played by the foot :P )

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Apr 17, 2016 2:35 am

Dutch_Master wrote: (always wondered why Americans insist on naming a game where one carries the oddly-shaped oval(-ish) ball in the hand as "football" where it clearly isn't played by the foot :P )
Well, there is the kickoff, the punt, and the extra points 'kicked' after a touchdown; other than that... oh, beats me.

The more interesting question is why certain American men are paid millions of dollars per year to move a big's bladder down a cow pasture... I suppose its because they 'move it' whilst risking permanent brain damage (what little they had to begin with)... but again, beats me ? :?

But baseball... aaah... the best. Beyond the dogs, brats, and beers... all about stats, numbers, programming... and did I mention the dogs and beers? aaah.

:mrgreen:
marcus
:ugeek:

User avatar
DougieLawson
Posts: 38549
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Apr 17, 2016 11:09 am

MarkHaysHarris777 wrote:But baseball... aaah... the best. Beyond the dogs, brats, and beers... all about stats, numbers, programming... and did I mention the dogs and beers? aaah.
I've always wondered why the game played by infants school kids was renamed from Rounders to "Baseball".
https://en.wikipedia.org/wiki/Rounders
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Heater
Posts: 15509
Joined: Tue Jul 17, 2012 3:02 pm

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Apr 17, 2016 11:34 am

If you read the article you linked to you will find that:

"The game of rounders has been played in England since Tudor times, with the earliest reference being in 1744 in A Little Pretty Pocket-Book where it was called "base-ball" by John Newbery."

So it's been called "base-ball since as far back as we know.

When did it get renamed to "rounders"?
Memory in C++ is a leaky abstraction .

Paulwood
Posts: 51
Joined: Mon Nov 04, 2013 10:30 am

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Tue May 10, 2016 11:54 am

I am so glad I found you can run REXX on the Pi! I still have a 1984 presentation on REXX and use to use it all the time (yes much easier than python!) I just had need to take two css files full of email addresses (mail chimp exports) most email addresses were in both, but some were unique to each file. I copied everything from one file to the next and sorted them and used a quick rexx program to compare the lines and write out a new file of the unique lines. Took about 20 minutes to write and test it and I havent touched REXX in 10 years!

Here the program if anyone wants to look at it. The email addresses are the first of the CSV entries in the file.

Code: Select all

/*
*  remdups.rex
*  Function: Remove duplicate email adress lines
*  HISTORY
*  Created: PMW 05/09/16 - 12:25
*  Lastmod:
*/
/*-------------------------*/
/* initilize variables     */
/*-------------------------*/
say "Begin"

signal on error
signal on novalue
signal on syntax
signal on halt
/*-------------------------*/

dups = 0
unique = 0
total = 0

infile="combinedlist.csv"
outfile='prunedlist.csv'

/*-----------------------------------*/
/* read out the first record         */
/* write out the first record        */
/*-----------------------------------*/
inrec1=linein(infile,1,0)
total = 1
z = lineout(outfile, inrec1)
unique = 1

/*--------------------------------------------------*/
/* main processing                                  */
/* - read a line                                    */
/* - parse the line                                 */
/* - compare email from inrec1 and inrec2           */
/* - if they match, move 2 to 1, read next, iterate */
/* - else write out rec1, read new, iterate         */
/*--------------------------------------------------*/

do until lines(infile)=0
   inrec2=linein(infile)
   total = total + 1
   parse value inrec1 with email1 ',' extra
   parse value inrec2 with email2 ',' extra
   if email1 = email2 then 
      	do
         	inrec1 = inrec2
         	dups = dups + 1
        	iterate
		end
   z = lineout(outfile,inrec1)
   unique = unique + 1
   inrec1 = inrec2
end
/*-----------------------------------*/
/* write out last line               */
/*-----------------------------------*/
z = lineout(outfile,inrec1)

/*-----------------------------------*/
/* close the file                    */
/*-----------------------------------*/
outline='   '
z=lineout(outfile,outline)
z=lineout(outfile)
/*-----------------------------------*/
/* output results                    */
/*-----------------------------------*/
say "total records  = " || total
say "duplicates     = " || dups
say "unique records = " || unique
say "All done."
exit


error:
say 'error big time error'
say condition()
say condition('C')
say condition('D')
say condition('I')
say condition('S')
exit 999
halt:
say 'halt big time error'
say condition()
say condition('C')
say condition('D')
say condition('I')
say condition('S')
exit 998
syntax:
say 'syntax big time error'
say condition()
say condition('C')
say condition('D')
say condition('I')
say condition('S')
exit 997
novalue:
say 'no value big time error'
say condition()
say condition('C')
say condition('D')
say condition('I')
say condition('S')
exit 996

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Tue May 10, 2016 3:55 pm

Paulwood wrote:I am so glad I found you can run REXX on the Pi! ...
Are you using Regina?

... OOREXX from RexxLA is also available in sources, and they will build right there on your PI ! (this does take some time... about 40 minutes?)

OORexx is the object oriented version from IBM; was popular back in the OS/2 Warp days.

Regina REXX has two flavors (both installed on the PI from the repositories... regina, and rexx) The difference in the interpreters is that Regina supports add-on modules (like maybe gpio libraries in C; haven't tried it yet) while the rexx counterpart does not. The install of oorexx will overwrite the rexx from regina, as will it also overwrite the man page; so if you want to preserve those be sure to move the man page to /usr/local/share and move the rexx interpreter to /usr/local/bin/ before installing oorexx. That way you can have all three on your PI at the same time without conflict. Oh, by the by, you'll also have to rename 'rexx' to 'rex' /

Long live the Rexx, long live Regina!
marcus
:ugeek:

Paulwood
Posts: 51
Joined: Mon Nov 04, 2013 10:30 am

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sat May 14, 2016 11:07 am

MarkHaysHarris777 wrote:Are you using Regina?
I'm not a 100% sure, but I beleive it is REXX since that is the command I used. I'm going to have to experiment with Regina to see if I can get the GPIO to work.

As for OOREXX...we'll see. I have a mental block about OO programming, maybe I just learned programming too long ago and with four grandsons that live nearby 5, 4, 3, and 2, I never seem to have the time to work on the projects I want to...but I do get to play with some cool kids toys :D

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Mon Jun 06, 2016 3:29 pm

Dougie, a question about your code. Is this bit:
DougieLawson wrote:

Code: Select all

do i = 1 to 7
  if days.i = dayname then daynum = i
end
done that way because rexx doesn't have hashes?
("Because I could" is also perfectly okay, too.)

You may find strftime() syntax yucky, but that program can be replicated with:

Code: Select all

#!/bin/sh
date +%j
date +%V
if it's printing the Julian day and the ISO week number.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
DougieLawson
Posts: 38549
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Mon Jun 06, 2016 7:43 pm

I did say it was ugly code. I wrote it that way so I can run it on Raspbian or a mainframe running z/OS or z/VM.

REXX has subscripted (stem) variables and that's as far as it goes. No hashes, no dictionaries, no lists.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Tue Jun 07, 2016 11:57 am

DougieLawson wrote:REXX has subscripted (stem) variables and that's as far as it goes. No hashes, no dictionaries, no lists.
I think you may be doing Rexx down a bit. It looks like you can use stems as hashes:

Code: Select all

#!/usr/bin/env rexx

str="Monday Tuesday Wednesday Thursday Friday Saturday Sunday"
d=date('w')
say 'Today is'
say d

do i=1 to words(str)
   w=word(str, i)
   days.w=i
end

say 'Day of week is'
say days.d
I remember writing a lot of ARexx around 1990. Sadly, I've forgotten most of the syntax.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

pgutti
Posts: 13
Joined: Sun Dec 11, 2016 8:43 pm

Regina-REXX error on sysloadfuncs

Mon Dec 12, 2016 8:30 pm

Since a few weeks i run a raspberry app, my very first use of unix and linux. In the past i used Rexx very often, on various IBM Platforms. Now i'm very happy about that this wonderful scripting languange is available under Linux/Debian.

Under Regina i tried to load regutil functions. But this ends in an error:

call rxfuncadd ’sysloadfuncs’, ’regutil’, ’sysloadfuncs’
call sysloadfuncs

Error 13 running "/home/pi/AICC/runAICC", line 4: Invalid character in program
Error 13.1: Invalid character in program "('e2'X)"

Any expierience?

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Tue Dec 13, 2016 1:40 am

Instead of

Code: Select all

call rxfuncadd ’sysloadfuncs’, ’regutil’, ’sysloadfuncs’
use

Code: Select all

call rxfuncadd 'sysloadfuncs', 'regutil', 'sysloadfuncs'
You were using a non-ASCII character instead of single quote.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

pgutti
Posts: 13
Joined: Sun Dec 11, 2016 8:43 pm

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Tue Dec 13, 2016 7:09 am

You may be right: i copy-pastet this fincion call from pdf running under Mac OS into the VPN window!

pgutti
Posts: 13
Joined: Sun Dec 11, 2016 8:43 pm

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Dec 18, 2016 6:16 pm

With the Raspberry Pi installation, we get a very nice programming editor: Geany. It displays almost any programming language syntax sensitive. Very, very helpful when coding complex scripts. And nice looking too!

You find it under Menu->Programming->Geany.
Rexx is not included ((:-(( but easy to enable: See https://wiki.geany.org/config/rexx
Attachments
Captura de pantalla 2016-12-18 19.11.03.png
Captura de pantalla 2016-12-18 19.11.03.png (45.95 KiB) Viewed 5916 times

User avatar
DougieLawson
Posts: 38549
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Sun Dec 18, 2016 6:39 pm

vim will colourise a REXX program in much the same way, but without needing a full-fat GUI.

I've just installed the REXX v5 beta on all of my systems, there's a downloadable Raspbian Jessie *.deb file on Sourceforge for it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
scruss
Posts: 3082
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Regina-REXX and the COMPUTE.REX module for Dougie Lawson

Mon Dec 19, 2016 12:56 am

yeah, but Dougie, it's vim: Linux's secret weapon for repelling users. Geany's okay and it's installed as standard.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Other programming languages”