Page 1 of 1

Line Continuation Character?

Posted: Sat May 15, 2004 9:52 pm
by Jerle69
I wrote my first MQ2 macro about a week ago (Rogue Helper, maybe you've seen it). Anyway, while I wrote the first version of it, I had some rather lengthy boolean expressions in some of my /if statements. When writing code in other languages, it's common code "form" to break long boolean conditions at a conjunctive operator (and and ors and whatnot) and put them on multiple lines for readability.

I tried that and MQ2 considered me foolish for doing so :)

I looked throughout the documentation and on the boards for a COBOL-style (or was it Fortran? Hell I don't remember!) continuation character or characters that could tell the parser "Hey, I got more shit for THIS line of code coming on the next line!"

Does MQ2 have one that I don't know about? If not, can my anal-rententive code-styling ass request one? Pretty please?

Perhaps two +'s bordered by spaces would indicate continue parsing on next line?

i.e.

Code: Select all

/if (${SomeBoolVariable} && !${Me.Casting.ID} && ${Me.Standing} ++
    && ${SomeOtherBoolean} && (${IntValueOfSorts}>=0)) {
  |- DO something
  |- And do something else
}
Something like that?

Thanks!

Posted: Sat May 15, 2004 10:41 pm
by Lax
i'll add something

Posted: Sat May 15, 2004 11:24 pm
by Jerle69
Thanks Lax, you kick ass :)

Posted: Wed Sep 29, 2004 12:59 pm
by Whrip
bump

Posted: Thu Sep 30, 2004 12:55 am
by zanomo
I found the long lines very hard to read and debug too. What I did for these repeating "/if" checks is to turn it into a subroutine, and this way, i can add the contitions whenever i think of one and to cut and paste to reuse the conditions easily.

From:

Code: Select all

/if (${SomeBoolVariable} && !${Me.Casting.ID} && ${Me.Standing} ++ 
    && ${SomeOtherBoolean} && (${IntValueOfSorts}>=0)) { 
  |- DO something 
  |- And do something else 
} 
To:
/call Long_and_Repeating_ifs PARM

Code: Select all

Sub Long_and_Reapeating_ifs(PARM)
    /if (!${SomeBoolVariable}) /return
    /if (${Me.Casting.ID}) /return
    /if (!${Me.Standing}) /return
    /if (!${SomeOtherBoolean}) /return
    /if (${IntValueOfSorts}<=0) /return

| All true:
|- DO something 
|- And do something else
/return RETURN_CODE
What I don't know is if I do it like this, will it take longer to execute? Most of my macros are quite short so I haven't notice much delay yet, but would it slow the execution with this type of subroutine calling?