Quantcast Operators and conditionals - EQ2Interface
EQ2Interface.com
Search Downloads


Go Back   EQ2Interface > Developer Discussion > XML Modification Help & Info

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Unread 01-12-2006, 03:39 PM
Erahain Erahain is offline
A Crazed Gnoll
 
Join Date: Jan 2006
Server: Antonia Bayle
Posts: 23
Default Operators and conditionals

My second post about this; but this time in a new
thread =P

-

I don't know if this has already been discovered, but I'm
posting it in case of...

While doing some research, I stumbled across the ##
operator. It is used to concatenate strings. However, there
are a few syntax rules that must be followed.

Look at the example below:

Code:
<Button LocalText="Happy" A="Very" B="Happy"
OnPress="LocalText=A ## ' ' ## B"/>
Keep in mind; always space between the property/value
and the ##, unless you put it in a block (...).

This does NOT work:

Code:
<Button LocalText="Happy" A="Very" B="Happy"
OnPress="LocalText=A##' '##B"/>
... but this does...

Code:
<Button LocalText="Happy" A="Very" B="Happy"
OnPress="LocalText=(A)##(' ')##(B)"/>
Reply With Quote
  #2  
Unread 01-12-2006, 07:39 PM
mother9987's Avatar
mother9987 mother9987 is offline
An atom heart
This person is a EQ2Map developer.
Interface Author - Click to view interfaces
 
Join Date: Dec 2004
Server: Everfrost
Posts: 201
Default

Wow, I love you man... and in the most macho possible way.

Now, if only I could remember what I wanted Concatenate for. There's been so many things and I've just found ways to work around it. But there might be a few things I could still use it for...

Edit: Here's a use for it that I could never get around... Albiet not an earth-shattering use. Mother's Mail now with mail forward button! (Might still be pending approval)
__________________
'Tetht the printhiple, tetht the printhiple,' muttered Igor. 'Thorry, thur, but Igorth do not "tetht the printhiple". Thtrap it to the bench and put a good thick bolt of lightning through it, thatth our motto. Thatth how you tetht thomething.'

Last edited by mother9987 : 01-12-2006 at 08:31 PM. Reason: Insert Link
Reply With Quote
  #3  
Unread 01-12-2006, 08:34 PM
depechenode's Avatar
depechenode depechenode is offline
A Griffon
Interface Author - Click to view interfaces
 
Join Date: Nov 2004
Server: Toxxulia
Posts: 584
Default Omg!!!

If this does what it says, I can get my grp window mod a GREAT BIG FACE LIFT!!! THANK YOU!!!!!!!
Reply With Quote
  #4  
Unread 01-13-2006, 06:13 AM
Erahain Erahain is offline
A Crazed Gnoll
 
Join Date: Jan 2006
Server: Antonia Bayle
Posts: 23
Default

Well I'm sure a lot of people will find it usefull =)
Reply With Quote
  #5  
Unread 01-14-2006, 02:36 AM
SOE_Bobble SOE_Bobble is offline
EQII Developer
Yes this person is from Daybreak!
 
Join Date: Aug 2004
Posts: 82
Default

Nicely done.

I have access to the code and didn't even know this existed. So I went into the UIScriptEngine code tonight but didn't find any other secrets treasures.

Operators:
= - assignment
== != - comparison
< <= - less than
> >= - greater than
&& || - AND OR
! - negative
+ - * / - math
## - concat
?: - conditional
$ - assignment. calls "/<lhs> <rhs>"


Did anyone ever figure out the syntax for the conditional operator? If not, the spacing rules and () syntax of ## might be a clue.

Bobble
Reply With Quote
  #6  
Unread 01-14-2006, 07:26 AM
Erahain Erahain is offline
A Crazed Gnoll
 
Join Date: Jan 2006
Server: Antonia Bayle
Posts: 23
Default

The comparison operators works as they should, but there are a few rules
to this as well.

<=, >=, < and >
The values on either side will be converted to numbers (temporary during
the comparison). If any of the values cannot be converted (i.e. a text or
a poorly formated number) it will become 0.

Example ('a' < 1) is true as 'a' is equal to 0.

Please note that == and != is purely string conversations; this means that
0 == 00 is false, 'a' == 0 is false and 1 == 1 is true.

Good programming practice is to enclose the comparison operators in ''s, as
this is a requirement in order to use <= and >=.
I.e.: a '<=' 1

The above rules that applies for ## is applied here as well.

Another good one is that && and || should have their left and right sides
contained within blocks. But that's ofcourse up to the modder =)

Also remember, no ( ) blocks, or comparisons, at the left side of the &&
or || operators. *UPDATED*

(1 == 1) && (2 == 2)
IS NOT VALID

A note about XML:
Since the &-character is special in XML, doing '&&' will probably just hang
your client. Instead, replace '&&' with '&amp;&amp;'
This should do the trick!

Now to the conditional operators '?' and ':';
Each side on both of the operators must contain real values (or variables),
no special characters, operators or blocks.

(1 == 1) ? yes : no
The above example will not work, as left side of ? contains a block.

So how do we compare? Simple workaround.

Code:
COND ? yes : no COND = (1 == 1)
------------
A side note:

The UI scripting engine interprets the text from top to bottom, and from
right to left; examples below:

COND is set first, then LocalText:
Code:
COND=1
LocalText=COND
Same here, COND is set.. then LocalText:
Code:
LocalText=COND COND=1
------------
Assign (1 == 1) to COND, and use COND as the condition for ? :

And if we want to have some more complicated things to do, we'll
have to put them outside of the condition segment...

Code:
COND = MyGender == male
BROTHER = 'Welcome brother ' ## MyName 
SISTER = 'Welcome sister ' ## MyName
LocalText = COND ? BROTHER : SISTER
Please note this:

If the condition is TRUE - no further text can be appended to the resulting
value, but this doesn't prevent processing through.

Code:
LocalText = (X ? 'Cool' : 'Very' ) ## ' funny'
The above is a good example of this; if X is TRUE, LocalText will be set
to 'Cool' .. ignoring the text after the ( ? : ) block.

If X is FALSE, LocalText becomes 'Very' and ' funny' is appended to the
string.

-

If you have any more questions, please ask =)

Daniel

Last edited by Erahain : 01-14-2006 at 09:17 PM. Reason: additions..
Reply With Quote
  #7  
Unread 01-08-2009, 07:06 AM
samejima samejima is offline
A Griffon
Interface Author - Click to view interfaces
 
Join Date: Jul 2005
Server: Unrest
Posts: 156
Default

Quote:
Originally Posted by SOE_Bobble View Post
Nicely done.

I have access to the code and didn't even know this existed. So I went into the UIScriptEngine code tonight but didn't find any other secrets treasures.

Operators:
= - assignment
== != - comparison
< <= - less than
> >= - greater than
&& || - AND OR
! - negative
+ - * / - math
## - concat
?: - conditional
$ - assignment. calls "/<lhs> <rhs>"


Did anyone ever figure out the syntax for the conditional operator? If not, the spacing rules and () syntax of ## might be a clue.

Bobble
So that doesn't exist or just not working properly? I just want to do if x= y || z
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:03 AM.


Our Network
EQInterface | EQ2Interface | War.MMOUI | WoWInterface | VGInterface | LoTROInterface | MMOInterface