|
Dear List,
Sometimes strange behaviour occurs when using macro's. I have another example that I want to share and perhaps get some feedback on the reasons for the behaviour. The macro I use, modulo spelling errors etc, looks like: DEFINE !mytroublsomemacro () *** Do some stuff. DO IF $casenum=1. WRITE OUTFILE "TempFilename" /"***." /"DEFINE !mymac ( ) " variable value " !ENDDEFINE.". END IF. EXE. INCLUDE FILE="TempFilename". EXE. ***Addition-below. !CONCAT("GET FILE = Filename'", !UNQUOTE(!EVAL(!mymac)), ".sps'.") !ENDDEFINE. (I don't know how this should make a difference, but to be fair, I call this macro from another one.) The real 'problem' is that the macro !mymac is not evaluated properly in the GET statement. I have solved this by adding the statement: !LET !locvar = !mymac where I have written ***Addition-below. Just assigning the value of !mymac to a local UNUSED macro appears to fix things. This "initialization"-proces does the trick - don't ask me why; please tell me! As a bonus, !mymac when called the first time in !mytroublesomemacro is called is handled differently than the subsequent times it is called, the higher level macro has several runs in one session, (!QUOTE and !UNQUOTE peculiarities; using "+"-s to generate syntax firts and second time still makes a difference). If anyone is interested I'll expand and clarify on the topic, perhaps best off-list. Thanks for your input, Alex _________________________________________________________________ Play online games with your friends with Messenger http://www.join.msn.com/messenger/overview |
|
Hi Alex,
Why are you using GET to use an SPS file? Was that a typo, or...? I am not so sure how you want the macro to evaluate. I think you mean: GET FILE = !QUOTE(!CONCAT("Filename",!EVAL(!mymac),".sav")). if that doesn't work, try changing the macro name from '!mymac' into 'mymac', or something else without an exclamation mark. I noticed before that nested macro names that have exclamation marks are sometimes evaluated as macro arguments, not as the macro itself. At least that was my interpretation of the errors I got. In any case, use of SET MPRINT = ON will help you debug your macro. Cheers!! Albert-Jan --- Alex Rasker <[hidden email]> wrote: > Dear List, > > Sometimes strange behaviour occurs when using > macro's. I have another > example that I want to share and perhaps get some > feedback on the reasons > for the behaviour. > > The macro I use, modulo spelling errors etc, looks > like: > > DEFINE !mytroublsomemacro () > > *** Do some stuff. > > DO IF $casenum=1. > WRITE OUTFILE "TempFilename" > /"***." > /"DEFINE !mymac ( ) " variable value " !ENDDEFINE.". > END IF. > EXE. > > INCLUDE FILE="TempFilename". > EXE. > > ***Addition-below. > > !CONCAT("GET FILE = Filename'", > !UNQUOTE(!EVAL(!mymac)), ".sps'.") > > !ENDDEFINE. > > (I don't know how this should make a difference, but > to be fair, I call this > macro from another one.) > > The real 'problem' is that the macro !mymac is not > evaluated properly in the > GET statement. > I have solved this by adding the statement: > !LET !locvar = !mymac > where I have written ***Addition-below. > Just assigning the value of !mymac to a local UNUSED > macro appears to fix > things. > This "initialization"-proces does the trick - don't > ask me why; please tell > me! > > As a bonus, !mymac when called the first time in > !mytroublesomemacro is > called is handled differently than the subsequent > times it is called, the > higher level macro has several runs in one session, > (!QUOTE and !UNQUOTE > peculiarities; using "+"-s to generate syntax firts > and second time still > makes a difference). If anyone is interested I'll > expand and clarify on the > topic, perhaps best off-list. > > Thanks for your input, > Alex > > > Play online games with your friends with Messenger > http://www.join.msn.com/messenger/overview > Cheers! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ____________________________________________________________________________________ Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 |
|
In reply to this post by Alex Rasker
At 05:28 PM 7/4/2007, Alex Rasker wrote:
>I have another example [of strange macro behavior] that I want to >share and perhaps get some feedback on the reasons for the behaviour. > >The macro I use, modulo spelling errors etc, looks like: > >DEFINE !mytroublsomemacro () > >*** Do some stuff. > >DO IF $casenum=1. >WRITE OUTFILE "TempFilename" >/"***." >/"DEFINE !mymac ( ) " variable value " !ENDDEFINE.". >END IF. >EXE. > >INCLUDE FILE="TempFilename". >EXE. > >***Addition-below. > >!CONCAT("GET FILE = Filename'", !UNQUOTE(!EVAL(!mymac)), ".sps'.") > >!ENDDEFINE. > >(I don't know how this should make a difference, but to be fair, I >call this >macro from another one.) > >The real 'problem' is that the macro !mymac is not evaluated properly >in the >GET statement. >I have solved this by adding the statement: >!LET !locvar = !mymac >where I have written ***Addition-below. >Just assigning the value of !mymac to a local UNUSED macro appears to >fix >things. >This "initialization"-proces does the trick - don't ask me why; please >tell >me! Do you have a test instance that can be run, and shows the problem? And what so you see, when you run with MPRINT ON? >If anyone is interested I'll expand and clarify, perhaps best >off-list. If it still is of interest to you, why don't you expand, preferably with test code we can run, and try it. Best on-list, actually; these are, after all, exchanges for all participants to learn from. And the more people who see what you post, the likelier that one will have the answer. -Good luck, Richard |
| Free forum by Nabble | Edit this page |
