Page 1 of 1

/if with non-numeric variables

Posted: Sat Jun 12, 2004 2:04 am
by srenex
I'm making a macro that will work with different cases based on the direction one is headed.


#turbo

Sub Main
/declare feettraveled int outer
/declare newy int outer
/varset feettraveled 50

/if (${Me.Heading} == N) {
${newy} = ${Math.Calc[${Me.Y} + ${feettraveled}]}

/echo ${newy}
}
/return


This all I've tried so far, and it's only for North. I intend for feettraveled to be inputted, but I'll worry about that later. My error is "error failed to parse /if condition '(N==N)', non-numberic encountered". Any help is appreciated, thanks in advance.

Posted: Sat Jun 12, 2004 2:20 am
by Falco72
Change

Code: Select all

/if (${Me.Heading} == N) {
to

Code: Select all

/if (${Me.Heading[color=red].Equal[N]}[/color]) {
I will suggest you to read the readme.chm in your MQ2 folder.
Heading give out a string and /if works only with numeric values. Equal will check to see if the string you put in the [] is equal (true and zero) or not (false and non zero value) with the Heading function. At the end the parse will read the line like

Code: Select all

/if (TRUE) {
.
.
.
} else {
.
.
.
}

Posted: Sat Jun 12, 2004 3:07 am
by srenex
That didn't work... the error I get is: No such 'heading' member 'Equal'
=( Thanks though. I'm understanding a little more though.

Posted: Sat Jun 12, 2004 3:13 am
by Falco72
Bah, I should read the manual too:

Code: Select all

Heading  
 Members  
 int Clock The nearest clock direction, e.g. 1-12 
 
float Degrees Heading in degrees (same as casting to float) 
 
float Degrees Heading in degrees Counter-Clockwise (the way the rest of MQ2 and EQ uses it, and is expected by older macros) 
 
string Name "south" "south by southeast" etc 
 
string ShortName "S" "SSE" etc 
 
To String Same as ShortName
Try:

Code: Select all

/if (${Me.Heading[color=red].ShortName[/color].Equal[N]})

Posted: Sat Jun 12, 2004 3:15 am
by Falco72
BTW, there is an error in the manual

Code: Select all

float Degrees Heading in degrees Counter-Clockwise (the way the rest of MQ2 and EQ uses it, and is expected by older macros)
Should be

Code: Select all

float [color=red]DegreesCCW[/color] Heading in degrees Counter-Clockwise (the way the rest of MQ2 and EQ uses it, and is expected by older macros)

Posted: Sat Jun 12, 2004 4:06 am
by srenex
That works, thanks!! My macro is working well now!


Edit: I had a question here, but I figured it out =)

Posted: Sat Jun 12, 2004 4:18 am
by Falco72
Using your example, "/macro ezw 70", change:

Code: Select all

Sub Main
/declare feettraveled int outer
/declare newx int outer
/declare newy int outer
/if (${Defined[Param0]}) {
   /varset feettraveled ${Param0}
} else {
   /varset feettraveled 50
}
BTW you no need to use #turbo, infact by default all macro are at turbo 20, so you need #turbo only if you want to set a different value (I mean, different from 20).