Page 1 of 2

macro commands

PostPosted: Tue Oct 25, 2011 4:53 am
by clrgq
I'm doing a project and i need to input a list of change commands in a macro in order to edit a file. Here's an example of how i started it:

isredit macro
isredit change all ? (
isredit change all ! )
isredit sort
isredit change all y z


When I try to use the macro in the PDS member I'm getting errors, any thoughts on what i'm doing wrong?

Re: macro commands

PostPosted: Tue Oct 25, 2011 5:13 am
by MrSpock
- What programming language are you using to code your macro? CLIST? REXX? COBOL? ASM? Something else?

- What are the errors?

- What is it exactly that you're trying to do? In other words, what is it that you want this macro to do?

A good way to write a macro is to step through the process manually at first, writing down the steps you take to accomplish your end result. Then, you can replicate those steps in your macro

Re: macro commands

PostPosted: Tue Oct 25, 2011 9:00 am
by dick scherrer
Hello and welcome to the forum,

When I try to use the macro in the PDS member I'm getting errors
Posting "it didn't work" is a complete waste of everyone's time.

You need to post completely what you tried and what happened (err msg, abend, syntax error, i/o error, etc.

If you do not post information we can use to help you, no one should have to guess at what problem(s) you have.

Re: macro commands

PostPosted: Tue Oct 25, 2011 11:06 pm
by Maxime B
It's a simple error. I'm guessing you're using REXX, so just add the word REXX on the first line and add the quotes for the commands.
For example :
/* REXX */               
isredit macro             
isredit change all "?" "("
isredit change all "!" ")"
isredit sort             
isredit change all "y" "z"

Re: macro commands

PostPosted: Tue Oct 25, 2011 11:44 pm
by Peter_Mann
Actually as I recall, ISREDIT MACRO is all that is required to signal its an EDIT MACRO, (in this simple form) there's not CLIST or REXX invocation unless you
do
 /* rexx */
ADDRESS ISPF
ISPEXEC EDIT DATASET('My.datasets') MACRO(EDITME)


or
If ENV <> 'OMVS' then                        /* are we under unix ?  */
  If Sysvar(SYSISPF)='ACTIVE' then do        /* no, is ISPF active?  */
    Address ISREDIT "MACRO (OPTION)"    /* YES - allow use as macro  */

I usually code my routines to provide some error handeling or condtion code checking.
I don't have any handy examples but adding some condion code checking is a good practice
/* REXX */               
isredit macro             
isredit change all "?" "("
set cc=&lastcc
write change cc=&lastcc
isredit change all "!" ")"
isredit sort             
isredit change all "y" "z"

a crude example but good for debugging

Re: macro commands

PostPosted: Wed Oct 26, 2011 12:10 am
by Peter_Mann
I stand corrected - I just was able to unload my CLIST and REXX PDS from CD and found some very good examples, and yeah - my bad - I think you can get away with
PROC 0

ISREDIT MACRO
----------------
at the very least for a clist
but for REXX you do need
/* REXX */

here's one very old example I found

ISREDIT MACRO
ISREDIT (CSR) = LINENUM .ZCSR
ISREDIT (FSTRING) = LINE &CSR
ISPEXEC VPUT (FSTRING)
SET &EDCMDS=&STR(&FSTRING)
ISPEXEC VPUT (EDCMDS)
ISREDIT CURSOR = LINE 1
SET &CMD=&STR(FIND '&FSTRING')
ISPEXEC VGET (EDCMDS)
ISREDIT &CMD
hope I didn't mess you up and this post actually helped

Re: macro commands

PostPosted: Wed Oct 26, 2011 12:25 am
by Maxime B
Actually, that code won't work :
/* REXX */               
isredit macro             
isredit change all "?" "("
set cc=&lastcc
write change cc=&lastcc
isredit change all "!" ")"
isredit sort             
isredit change all "y" "z"

It looks more like a CLIST. You'd have to change the first "/* REXX */" line for "PROC 0"

In REXX, it would look like :
/* REXX */               
isredit macro             
isredit change all "?" "("
lastcc = RC
say lastcc
isredit change all "!" ")"
isredit sort             
isredit change all "y" "z"


If you want the fancy message form with the yellow message box, you can go this way `
/* REXX */                                                 
isredit macro                                               
isredit change all "?" "("                                 
                                                           
if RC > 0 then                                             
   do                                                       
      ZEDSMSG = "Error prossing the macro"                 
      ZEDLMSG = "There was an error while using this macro."
      ISPEXEC "SETMSG MSG(ISRZ001)"                         
   end                                                     
                                                           
isredit change all "!" ")"                                 
isredit sort                                               
isredit change all "y" "z"                                 


ZEDSMSG is for the short message that appears in the window and ZEDLMSG for the long one when you use the command "HELP" (generally mapped on PF1).

Re: macro commands

PostPosted: Wed Oct 26, 2011 12:51 am
by Peter_Mann
yep, bad example - thus my follow up post - I need to make sure I give more accurate / correct examples
thanks

Re: macro commands

PostPosted: Wed Oct 26, 2011 1:55 pm
by expat
Just clarify one point

I have a lot of macros which DO NOT have /* REXX */ in the first line, or in fact anywhere and they work perfectly well.

It seems that the OP has been asked some questions to clarify what is happening but has failed to respond, so until that time, unless you are ABSOLUTELY sure that you know what the problem is and exactly why it doesn't work, perhaps a refrain from posting may eliminate the clutter that is accumulating in this thread

Re: macro commands

PostPosted: Wed Oct 26, 2011 5:08 pm
by enrico-sorichetti
have a lot of macros which DO NOT have /* REXX */ in the first line, or in fact anywhere and they work perfectly well.


because Your setup uses the SYSEXEC ddname
SYSEXEC contains only REXX stuff

just checked ;)