EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   UI Developer Discussion (https://www.eq2interface.com/forums/forumdisplay.php?f=3)
-   -   String Compare? (https://www.eq2interface.com/forums/showthread.php?t=14969)

kdmorse 10-08-2010 10:45 PM

String Compare?
 
Is it possible to do primitive string compares at all? I seem to be drawing a blank.

Really, I'm looking for the logical equivalent of:

if Parent.Text5.Text == "" then
Parent.Temp = Parent.Input5.Text
else Parent.Temp = Parent.Text5.Text

Based on some things I've seen, I'm fumbling around with
Parent.Temp = Parent.Text5.Text eq '' ? Parent.Input5.Text : Parent.Text5.Text

Doesn't work of course, but that's what I'm aiming for. If one box has text in it, use that text. If not, use a different box....

Elsewhere, I'd love a 'Begins' type text compare. So I can compare the beginning of the string, but not the entire string (as the tail end changes) - but I suspect that's impossible with the tools at hand...

Thanks,

-Ken

EQAditu 10-08-2010 11:27 PM

Normally you can only do one evaluation per line, so try the following:

ISEMPTY=Parent.Text5.Text==''
Parent.Temp=ISEMPTY ? Parent.Input5.Text : Parent.Text5.Text


Or you can try to wrap the encoded apostrophes with parenthesis: ('')
I've never had great luck with comparing null strings but maybe one of those will work. Putting a null string into a variable and trying to compare with that variable doesn't work because the engine sees that no variable with a value exists by that name, so it treats the variable name as plain text.


We don't have any ability to do substring operations except for things like "123,456" put into a Location property of a Widget can be split by the comma by referencing the Left and Top properties.

kdmorse 10-11-2010 03:24 PM

Thanks - I think you're example, and comments are enough to help me get what I want done, even if it's in a slightly more convoluted way than expected.

Unfortunately, I just haven't had the time to get back to it and try it out. But I wanted to make sure I responded and thanked you for the help.

Thanks,

-Ken

gm9 10-11-2010 05:04 PM

Quote:

Originally Posted by EQAditu (Post 93711)
I've never had great luck with comparing null strings but maybe one of those will work. Putting a null string into a variable and trying to compare with that variable doesn't work because the engine sees that no variable with a value exists by that name, so it treats the variable name as plain text.

You can also make a helper attribute for that like empty="" onPress="ISEMPTY=Parent.Text5.Text==empty", that often helps around such issues.

EQAditu 10-11-2010 07:48 PM

If you say so, but the exact thing you quoted meant that I had no such luck with it. If I make an XML attribute with nothing in it, the engine treats the referenced attribute as plain text instead of a variable. I ended up making it " " (a space) instead of "" and it worked fine... so I left it like that.

gm9 10-12-2010 03:01 AM

Quote:

Originally Posted by EQAditu (Post 93749)
If you say so, but the exact thing you quoted meant that I had no such luck with it. If I make an XML attribute with nothing in it, the engine treats the referenced attribute as plain text instead of a variable. I ended up making it " " (a space) instead of "" and it worked fine... so I left it like that.

Fair enough, I know I used a space when dynamically doing it, too, am probably misremembering the attribute thing then.


All times are GMT -5. The time now is 05:29 PM.

vBulletin® - Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
© MMOUI