OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: lmotaku on March 19, 2013, 09:36:48 pm

Title: Rexx?
Post by: lmotaku on March 19, 2013, 09:36:48 pm
I'm not going to ask how to program in Rexx, as I'm reading a documentation on it's built in functions and such. I've scripted mIRC in the past, been using Javascript since a teen, learned OOP-PHP, understand some C/C++ structuring due to some involvement with reverse engineering and such, so it shouldn't be super super hard for me. However, if I want to read a line of a file I would use

Code: [Select]
say Linein( 'file1' )  right?

So if I have a Rexx widget in my taskbar and tell it to "say Linein( 'file1' )" and file1 contains "Hello, Larry!" would I see that on the taskbar?

Sorry, it appears it can't do that, RxMessagebox or what not, will read more and learn.

Derp:

(http://i45.tinypic.com/35ldisi.png)
Title: Re: Rexx?
Post by: Doug Bissett on March 19, 2013, 11:52:28 pm
You are jumping in a little too fast. REXX is actually fairly easy, but there are two versions. One is known as "Classic REXX", which is the default. There is also "Object REXX" which needs to be set up by the user. It is usually one, or the other, but not both, although there is a way to do both. I assume that you are still using "Classic REXX".

Next, you picked a more advanced function with RxMessageBox. It does need some extra things to make it work.

There are also a few more advanced REXX packages, that help to make GUI interfaces. VXREXX, and DrDialog, are the two that I remember. I use DrDialog, but VXREXX is probably a better choice, since the support is already in eCS (I am not sure if the programmer package is included).

Quote
So if I have a Rexx widget in my taskbar and tell it to "say Linein( 'file1' )" and file1 contains "Hello, Larry!" would I see that on the taskbar?

Not the way you are doing it. There are some widgets that support REXX code, but what you did would simply start the program in a window. There is also a widget to add an "Extended system tray", which does some of the things that the windows taskbar does. AFAIK, the only things that actually use that, are some programs that have been ported using the QT4 package, and some JAVA programs.

If your quoted code is what you tried, it isn't likely to work. First, to tell the command processor to decode  REXX command file, it needs to start with a comment line. That is the first two characters, in the first line, need to be "/*" ( slash asterisk, without the quotes). That is usually followed by a description of what the program is, and the comment is closed by "*/" (asterisk slash, without the quotes). If that is not found, the command processor attempts to treat it like a normal batch file (pretty much like DOS).

Then, you need to load the appropriate support module(s), which is one of the reasons why RxMessageBox isn't working. Add this sequence:

Code: [Select]
/* Load the rexxUtil functions -------------------------------------------- */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs

Which loads the functions, including RxMessageBox. Be aware, that this is a system wide load, so any program can use it, as long as it stays loaded. Proper practice dictates that you should unload that stuff, when you are finished with it. In real life, if you do that, and some other REXX program is using it, it goes away, and the other program will die. The fix is: do NOT unload it. You should always load it to be sure that your program has access, just in case it is the first program that needs it. There are more function  libraries available, but you should stay with the simple stuff to start.

Then, add your line of code. Now, you can run that from a command line, or from a program icon, or, put the program icon in the eCenter bar, and it will open a text window, and do what you asked.

At this point RxMessageBox still won't work, because it needs to be run by  a program that is capable of doing a graphical presentation. The easiest program is PMREXX. Create a file called HelloLarry.cmd, and insert this code:
Code: [Select]
/* Hello Larry */

/* Load the rexxUtil functions -------------------------------------------- */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs

Do until RxMessageBox("Hello Larry","Testing","OK","EXCLAMATION") = 1
end

EXIT

Now go to a command line, in the directory where you saved the HelloLarry.cmd file, and type "PMREXX /Q HelloLarry". It will open the PMREXX window (which may hide behind other things), and pop up the message window. When you click OK, it will close (PMREXX would stay open, without the "/Q" parameter).

Of course, this is pretty simple, and it contains no checking, but it is a start.
Title: Re: Rexx?
Post by: lmotaku on March 20, 2013, 01:23:39 am
Posting from eCS, since Virtualbox doesn't wanna transfer clipboards between guest and host. lol

Code: [Select]
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
Address 'CMD'
'D:\Programs\cURL\curl\bin\curl.exe <URL/weather/?zip=zipcode> -o D:\scripts\weather\current.txt'
Address
Do until RxMessageBox(Linein( 'D:\scripts\weather\current.txt' ,1),"Weather","OK","EXCLAMATION") = 1
end

EXITcall RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
Address 'CMD'
'D:\Programs\cURL\curl\bin\curl.exe http://steam.dvflex.com/weather/?zip=L9Y4V4 -o D:\scripts\weather\current.txt'
Address
Do until RxMessageBox(Linein( 'D:\scripts\weather\current.txt' ,1),"Weather","OK","EXCLAMATION") = 1
end

EXIT

That's what I have now, and it works as expected. Just now need to tell it what to do with the response.
If you're unsure of what I'm doing, I'm trying to make widget similar to the one that tells me the current cpu load on the desktop shell?( or should I say Workspace shell?)
Title: Re: Rexx?
Post by: Doug Bissett on March 20, 2013, 06:15:27 pm
Quote
Posting from eCS, since Virtualbox doesn't wanna transfer clipboards between guest and host. lol

You need to install the VBox additions. It works a little different from installing in a windows client. Click on (VBox menu) Devices, then Install Guest Additions. In windows, that will start an installer in the client. In OS/2 (eCS), it simply attaches a virtual CD, so you need to open the CD. Then, look in the OS2 directory. There are instructions that you need to follow.

Quote
f you're unsure of what I'm doing, I'm trying to make widget similar to the one that tells me the current cpu load on the desktop shell?( or should I say Workspace shell?)

Neither is right. The CPU load widget shows the whole system load, not just for Presentation Manager, and/or the Workplace Shell.

You need one of the REXX widgets for eCenter (XCenter) from: http://www.os2usr.org/xcenter/ (http://www.os2usr.org/xcenter/). READ the instructions that comes with them. Depending on what you want to do, one of them should do it for you.

BTW, since you seem to want to use up valuable space in the eCenter (XCenter) bar, you should realize that you can have two bars. One at the top of the screen, and the other at the bottom. Go to Programs-> Utilities and copy the eCenter icon to something like eCenter1, then put a shadow of that into the startup folder. When it starts, it will be on top of the original eCenter bar. Right mouse click on an empty spot (or jamb the cursor hard against the right end, if there is no blank spot), and open the Properties. One of the settings is Top or Bottom. Select Top, and the new bar will appear at the top, with the old bar at the bottom. Then, you should delete any duplicated widgets, and adjust both bars to your own preferences. Don't worry about "you can't undo this". You can, but any settings, or contents, for the individual widgets will need to be recreated if you put them back.

You should also look up the REXX help, to see what the options are for RxMessageBox. "EXCLAMATION" is probably not the best icon for your popup window (which you probably won't use anyway, with the REXX widgets).

Have fun...
Title: Re: Rexx?
Post by: lmotaku on March 20, 2013, 07:47:58 pm
I think you may have read me a little unclear, I was referring to the taskbar. It's called the WPS isn't it? I know that the CPU load widget is the whole system though, either way, you still gave me some valuable information.  thanks again, I appreciate it.

Update, just to be sure, this is what you meant?

Title: Re: Rexx?
Post by: Doug Bissett on March 20, 2013, 09:12:55 pm
I think you may have read me a little unclear, I was referring to the taskbar. It's called the WPS isn't it? I know that the CPU load widget is the whole system though, either way, you still gave me some valuable information.  thanks again, I appreciate it.

Update, just to be sure, this is what you meant?

There is no "taskbar" as such. There is the eCenter (XCenter) bar, which sort of works like the windows taskbar.  The Extended System Tray widget adds more of the function of the windows task bar to the eCenter (XCenter) bar.

WPS is a program that runs under the Presentation Manager, which is really the GUI that OS/2 uses. WPS adds a lot of function to the Presentation Manager, and the WPS itself is further extended by eWorkPlace, which is a sub set of the full blown XWorkPlace. Most OS/2 GUI programs run under the Presentation Manager (which is why many programs are called PM<something or other>). The WPS can also be programmed (extended) if it makes sense to do that for a particular reason.

Older versions of OS/2 use a different thing called "WarpCenter" (if I remember correctly), which is not nearly as flexible as eCenter.  Before that (in warp3) there was the Toolbar, which was quite different, and really had a different purpose. They all work in eCS, but usually only the eCenter bar is used. WarpCenter (AKA eComCenter) is known to have some bugs, and the Toolbar takes up a lot of screen real estate.

I would guess, that you are trying to do something similar to what the windows Gadgets do. If so, you are probably on the right track, but it would be better to use VXREXX, or DrDialog, to create a GUI window with whatever you want in it. That, of course, is even more complicated, and does involve a "learning curve".
Title: Re: Rexx?
Post by: Alex Taylor on March 21, 2013, 04:41:48 pm
The REXX 'SAY' instruction simply prints to standard output (STDOUT).  Unless you use a special REXX environment that redirects STDOUT (such as PMREXX), you will only see this when running the REXX program from a command prompt.

RxMessageBox only works within a process that is running as in graphical (PM) mode.  If you run within PMREXX ('REXX console' on the eCS desktop) then it should work (IIRC, anyway).  You can also convert a REXX script to a graphical program by using a tool like REXX2EXE (http://hobbes.nmsu.edu/h-viewer.php?dir=/pub/os2/dev/rexx&file=rexx2exe.zip&backto=%2Fh-search.php%3Fkey%3Drexx2exe%26pushbutton%3DSearch) (use e.g. 'rexx2exe myrexx.cmd myrexx.exe /p').

Normally eCenter widgets are not written in REXX.  I believe somebody wrote a special wrapper widget a few years ago which does allow this, however.  It might be in this package (http://hobbes.nmsu.edu/h-viewer.php?dir=/pub/os2/apps/wps/xworkplace&file=xwpwidgets-0-7-3.wpi&backto=%2Fh-search.php%3Fkey%3Dwidget%26pushbutton%3DSearch) but I'm not sure (and I've never used it so I can't be any more help than that).
Title: Re: Rexx?
Post by: lmotaku on March 22, 2013, 02:04:40 pm
Okay, thanks. Both replies helped me learn some stuff. But before I get too out of focus, where exactly could one see a documentation on VX-REXX, or DrDialog? I'm coming up nothing in Google, and I'm not buying a book, haha. The books don't teach me anything, I need visual examples and class/function structure so I can engineer it. I didn't learn PHP, Javascript, HTML, or anything like that reading books, just examples, concepts, and functions, until I knew enough functions to write my own stuff. Same way I learned PC repair. I opened up a PC case, took out a part and replaced it. I didn't need no guide.
Title: Re: Rexx?
Post by: Martin Iturbide on March 22, 2013, 02:19:53 pm
Hi Larry.

The EDM/2 wiki has several OS/2 REXX related article, there is also a series of articles called "DrDialog, or: How I learned to stop worrying and love REXX"
http://www.edm2.com/

But seems that the wiki is down for the moment. I will contact Adrian (netlabs) to see what happened.

Jumping a little but out of the topic, I always dream with the idea of replacing OS/2's REXX with an open source implementation of Regina REXX  (http://regina-rexx.sourceforge.net/) How will it work for us to remove IBM's REXX libraries from OS/2 and use Regina? I don't have the technical skill to know how hard or easy will be to do this, or if Regina REXX has all the functionality that IBM's REXX has.
Title: Re: Rexx?
Post by: lmotaku on March 22, 2013, 02:34:20 pm
Hi Larry.

The EDM/2 wiki has several OS/2 REXX related article, there is also a series of articles called "DrDialog, or: How I learned to stop worrying and love REXX"
http://www.edm2.com/

But seems that the wiki is down for the moment. I will contact Adrian (netlabs) to see what happened.
Thanks Martin, sounds like it is what I could be looking for.

Jumping a little but out of the topic, I always dream with the idea of replacing OS/2's REXX with an open source implementation of Regina REXX  (http://regina-rexx.sourceforge.net/) How will it work for us to remove IBM's REXX libraries from OS/2 and use Regina? I don't have the technical skill to know how hard or easy will be to do this, or if Regina REXX has all the functionality that IBM's REXX has.

Well, on the outside it seems to have a lot of what IBM does, but there could be something deeper that IBM has that makes it still somewhat better. Don't know enough about eCS yet.
I would imagine it would be the same as replacing any other library or interpreter. As long as all the functions and calls are there for the OS, it would make it an easier change, if workarounds need to be coded, that could take time.
Title: Re: Rexx?
Post by: Doug Bissett on March 22, 2013, 06:38:26 pm
Quote
where exactly could one see a documentation on VX-REXX, or DrDialog?

I don't know about VX-REXX. There is some information at: http://en.wikipedia.org/wiki/VX-REXX (http://en.wikipedia.org/wiki/VX-REXX).

DrDialog is at HOBBES (where many things are to be found): http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/drdialog.zip (http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/drdialog.zip) with updates: http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/DrDlgFix.zip (http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/DrDlgFix.zip) and: http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/DrDlgRc.zip (http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/DrDlgRc.zip).

HOBBES is at: http://hobbes.nmsu.edu/ (http://hobbes.nmsu.edu/), where you can search for things.
Title: Re: Rexx?
Post by: Jan-Erik Lärka on March 25, 2013, 07:56:28 am
Hello,

something that may seem unrelated, but provide you with the mentioned tool ...
look for Dimitris 'sehh' Michelinakis - WebMail/2 for OS/2
not to mention the web mail tool written in rexx  ;D

//Jan-Erik
Title: Re: Rexx?
Post by: RobertMauro on April 04, 2013, 11:22:07 pm
Hi, I believe what is really needed is very simple. There is a REXX widget toolkit or Rexx widget someplace for XWorkplace (and eWorkplace). Installing that will allow writing simple rexx code where the code is used to do various things (output text, update graphs, etc).

It's not as simple as simply writing output to STDOUT (ie: a console window), but still very easy, especially if one looks at the widgets and source included.
Title: Re: Rexx?
Post by: warpcafe on April 13, 2013, 12:07:28 am
Hi all,

most probably, that widget toolkit is the one that can be found here:
http://www.os2usr.org/xcenter/

Scroll down for the "rexx gauge", which is part of the linked xworkplace widget library.
IIRC it includes code samples and documentation and comes as a warpin install package (.wpi)

Cheers, Thomas
Title: Re: Rexx?
Post by: RobertMauro on May 01, 2013, 11:22:18 pm
Scroll down for the "rexx gauge", which is part of the linked xworkplace widget library.
IIRC it includes code samples and documentation and comes as a warpin install package (.wpi)

BINGO! That's the one! Glad someone remembered it. Thanks Thomas!
Title: Re: Rexx?
Post by: muffetta on June 26, 2013, 07:21:03 pm
Hi, returning to the vx-rexx, since i'm reading the manual for version 2.1 CS demo (the one on hobbes) out of curiosity, is it possible to get an executable from a project written in vx-rexx using other tools?
Regards
Title: Re: Rexx?
Post by: Andreas Schnellbacher on June 26, 2013, 11:03:34 pm
is it possible to get an executable from a project written in vx-rexx using other tools?

No.
Title: Re: Rexx?
Post by: RobertMauro on June 27, 2013, 11:48:10 pm
Hi, returning to the vx-rexx, since i'm reading the manual for version 2.1 CS demo (the one on hobbes) out of curiosity, is it possible to get an executable from a project written in vx-rexx using other tools?
Regards

Hi Barbara, can you go into more detail about what you are trying to do and what the source code looks like? Some of the libraries out there work with vx-rexx and other packages, so, theoretically, it is possible, probably with some modification, to compile code using another "tool".

Best,
Robert
Title: Re: Rexx?
Post by: muffetta on June 28, 2013, 05:57:50 am
Nothing special Robert, I spoke of the exercises and examples given in the manual of the vx-rexx demo that I'm reading, as Alex Taylor spoke of rexx2exe some post ago in this thread (and in fact on hobbes is not the only program like that) I thought it was possible.
Regards.
Title: Re: Rexx?
Post by: Andreas Schnellbacher on June 28, 2013, 05:01:04 pm
Nothing special Robert, I spoke of the exercises and examples given in the manual of the vx-rexx demo that I'm reading, as Alex Taylor spoke of rexx2exe some post ago in this thread (and in fact on hobbes is not the only program like that) I thought it was possible.

More background details: Every REXX dialog IDE must use its own tools to create an executable from the source. There exist no other (maybe license-free) tools to do that.

Andreas
Title: Re: Rexx?
Post by: Alex Taylor on June 29, 2013, 02:46:57 am
Any VX-REXX application project can only be compiled with VX-REXX (although it's possible to do this using only the demo if you don't mind some extra work).

However, separate REXX function libraries and some kinds of macros that are written with VX-REXX may be able to be compiled (with e.g. REXX2EXE) if they are 'plain' REXX and don't rely on the VX-REXX client-server object framework.

It's quite possible to use VX-REXX functions (but not objects, methods or events) in a 'standard' REXX script.
Title: Re: Rexx?
Post by: muffetta on July 03, 2013, 10:20:29 pm
So there is a way, no,  I don't mind some extra work, definitely it is faster than rewriting every time exercises  ::) !
Regards.
Title: Re: Rexx?
Post by: Alex Taylor on July 04, 2013, 11:49:20 pm
So there is a way, no,  I don't mind some extra work, definitely it is faster than rewriting every time exercises  ::) !

Every time you Run a VX-REXX project (even in the demo) it compiles it to EXE and writes both the EXE and the source code to a temporary directory (called "__tmp?" where ? is a number) under %TMP%.  The three source files you need to save are project.VRP, project.VRM (rename to project.VRX when saving), and project.VRW (rename to project.VRY).   
Title: Re: Rexx?
Post by: muffetta on July 05, 2013, 09:22:08 pm
Unfortunatly does not work after you've closed vx-rexx (at least here for me). The executable does not start and you can't re-open the project file (a simple window with a quit button)
Project.vrp:
MacroPath: VRM:
EXEPath:
RunParameters:
RunDirectory:
VRXWindow: __VREMainWindow,1,2289,4433,5767,8000
VRXWindow: __VRESectionListWindow,0,3324,6793,2650,3342
VRXWindow: __VREToolsWindow,1,3404,10648,4993,1669
UserFile: 1
UserWindow: Window1,1

Likely something wrong, but what?
Regards
Title: Re: Rexx?
Post by: xynixme on February 24, 2017, 05:05:14 pm
may be able to be compiled (with e.g. REXX2EXE) if they are 'plain' REXX

One of the rather expensive Rexx compilers, which actually should be quite easy to write, was shipped with a fully functional RexxPack utility. RexxPack used to be a product on its own, AFAICT. An improved version of RexxPack can be found here: http://hobbes.nmsu.edu/download/pub/incoming/delayed/packrexx.zip (http://hobbes.nmsu.edu/download/pub/incoming/delayed/packrexx.zip)

Interestingly it decreases the size of the EAs too, so it should improve the speed of execution slightly. Registration may be required to receive some undo-utility. I guess RexxPack just removes all unneeded characters, without overdoing it. In theory you could use RexxPack to produce a hard-to-edit smaller file, and Rexx2EXE to create a "compiled", smaller, unreadable final product.

Please do execute our Rexx EXEs with Object REXX too, to make sure that there are no fatal syntax errors. The same syntax check applies to VX-REXX (with PackVXRX) EXEs.