cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with comparing a string with a variable

Problems with comparing a string with a variable

EtherNation_Use
Contributor II
Create Date: Jul 11 2013 2:15PM

Hi,

I want to compare the content of a variable with a string, but it doesn't works.

Here the posting of some examples and the error messages which I get:

# variables
set var count 0
set var par1 "Image"

# example 1
set var count ($count + 1)
show var count
while ("$par1" != "Image") DO
show var $par1
endwhile
# Message:
# Error:can't read "par1": no such variable
# Variable Image not found.
# Error: Mismatched ENDWHILE



# example 2
set var count ($count + 1)
show var count
while ("Image" != "Image") DO
show var $par1
endwhile
# No Error-Message

# example 3
set var count ($count + 1)
show var count

while (part1 != "Image") DO
show var $par1
endwhile
#Error-Message:
#Error:syntax error in expression "(part1 != "Image")"

#Variable Image not found.
#Error: Mismatched ENDWHILE

Does somebody knows the rigth syntax?

(from Hans_Vedder)
5 REPLIES 5

EtherNation_Use
Contributor II
Create Date: Jul 15 2013 12:30PM

That is TCL language, in EXOS you can use it but it's a bit "limited version".
You can find many examples in the internet, for exampl. http://wiki.tcl.tk/.

--
Jarek (from Jaroslaw_Kasjaniuk)

EtherNation_Use
Contributor II
Create Date: Jul 15 2013 12:12PM

Thank you very much. This works fine.

You used the syntax:

while ( [string equal $par1 Image ] ) do
...

Where do I find the syntax of the string command? It's not described in the Concepts Guide 15.3.

There I read:
== Boolean equal
!= Boolean not equal

Each operator produces a zero or one result. These operators are valid for all operand types.





(from Hans_Vedder)

EtherNation_Use
Contributor II
Create Date: Jul 12 2013 2:32PM

Ah..that was strings ..

maybe this would help you
while ( ! [string equal $par1 "Image" ] ) do

--
Jarek (from Jaroslaw_Kasjaniuk)

EtherNation_Use
Contributor II
Create Date: Jul 12 2013 8:21AM

I tried:

set var par1 "Image"
while ($par1 != "Image") DO
show var $par1
endwhile

and get the error message:

Error:syntax error in expression "(Image != "Image")"

Variable Image not found.
Error: Mismatched ENDWHILE

(from Hans_Vedder)
GTM-P2G8KFN