• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->

Strings and Numerics (1 Viewer)

Druid

Member
Joined
May 23, 2005
RedCents
50¢
[sigh... another dumb question... I wish there were a USABLE reference for macros... the "documentation" at mq2 is very ..uh.. dense. Or maybe I am]

Anyway...

My current problem is:

/if (${Target.Name}="SomeName") then { dosomething }

If there is no target, I get "Null" .. which is of course not a string,
so the thing aborts.

If there is a target, I get "hunter03 is not a string" either.

Looks like a string to me, and the Target.Name type should be a string
but then, I'm not a dumb computer.



BTW: what I am trying to do, is stop casting dots if *I* am the target, as sometimes happens.
 
Many apologies for putting the wrong error message.

It reads

Non-numeric string encountered.
And I *want* to test non-numeric strings, so... what's wrong with the /If statement?

-------------------------------

I'll try the Me.Target ... thanks
 
/if only compares numerical statements.

/if(${Target.Name.Equal["Name"]) {
/echo Correct Name
}

.Equal
.NotEqual

etc return 0s and 1s which can be processed by the /if statement

/if(${String} = "Hi") This statement is invalid and will generate the non-numeric message
 
Everything a string can do:

Rich (BB code):
string

Members
string Arg[n,separator] 	Gets nth argument using separator as the separator (single character). separator defaults to space
int Compare[text] 	-1 if the string is alphabetically before text, 0 if equal, 1 if after. Case does not count.
int CompareCS[text] 	-1 if the string is alphabetically before text, 0 if equal, 1 if after. Case counts.
int Count[char] 	Count the number of occurrences of a particular character in the string
bool Equal[text] 	Strings equal? Case does not count
bool EqualCS[text] 	Strings equal? Case counts!
int Find[text] 	Looks for the given text, gives position (currently NULL if not found)
string Left[length] 	The left (length) of the string.. Left[2] of "Left" will be "Le"
string Left[-length] 	The left ("all but" length) of the string.. Left[-1] of "Left" will be "Lef"
int Length 	The length of the string
string Lower 	The string in all lower case
string Mid[position,length] 	The left (length) starting at (position).. Mid[2,3] of "Left" will be "ef"
bool NotEqual[text] 	Strings not equal? Case does not count
bool NotEqualCS[text] 	Strings not equal? Case counts!
string Replace[old,new]
string Right[length] 	The right (length) of the string.. Right[2] of "Left" will be "ft"
string Right[-length] 	The right ("all but" length) of the string.. Right[-1] of "Left" will be "eft"
string Token[n,separator] 	Retrieve a token from the string using a custom separator. Will not skip empty values
string Upper 	The string in all UPPER CASE
To String 	this IS a string, assface
 
Wonderful, Cobalt !

Where did the string stuff come from? In case I have questions about anything else -- [ like there's a chance of THAT... I'm sooooo uber. ;) ]
 
Curious why this:

/if (${Zone.ID}=344) /echo I am in Guild Lobby

Is giving me error message:

Failed to parse /if condition '(344=344)', non-numeric encountered

Was trying to improve one of my macros and my first foray into flow control and conditions with a TLO and definitely confused.

Zone TLO showed that ID was an integer so must be my syntax?

intIDZone ID


I also tried using Zone.Name.Equal with zone name and was getting the non numeric sting error so I obviously am doing something wrong with that too ~
 
Curious why this:

/if (${Zone.ID}=344) /echo I am in Guild Lobby

Is giving me error message:

Failed to parse /if condition '(344=344)', non-numeric encountered



I also tried using Zone.Name.Equal with zone name and was getting the non numeric sting error so I obviously am doing something wrong with that too ~

INI:
/if (${Zone.ID}==344) /echo I am in Guild Lobby
/if (${Zone.Name.Equal[Guild Lobby]})  /echo I am in Guild Lobby
Missing an equal sign in the numeric compare.
You didn't show your text comparison, no idea what your problem there is.
 
Last edited:
I always try to use numerics for checks where possible, and often MQ2 will give something an ID number (actually EQ does). e.g. from https://www.redguides.com/wiki/DataType:spawn has an ID, so

INI:
/if (${Target.ID} == ${Me.ID}) {
  | Is the ID number of my Targetequal to my ID number?
  | I am the target so stop doing stuff
}

To check if two things are equal, you use double equals "==" . So

${Zone.ID}==344

Would mean "is ${Zone.ID} equal to 344?", and MQ2 would either say true or false.
 
to elaborate a little bit typically in programming a single equal sign assigns the value to the variable, and two equal signs is meant to compare the values.

Now, even though the single equal sign doesn't assign a variable a value in macros, we still use the double equal to compare two values.

I wrote a basic conditions guide to get people interested in learning on the right track and hopefully explain away some of the mystery.


Check out this link to hopefully start you on the path to success in whatever macro you're working on.
 
Strings and Numerics

Users who are viewing this thread

Back
Top