Macros: sublists question

24 views
Skip to first unread message

David Eisenberg

unread,
Aug 1, 2023, 4:39:39 PM8/1/23
to ASSEMBL...@listserv.uga.edu
I hope someone can help me; I have a macro assembler question.

Suppose I write a macro MYMAC receiving two positional parameters:

&TAG MYMAC &DATE1,&DATE2

The macro will do some date arithmetic. If I invoke the macro this way:

MYMAC (2023,7,31),(2024,1,15) two dates (year,month,day)

then IIUC, &DATE1 and &DATE2 are both sublists. I therefore have no trouble coding SETA statements so that I can reference the year, month, and day values individually.

Now suppose I wish to modify the macro parameter syntax by requiring an equals sign in front of one of the dates (because I need to handle certain dates differently). E.g.:

MYMAC (2023,7,31),(=,2024,1,15)

Again, this is simple: I can check for the equals sign and extract the numeric values from the appropriate positions in each sublist.

However... suppose I want to allow this syntax:

MYMAC (2023,7,31),=(2024,1,15)

in which the equals sign precedes a date, but is *outside* of the parentheses. Now IIUC, &DATE2 is no longer a sublist. This instruction:

&YMD2 SETC '&DATE2'(2,*)

sets &YMD2 to the string (2024,1,15) which *looks* like a sublist, but of course it’s not. Maybe I'm on the wrong track. Bottom line: in my last example, I can’t figure out how to extract the year, month, and day values from &DATE2 so that I can reference them separately.

I apologize if this is basic stuff... I would really appreciate the help!

Thanks,

David

Steve Thompson

unread,
Aug 1, 2023, 4:50:43 PM8/1/23
to ASSEMBL...@listserv.uga.edu
I haven't been dealing with HLASM for a few years, and I know
that the new kids wanted certain new features....

But look at this from the Macro Processor's viewpoint:

   AAA m=(1,2,,3),=(a,b,c)

Which one is a "macro" name (or mnemonic) and then which is a
keyword and which one is positional?

The second one "=(a,b,c)" is missing the keyword.

So that statement should be flagged with an error. At least, I
would expect that.

Steve Thompson

Farley, Peter

unread,
Aug 1, 2023, 4:58:52 PM8/1/23
to ASSEMBL...@listserv.uga.edu
I think you are SOL on that last argument format (“=(yyyy,mm,dd)”), it just isn’t kosher. Use your second format (“(=,yyyy,mm,dd)”) if at all politically feasible.

Peter
--

This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.

Abe Kornelis

unread,
Aug 1, 2023, 4:59:45 PM8/1/23
to ASSEMBL...@listserv.uga.edu
Hi David,

As you stated, the parameter is no longer regarded as a sublist by HLASM.
Therefore you'll have to do all the parsing yourself. You'll probably
have to rely
heavily on INDEX, FIND, and substring notation.

Depending on the quality and detail of error messages you might want to
produce,
that could result in a significant amount of code.

From what you wrote it appears you have freedom to choose your own syntax.
If that is correct, why not choose something that aligns better with HLASM
predefined macro invocation behaviour?
Your own suggestion was to use:

MYMAC (2023,7,31),(=,2024,1,15)

I guess you might also choose to keep sublist  positions compatible:

MYMAC (2023,7,31),(=2024,1,15)

Kind regards,
Abe Kornelis
===========



Op 01/08/2023 om 22:39 schreef David Eisenberg:

Bill Hitefield

unread,
Aug 1, 2023, 5:01:49 PM8/1/23
to ASSEMBL...@listserv.uga.edu
In my quick playing with it, the assembler treats it as a character string.
I tried to do something like what David did. When I parsed a &DATE2 value of =(2021,01,31), the assembler returned the entire character string for the value of &DATE2(1).
I stripped off the leading '=' and tried to pass the remaining value, the '(2021,01,31)' to another macro which attempted to break it down as &OPERAND(1), &OPERAND(2), and &OPERAND(3).
&OPERAND(1) was assigned the value of '(2021,01,31)'. The other two were null.

In the past, when I have had a list like that and it was converted to a character string, I have had to write a mini-parser to look for the commas and pull out the data I wanted.

Not sure if this helps, but it has been my experience.

Bill Hitefield
Dino-Software Corporation
800.480.DINO
www.dino-software.com

> -----Original Message-----
> From: IBM Mainframe Assembler List <ASSEMBL...@LISTSERV.UGA.EDU>

David Eisenberg

unread,
Aug 1, 2023, 5:12:06 PM8/1/23
to ASSEMBL...@listserv.uga.edu
Thank you very much, everyone, for these rapid and helpful replies!

I hear you all loud and clear... my concept is apparently wishful thinking. I will put the equals sign inside the parentheses so that the parameter is treated as a sublist.

David

Rene BRANDT

unread,
Aug 2, 2023, 2:55:06 AM8/2/23
to ASSEMBL...@listserv.uga.edu
Hi David,

I don't understand your need of the = sign, and a question comes to me : why not using a 3rd parameter ?

René

Seymour J Metz

unread,
Aug 2, 2023, 7:13:12 AM8/2/23
to ASSEMBL...@listserv.uga.edu
Maybe. Have you tried a solution using AINSERT? Or would that get too messy?


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Assembler List [ASSEMBL...@LISTSERV.UGA.EDU] on behalf of Rene BRANDT [000014a2846c666...@LISTSERV.UGA.EDU]
Sent: Wednesday, August 2, 2023 2:54 AM
To: ASSEMBL...@LISTSERV.UGA.EDU
Subject: Re: Macros: sublists question

Steve Smith

unread,
Aug 2, 2023, 8:44:14 AM8/2/23
to ASSEMBL...@listserv.uga.edu
Just because a positional sublist parameter works for one (or two) thing
doesn't mean you're limited to using only positional sublist parameters.
Maybe add a keyword TYPE=EQ, or whatever makes sense?

Much more typically, the blinders are on the other side, and people forget
that a positional parameter would be much better than a required keyword of
FUNCTION=foo|baz

sas
Reply all
Reply to author
Forward
0 new messages