curious "if" - experience

  • Hallo Klaus,

    i ran into the following situation:
    A help-box describing basic usage of the app was defined somewhere and is shown up / hidden by user (clicking the help button).
    The plugin "HelpBox" and the corresponding actions "showHelp" and "hideHelp" already worked fine.
    All easy, all worked...

    ...until i decided to show this box at startup too. In the main xml-definition there is a plugin "myVar", only carrying certain vars (maincolor of my tour elements, showMapAtStart, ...) i defined a new var >HelpAtStart = "true"< for it.
    And the "HelpBox" additionally now recieved an "onloaded=action(askforhelp)".
    This shoud work as following:

    Code
    <action name="askforhelp">
    	if(plugin[myvar].HelpAtStart == true, action(showHelp));
    </action>


    ...but does not.
    i also tried quoted true:

    Code
    <action name="askforhelp">
    if(plugin[myvar].HelpAtStart == "true", action(showHelp));
    </action>


    ...nothing.
    When i test the following, i get results:

    Code
    <action name="askforhelp">
    	trace(plugin[myvar].HelpAtStart);     	// ---> traces true
    	action(showHelp);                            	// ---> and runs the expected action
    </action>


    al last i tried this and succeeded(!):

    Code
    <action name="askforhelp">
    	if(plugin[myvar].HelpAtStart, action(showHelp));
    </action>

    Is this normal to the "if( , ,)" command or a bugy (mis)interpretation of >true< in this case?? *confused*

  • Hi,

    no, that's not normal
    can you show a full example?

    there is a small bug in the current beta 7 with the order of how the actions are executed,
    this bug happens only in a combination of if() and action(), maybe this is the problem here...

    best regards,
    Klaus

  • String != Boolean

    ohh, you're right, this was the problem
    I have tested and looked at the code again,

    normally the predeclared values are from the correct type,
    but self declared variables are always strings,

    I thought I have already fixed that, but now it's really fixed for beta 8

    best regards,
    Klaus

  • but if user declared variables always are interpreted as strings
    this (i tried)

    Code
    <action name="askforhelp">
    if(plugin[myvar].HelpAtStart == "true", action(showHelp));
    </action>


    should work, but also did not...

    See all relevant code here:

    Code
    <plugin name = "myvar" 
    	keep="true"
    	maincolor="0xFFCC00"
    	radarcolor="0xFFCC00"
    	radarfillalpha="0.7"
    	prevTextbackcolor="0x000000"
    	mapStart="closed"
    	HelpStart="true"  
    />


    and

    ONLY(!) this works; if you (in the acion "askforhelp") compare [myvar].helpstart against any value it does not!

  • Hi,

    but if user declared variables always are interpreted as strings
    this (i tried)

    <action name="askforhelp">
    if(plugin[myvar].HelpAtStart == "true", action(showHelp));
    </action>

    should work, but also did not...

    that's because the quotes ("") are currently not resolved (but in beta 8 they are),
    in this case it would compare - true - with - "true" - again not the same

  • I have one question. How do i use BlackyOn and BlackyOff ?
    I've tried to put blackyon when people click on the info button, but doesn't do anything.

    Here is the code:

    I am missing something ?

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!