Macro Toolworks Products Discussion Forums :: General Discussion
Welcome Guest   
 Subject :a question about == and ~=.. 27-03-2012 13:49:29 
hugblue@hotmail.com
Joined: 13-10-2010 01:09:07
Posts: 109
Location: sweden
hi petr ..

i cannot get the deeper difference between these two. not even after reading the help.

can u help me understand the difference ?.
and normally i use == but in some areas i was needed to use ~=. so sometimes its trial and error. before i get the result i want.

so please help me understand and in a very understandable way.
and if u can support with some code in your explanation.

i think i sometimes gets lost in the difference between number vs string variables.

thz.
IP Logged
 Subject :Re:a question about == and ~=.. 29-03-2012 14:10:51 
petr
Joined: 15-10-2009 11:48:52
Posts: 196
Location
Hi,

basically "==" operator means "is the same" while "~=" operator means "one string contains other". So for example it is true that "THIS_STRING"~="IS_STR". This ~= operator can be only used for strings (texts) and not for numbers.

Here is a sample code that could help.

<cmds>

<varset>("vStr1=Hello, World!","")
<varset>("vStr2=Wor","")

<if_str>("vStr1~=vStr2")
<msg>(-100,-100,"Yes, one string contains ~= other","Message",1,0,0,1)
<endif>

<if_str>("vStr1==vStr2")
<msg>(-100,-100,"This should never happen!","Message",1,0,0,1)
<else>
<msg>(-100,-100,"Correct, the strings are not identical ==","Message",1,0,0,1)
<endif>


>>> i think i sometimes gets lost in the difference between number vs string variables.

It just depends on macro logic what kind of data is in variable. For example if you have two variables that contains X and Y position of a pixel on the screen, then you know the variable always contains number and you want to use numerical operations, for example:

<if_num>("vX > 100")

but you do not want let the macro work with the data as strings like do this:

<if_str>("vX > 100")

Best regards,
Petr
IP Logged
 Subject :Re:a question about == and ~=.. 01-04-2012 17:05:56 
hugblue@hotmail.com
Joined: 13-10-2010 01:09:07
Posts: 109
Location: sweden
thz alot petr ..
IP Logged
Page # 


Powered by ccBoard


Login and share your experience - send messages to forums and add comments to samples, commands and other resources.



Account is free of charge, easy to setup.