OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Jan-Erik Lärka on October 01, 2024, 06:58:57 pm
-
I see that the knowledge of REXX is somewhat limited even with OS/2 users.
Classic Rexx (by IBM) is the default scripting language in OS/2, eComStation and ArcaOS and one just need a simple text editor and write in fairly plain English.
It allow you as a user to write scripts to aid you with certain tasks and it is well integrated with the system so that you don't need to specify an executable to run a script, but it also drive applications as the "engine" written with for example DrDialog, VX-REXX and even code you can write yourself and compile.
It is not possible to create reusable text libraries of code to just call, but one can write functions in the script that perform certain tasks. It's is however possible to use external compiled libraries.
Regina Rexx (by Mark Hessling) is more modern, very similar to Classic Rexx, but lack the system integration.
It is more up to date than Classic Rexx and probably also somewhat more reliable.
Object Rexx (by IBM) addressed some of the shortcomings of Classic Rexx, and one can switch to it in OS/2, eComStation and ArcaOS, while the way to write code also evolved and introduced ~ and arrays with [] but also external reusable code libraries, written in plain text Object Rexx.
Object Rexx is just as well integrated with the base OS as Classic Rexx, can run and use Classic Rexx scripts end external compiled libraries and be the engine for DrDialog, VX-REXX etc., but was never set as default due to that the OS/2 version had some flaws caused by the compiler used, if I remember correctly.
Open Object Rexx (by RexxLA) has refined what IBM created with Object Rexx and also cleaned up some syntax and introduced a lot of useful and powerful stuff. We now have an up to date and current ooRexx back ported to OS/2 but the integration found in Classic Rexx and Object Rexx is missing so DrDialog, VX-REXX etc. can not benefit from the new features, easier and simpler way to express complicated information and relations etc. but still need to rely on those old scripting engines to be present. If we'd have the intergration Classic Rexx and Object Rexx could be phased out in favor of the new and open version. What we need is what I express as the integration part and that it can run in any command line environment, not only 4OS2.
So what can one do with REXX you wonder?
Alex Taylor has for example written some excellent software that you may have used, both command line scripts and GUI applications like Naps and ANPM to mention a few.
Glassman wrote AutoWGet that is very helpful to fetch things from the internet
and much more...
I use ooRexx to automatically create documents with maps to send to owners of land at work, drive office applications, vector drawing applications such as OpenOffice Draw, Calc etc. split/merge/extract text PDF documents with GhostScript and retrieve routes from google between places etc.
I would like to get your attention to push for an update to the wps integration stuff and enable it for ooRexx on OS/2, without reinventing the wheel from scratch.
The problem is that IBM have a cross licensing agreement with another party (Amiga)?!
-
Fairly complete description, Jan-Erik. Thanks.
Some of these details I didn't know very well - as far as I can remember, Object REXX was heavily criticized on Warp 4 and almost never used - I stayed on Classic REXX, like many of us.
I also used DrDialog and GPF Rexx (too bad they're discontinued) to build some fancy apps for my theatre activities and boy, was it fun.
I'm currently too involved in porting OS/2 apps from the open source entourage so I don't have time, but in the future I'm willing to write some other useful GUI application in REXX, mostly for my activities as a musician and electronic engineer.
The interesting part of REXX on OS/2 is its integration with the system and SOM - I see many similarities between {OS/2, SOM, REXX} and the .NET environment on Windows and Linux with its Powershell scripting language, though I prefer the more elegant REXX syntax (Powershell can really be a drag). So yes, being able to integrate Regina or ooRexx with OS/2 (and SOM) would give us a big step forward.
Mentore
-
Is Open Object Rexx (by RexxLA) what was/called NetRexx? I vaguely remember some presentation on some Warpstock Europe some time ago...
-
Is Open Object Rexx (by RexxLA) what was/called NetRexx? I vaguely remember some presentation on some Warpstock Europe some time ago...
AFAIK, Andi, NetRexx was/is (?) something related to Java: quoting the NetRexx website
"NetRexx is a general-purpose programming language inspired by two very different programming languages, Rexx and Java."
Though I feel Netrexx and ooRexx have many things in common, ISTR there is also a converter from / to Netrexx under OS/2.
Mentore
-
NetRexx is an implementation of Rexx that runs on a Java virtual machine. The powerful thing about it is that it can access many Java libraries. If you prefer Rexx, but want to write Java programs, NetRexx may be useful.
-
Hello Jan-Erik
I would like to get your attention to push for an update to the wps integration stuff and enable it for ooRexx on OS/2, without reinventing the wheel from scratch.
The problem is that IBM have a cross licensing agreement with another party (Amiga)?!
I don't have knowledge on this area, so I'm just asking, what kind of WPS and ooRexx integration do you expect or need?
Is it something like "IBM's Object Rexx has this WPS integration, I need the same one for ooRexx, because it is currently missing on that open open source project"?
Is there too much WPS integration on IBM's Object Rexx? Will it be a long project to do that?
Regards
-
NetRexx
- The last version that ran with our Java (1.)6 was 3.04, as they then compiled it to require features introduced with Java (1.)8 in later NetRexx versions
- I understand that NetRexx create byte code that the java engine run, but with the additions of Rexx like libraries that add useful features that resemble Rexx.
- It claim to be like Rexx, but due to the underlying requirement to follow a ceratin structure the code one can write, need to have a certain structure that I don't recognize from Rexx.
Consensus was that Object Rexx for OS/2 wasn't good enough (good features, but bad memory handling, speed and stability due to the complier used), thus not set as default.
WPS integration
Both IBM Classic Rexx (crexx from now on) and IBM Object Rexx (orexx from now on) is integrated with the system, that's why you need to switch rexx interpreter with the command SWITCHRX (see the code of SWITCHRX.CMD in your OS2-folder) that aslo reregister files such as
REXXSC.DLL
OREXXSC.DLL
REXXSOM.DLL
OREXXSOM.DLL
REXXWPS.DLL
OREXXWPS.DLL
that enable crexx and orexx to be the scripting engine for applications as well as talk to the wps through SOM etc. etc. that interact with the scripting engine to launch it from command line without first typing a scripitng engine name such as rexx <script_to_run.ext>. Guess DB2 intergation and other rexx enabled applications use the currently enabled scripting engine.
When I talk about WPS integration I also mean the programming interface "rexxsaa", not just SOM or WPS.
/*
* Filename: dbug.cpp
* Author: JanErik
* Created: Sun Oct 6 2024
* Purpose: Compile into dbug.exe and debug "it" with Watcom Visual Debugger (wdw) to correct libraries (dll:s) you write for rexx (see unimix rexx .dll)
* Changes:
*/
#define INCL_REXXSAA
#include <rexxsaa.h>
#include <iostream.h>
int main(int args, char *argn[]) {
LONG return_code; /* interpreter return code */
RXSTRING argv[1]; /* program argument string */
RXSTRING retstr; /* program return value */
SHORT rc; /* converted return code */
CHAR return_buffer[250]; /* returned buffer */
/* build the argument string */
CHAR retval[1];
retval[0] = '\0';
if( args > 2 ) {
MAKERXSTRING( argv[0], argn[1], strlen( argn[1] ) );
} else {
MAKERXSTRING( argv[0], retval, strlen( retval ) );
}
/* set up default return */
MAKERXSTRING(retstr, return_buffer, sizeof(return_buffer));
return_code = RexxStart(args, /* one argument */
argv, /* argument array */
argn[1], /* REXX procedure name */
NULL, /* use disk version */
NULL, /* default address name */
RXCOMMAND, /* calling as a subcommand */
NULL, /* no exits used */
&rc, /* converted return code */
&retstr); /* returned result */
/* process return value */
/* need to return storage? */
if (RXSTRPTR(retstr) != return_buffer)
DosFreeMem(RXSTRPTR(retstr)); /* release the RXSTRING */
return 0;
}
There's a nifty script by Steven Levine out there that can enable one or the other on the fly, but then one can't rely on that a certain is enabled but has to fall back to always has to assume crexx to start with. >:(
crexx is not aware of any of the new features, so with it still the default it is not really useful.
-
Jan-Erik, you wouldn't mind if I borrowed some of your opening description for a wiki page on the ArcaOS site, would you? An interesting question cropped up in the bug tracker today, and I had to over-simplify my answer. I realized that we really didn't have anything REXX-related in the wiki (though we do have pages for DOS and Win-OS/2 and the like).
That same question holds true for everyone else in this thread, as this is some good, solid info which bears repeating, I think.
-
Jan-Erik, you wouldn't mind if I borrowed some of your opening description for a wiki page on the ArcaOS site, would you? An interesting question cropped up in the bug tracker today, and I had to over-simplify my answer. I realized that we really didn't have anything REXX-related in the wiki (though we do have pages for DOS and Win-OS/2 and the like).
That same question holds true for everyone else in this thread, as this is some good, solid info which bears repeating, I think.
I don't mind.
-
I see that the knowledge of REXX is somewhat limited even with OS/2 users.
[...]
It is not possible to create reusable text libraries of code to just call, but one can write functions in the script [...]
I don't know; doesn't this mean exactly the opposite?
Syntax
┌───────────────────────────────────────────────────────────────────────────┐
│ │
│ ──SysSaveRexxMacroSpace( file )─────────────────────────────────── │
│ │
└───────────────────────────────────────────────────────────────────────────┘
Description
Saves all functions in the REXX macrospace to a file. These functions can be loaded again later using the SysLoadRexxMacroSpace function.
The problem is that IBM have a cross licensing agreement with another party (Amiga)?!
I would say so: https://datagubbe.se/rexxtut/ (https://datagubbe.se/rexxtut/)
-
While I for one would like to see any enhancements made to Rexx in the outside world integrated into ArcaOS too, this made me think as well...
I see that the knowledge of REXX is somewhat limited even with OS/2 users.
[...]
So what can one do with REXX you wonder?
Alex Taylor has for example written some excellent software that you may have used, both command line scripts and GUI applications like Naps and ANPM to mention a few.
Glassman wrote AutoWGet that is very helpful to fetch things from the internet
and much more...
I use ooRexx to automatically create documents with maps to send to owners of land at work, drive office applications, vector drawing applications such as OpenOffice Draw, Calc etc. split/merge/extract text PDF documents with GhostScript and retrieve routes from google between places etc.
Anything that you can show?
I myself have written a few dozens of simple rexx programs. While they may not be spectacularly useful for everyone I wrote them in REXX with the idea that anyone could see right away how stuff is done, and maybe this could pique the interest of more people (or new users?) than what is currently included with the system -- who doesn't like a good tutorial? So, I could try and turn what I have into one <g> if you guys think it could be of interest and are willing to provide useful feedback.
Your thoughts?
-
As my own REXX is terrible (by my own admission), I would welcome any additional tutorial material to help me improve upon it. ;)
-
OK, to try and not derail this thread so we can further consider the feasibility of modernizing REXX support in ArcaOS, there you go: a new thread for REXX tutorials (https://www.os2world.com/forum/index.php/topic,3846.0.html) ; )
-
I don't know; doesn't this mean exactly the opposite?
Syntax
┌───────────────────────────────────────────────────────────────────────────┐
│ │
│ ──SysSaveRexxMacroSpace( file )─────────────────────────────────── │
│ │
└───────────────────────────────────────────────────────────────────────────┘
Description
Saves all functions in the REXX macrospace to a file. These functions can be loaded again later using the SysLoadRexxMacroSpace function.
It's not directly editable or in plain text, it's what one would think of as "compiled" or as better described, tokenized into machine readable code (see more accurate info below).
It's also a hassle to create functions that way, the code for it has to be written into one script that gets tokenized and save the code on the side.
The benefit of Object Rexx and ooRexx is that one can write rexx code in a plain text file and call one or more functions/methods as it behave as part of the main script.
from
Rexx Tips & Tricks, Version 3.60
Another method to create a token image of your REXX program is to load the REXX program into the macro space and save the macro space into a file. This will produce a token image of your REXX program that you can reload into the macrospace and execute it from there. This method also avoids the 64 K limit of the EAs. (see REXXCC - a REXX "compiler")
In this case you need an additional loader to load the token image into the macro space again before you can execute it.
-
SysSaveRexxMacroSpace( file )[...]
Saves all functions in the REXX macrospace to a file. These functions can be loaded again later[...]
It's not directly editable or in plain text,
Bummer : /
I used to use PPWizard to keep a Rexx code library of sorts for my bigger scripts or bits that were likely to change. Testing Sys*Macro had been on my to-do list since I first read about them in RexxUtil.inf (rexx.inf does not mention them), but never got round to it, and now I never will.
The benefit of Object Rexx and ooRexx is that one can write rexx code in a plain text file and call one or more functions[...]
You bet, sold : )
I find it interesting that while 'tokens' appear in cRexx messages up to 5 times, they are mentioned only once in Rexx.inf (and never in rexxutil.inf). It should come as no surprise then that many (most?) people never get to even know about the tokenization process -- it took me ages to get deep enough to practically need to learn about it, and then I had to google it up. I'd have been more than happy to have it explained in the original documentation, even in passing.
-
The benefit of tokenized code is that the rexx engine can run faster as it's prepared and structured in a way that the machine would handle it.
In my mind model to make it understandable I look at it as something like:
[b]"Not tokenized"[/b]
The text has to be read and interpreted over and over again as it run loops and process instructions.
Comparisons performed letter by letter to determine what instruction for instruction lead to
[b]"Tokenization"[/b]
The text code read into memory is prepared before the engine run it
Each time a variable get mentioned it is replaced by a placeholder that point to memory, specific to the computer and architecture.
All references that point to that placeholder/memory can then be directly read/written/used instead of looking/searching/comparing through text.
[b]"Tokenized"[/b]
The non text tokenized code in memory can execute the instructions the way the computer work.
On OS/2 it save the tokenized code to the EA (Extended Attribute) of the .cmd file, so if no one has altered the code between runs, can just skip the "compilation" part and just run it.
cRexx check less of the code in advance for obvious mistakes and problems.