| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hello. I have had 20 +years working with Rexx on a mainframe but I am new to working on a pc. I have oorexx installed on my pc running Windows Vista OS. I need a sample program to get me started. Could someone provide a sample list of commands to open a file on my pc, read each line and write each line to an output file? Also how do you debug a rexx.exe?, When I run on that is in error the MS window closes before I see what the error was. Thanks in advance. |
|
#2
| |||
| |||
| On Fri, 18 Jul 2008 21:35:56 -0700 (PDT), globaloney wrote: >Hello. >I have had 20 +years working with Rexx on a mainframe but I am new to >working on a pc. >I have oorexx installed on my pc running Windows Vista OS. I need a >sample program to get me started. > >Could someone provide a sample list of commands to open a file on my >pc, read each line >and write each line to an output file? > >Also how do you debug a rexx.exe?, When I run on that is in error the >MS window closes >before I see what the error was. Thanks in advance. > > Here is an old file I had around (cut and pasted below). Modifies lines in a file based on a simple pos search on each line. ASCII/text file. No waranty on how it will work for you. This was written for OS/2 but should run unchanged in windows. For debug you can add the trace command. Most of my rexx has been simple scripts so Say and Trace have been enough. From the rexx docs: TRACE ?R /* Interactive debugging is switched on if it was off, */ /* and tracing results of expressions begins. */ You can switch off interactive debugging in several ways: * Entering TRACE O turns off all tracing. * Entering TRACE with no options restores the defaults--it turns off interactive debugging but continues tracing with TRACE Normal (which traces any failing command after execution). * Entering TRACE ? turns off interactive debugging and continues tracing with the current option. * Entering a TRACE instruction with a ? prefix before the option turns off interactive debugging and continues tracing with the new option. Now that IBM has opensourced Rexx you can get info here http://www.oorexx.org/ http://www.oorexx.org/docs.html Take care, Bart cut and paste to a filename of your choice ".cmd" ie "myscript.cmd" run as follows: c>rexx myscript.cmd mydatafile.dat ------------- Cut ------------ /* REXX EXEC */ '@Echo off' parse arg filename fname = filename'.new' /* create new file name for output, If it exists we will append to it. */ say 'input file = "'filename'"' say 'output file = "'fname'"' modifiedLines = 0 totalLines = 0 input=linein(filename) Do while lines(filename) > 0 totalLines = totalLines + 1 pos1 = lastpos('Fixme', input) if pos1 \= 0 then Do output = left(input, pos1-1)'Fixed' modifiedLines = modifiedLines + 1 End else Do output = input End call LINEOUT fname, output input=linein(filename) /* get next line */ End /* file read loop */ say 'Total lines read = 'totalLines say 'Total lines changed = 'modifiedLines ------------ End Cut ------------------- |
|
#3
| |||
| |||
| Nitro wrote: > For debug you can add the trace command. Most of my rexx has been simple > scripts so Say and Trace have been enough. I recently came across the fact that you could turn rexx tracing on by setting the RXTRACE environment variable to ON. This can be handy if you use external subroutines, or ::include libraries. If you find yourself about to call such an external routine (while tracing your own code) then you can enter: Call Value 'RXTRACE','ON','ENVIRONMENT' .... and see what the external routine does. -- Steve Swift http://www.swiftys.org.uk/swifty.html http://www.ringers.org.uk |
|
#4
| |||
| |||
| Steve Swift wrote: > I recently came across the fact that you could turn rexx tracing on by > setting the RXTRACE environment variable to ON. Thanks Steve! I had not known of that trick. Indeed it does work with ooRexx on Linux. -- Michael Lueck Lueck Data Systems http://www.lueckdatasystems.com/ |
|
#5
| |||
| |||
| On Fri, 18 Jul 2008 21:35:56 -0700 (PDT), globaloney <jgolano@excite.com> declaimed the following in comp.lang.rexx: > Also how do you debug a rexx.exe?, When I run on that is in error the > MS window closes > before I see what the error was. Thanks in advance. > Crystal ball time... the haze is clearing... I see... You're double-clicking on an icon of your program script. Try opening a command shell first, navigating to the location of your script, and then typing the name of the script (with extension). If it doesn't start, you may need to specify the REXX interpreter. (NOTE: I have Regina installed here... and it looks like it's rigged to not exit on successful run... Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\Dennis Lee Bieber>edit t.rx C:\DOCUME~1\DENNIS~1>t.rx Did it run Press ENTER key to exit... C:\DOCUME~1\DENNIS~1>rename t.rx t.rexx C:\DOCUME~1\DENNIS~1>t.rexx Did it run Press ENTER key to exit... C:\DOCUME~1\DENNIS~1> --- Confirmed: Using regina.exe to run automatically adds that "press ENTER"... which will hold a console window open if double clicking an icon. If changing the default to use rexx.exe, the console closes after any output. -- Wulfraed Dennis Lee Bieber KD6MOG wlfraed@ix.netcom.com wulfraed@bestiaria.com HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: web-asst@bestiaria.com) HTTP://www.bestiaria.com/ |
|
#6
| |||
| |||
| This is what I use to copy a file. The 'say' is cosmetic. It assumes f1_rm1 exists as an input file and you'll create fi_out. someproc: fi_rm1 = 'c:\ghexe\utem1rm1.txt' fi_out = 'w:\bkpdir\utem1rm1.001' do while lines(fi_rm1) > 0 ws_inb = linein(fi_rm1) say 'ws_inb='ws_inb call lineout fi_out, ws_inb end call lineout (fi_rm1) /* close */ call lineout (fi_out) /* close */ return As for debugging - ask smarter guys than me. That said . . I do use 'trace' with a parm occasionally but usually when I've done a nono if prints up on the CMD window and describes the error very clearly. (Am ooRexx on XP though - shouldn't make a difference). Many Rexx's have bitten me because i forgot to close the file. Read the manual about linein and how its coded (I say this because in the code above there is no explicit 'open' - ain't like cobol:-)) Hope this helps, Graham On Fri, 18 Jul 2008 21:35:56 -0700 (PDT), globaloney <jgolano@excite.com> wrote: >Hello. >I have had 20 +years working with Rexx on a mainframe but I am new to >working on a pc. >I have oorexx installed on my pc running Windows Vista OS. I need a >sample program to get me started. > >Could someone provide a sample list of commands to open a file on my >pc, read each line >and write each line to an output file? > >Also how do you debug a rexx.exe?, When I run on that is in error the >MS window closes >before I see what the error was. Thanks in advance. > ** Posted from http://www.teranews.com ** |
|
#7
| |||
| |||
| Graham Hobbs wrote: > Many Rexx's have bitten me because i forgot to close the file. Read > the manual about linein and how its coded (I say this because in the > code above there is no explicit 'open' - ain't like cobol:-)) True true... But for max I/O performance, methods were added which are FAR superior to LineIn / LineOut. For example: file=.stream~new('data.dat') file~open('READ') if result\='READY:' then do return 0 end /* Check for how many lines the file has */ FILEsize=file~command('QUERY SIZE') /* Read in the file */ /* This code requires at least ORexx 2.1.1 on Win32 - only tested with >=2.1.2 */ INstr=file~charin(1, FILEsize) FINDarray=INstr~makearray() file~close() Open/Close the file with the scream object. If it is not possible to have the complete data set in memory, the use LineIn/LineOut instead of charin/makearray. -- Michael Lueck Lueck Data Systems http://www.lueckdatasystems.com/ |
|
#8
| |||
| |||
| Steve Swift wrote: > I recently came across the fact that you could turn rexx tracing on by > setting the RXTRACE environment variable to ON. Thanks Steve! I had not known of that trick. Indeed it does work with ooRexx on Linux. -- Michael Lueck Lueck Data Systems http://www.lueckdatasystems.com/ |
|
#9
| |||
| |||
| globaloney <jgolano@excite.com> wrote: > Also how do you debug a rexx.exe?, When I run on that is in error the > MS window closes > before I see what the error was. Thanks in advance. The simplest way is to have your code end with something like: say "***" ; parse pull waste so the exec waits for a final bit of input before ending. You could put that in your error handler if normal execution is meant to produce no output, so only when something goes wrong does the window hand around. -- Jeremy C B Nicoll - my opinions are my own. |
|
#10
| |||
| |||
| globaloney wrote: > Hello. > I have had 20 +years working with Rexx on a mainframe but I am new to > working on a pc. > I have oorexx installed on my pc running Windows Vista OS. I need a > sample program to get me started. > > Could someone provide a sample list of commands to open a file on my > pc, read each line > and write each line to an output file? > > Also how do you debug a rexx.exe?, When I run on that is in error the > MS window closes > before I see what the error was. Thanks in advance. > > Lots of good suggestions already so I will only add the following. OoRexx provides two additional ways to run a script besides REXX.EXE - REXXHIDE.EXE and REXXPAWS.EXE. You would use the first in cases where all of the user interaction is via dialogs so there would be no need for a "command window". It also would be useful for something meant to run in the "background". The second was added by Mark Hessling to mimic the default Regina behavior of leaving the command window open after the script terminates. The default "association" for the .rex extension is to invoke REXX.EXE but you COULD change it to run REXXPAWS for example if you wanted the command window to always remain open. In my opinion, however, the best way to debug a new script is to invoke it from an already open command window and make liberal use of TRACE to step through the parts of the program that aren't working as expected. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.