Scripting

  • 1.  Problems with comparing a string with a variable

    Posted 01-07-2014 21:50
    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)


  • 2.  RE: Problems with comparing a string with a variable

    Posted 01-07-2014 21:50
    Create Date: Jul 11 2013 4:31PM

    Hi,

    try -> while ( $par1 != "Image")

    Jarek (from Jaroslaw_Kasjaniuk)


  • 3.  RE: Problems with comparing a string with a variable

    Posted 01-07-2014 21:50
    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)


  • 4.  RE: Problems with comparing a string with a variable

    Posted 01-07-2014 21:50
    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)


  • 5.  RE: Problems with comparing a string with a variable

    Posted 01-07-2014 21:50
    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)


  • 6.  RE: Problems with comparing a string with a variable

    Posted 01-07-2014 21:50
    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)