INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

New to Rexx Scripting

New to Rexx Scripting

(OP)
Hi,

I have been using Rexx scripting for a little while for very basic scripts for "copying & pssting" information from a text file into a third party application.

I tried using the ZocGetFilename commannd, i.e. file= ZocGetFilename(Select file to Upload: ", "*.txt"), but I cannot see to get it to work correctly.

I am trying to amend the script below so that when I run the script it will do the following:

1) Open a window to select the filename to use
2) Get the window to open in a specific default location, i.e. the "ZOC6 Files" folder where the scripts are located
3) Exit the script if a file is not selected, i.e. open command is cancelled.
4) Ignore the first two records within a file if it is selected are these are the header information from the Excel document the text file was generated from.

Any help would be much appreciated

/* REXX */

file = "C:\Users\Name\Documents\ZOC6 Files\User Names.txt"
tabchar = '09'x
do while( lines(file) )

data=LINEIN(file)

Parse Var data v1 (tabchar) v2

CALL ZocSend v1
CALL ZocSend "^M"
CALL ZocSend "f"
CALL ZocSend "^M"
CALL ZocDelay 1

CALL ZocSend "^Z"
CALL ZocDelay 1

CALL ZocSend v1
CALL ZocSend "^I"
CALL ZocDelay 1

CALL ZocSend v2
IF LENGTH(v2) < 20 THEN DO
CALL ZocSend "^I"
END
CALL ZocDelay 1

CALL ZocSend "^M"
CALL ZocSend "a"
CALL ZocSend "^M"
CALL ZocDelay 1

CALL ZocSend "^Z"
CALL ZocDelay 1

END

RE: New to Rexx Scripting

I tend to use excel and save as CSV and pull info from that for scripts also sections rather than DO. If you want to skip a couple of lines you could use a variable an example would be this

/*REXX*/

new= ZocGetFilename("Select file to upload", "c:\csv\*.csv")
IF new="##CANCEL##" THEN CALL LEAVE
x = 0
LOOP:
x = x + 1
fileid = linein(new)
PARSE VALUE fileid WITH v1","v2","v3","v4 /*example for a 4 column excel*/
IF x > 2 THEN CALL LOOP
IF v1 = "" THEN CALL finish

stuff you want to do inside the loop

CALL LOOP

finish:
EXIT

RE: New to Rexx Scripting

I don't kmow what flavour of rexx you use but rexx does not have sections - it has sub-routines. Your LOOP: is jsut a label - if it was after the EXIT statement then it would be a sub-routine.
LEAVE is a keyword not a function so you cannot call it. You shouldn't call finish but SIGNAL finish. Wjhy are you calling LOOP recursively and not gracefully returning through its calls clearing the stack as you go?

You probably need a DO loop - maybe FOREVER and ITERATE if x>2 or LEAVE if v1 = ""
So, probably:
/* rexx */
x = 0
new= ZocGetFilename("Select file to upload", "c:\csv\*.csv")
IF new <> "##CANCEL##" 
THEN DO FOREVER
   x = x + 1
   fileid = linein(new)
   PARSE VALUE fileid WITH v1","v2","v3","v4 /*example for a 4 column excel*/
   IF x > 2 THEN ITERATE
   IF v1 = "" THEN LEAVE

   stuff you want to do inside the loop

END

EXIT 


Nic

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close