Announcement

Collapse
No announcement yet.

Is this a Listbox bug?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is this a Listbox bug?

    I've just cranked up AutoMenu 4 (previous version is 2) and was quite delighted by the improvements. Wow, this is really different. But I'm somewhat dismayed in that the first experiment I try turns out in confusing me. I added a listbox object with 3 entries labeled "One", "Two", and "Three" (no data attached to the display items.) Then the following code for the SelectionChanged event:
    %SelectedIndex%=ListBoxObject(Listbox1).GetSelecte d
    IF (%SelectedIndex%=0)
    TextObject(MouseOverText).SetText("You selected item 1")
    END IF
    IF (%SelectedIndex%=1)
    TextObject(MouseOverText).SetText("You selected item 2")
    END IF
    IF (%SelectedIndex%=2)
    TextObject(MouseOverText).SetText("You selected item 3")
    END IF

    This works as expected for the second two items, but not the first. When I select the first item (item "One") there's no change to the displayed text. When I select the second or third items, the text changes as expected. What am I missing here?



  • #2
    Re: Is this a Listbox bug?

    I just tried the same thing, and it works fine here.

    Are you sure you spelled the variable name, object name, etc. correctly in the first IF block?

    You can copy and paste this code if you want:

    <font color=green>
    <IR_ACTIONS_LIST>
    <Action name="IF">
    <Type>200</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Condition>%SelectedIndex% = 0</Condition>
    </Action>
    <Action name="Set Text">
    <Type>75</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <ObjectName>MouseOverText</ObjectName>
    <Text>You selected item 1</Text>
    </Action>
    <Action name="END IF">
    <Type>201</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    <Action name="Blank Line">
    <Type>203</Type>
    <Function>2</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    <Action name="IF">
    <Type>200</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Condition>%SelectedIndex% = 1</Condition>
    </Action>
    <Action name="Set Text">
    <Type>75</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <ObjectName>MouseOverText</ObjectName>
    <Text>You selected item 2</Text>
    </Action>
    <Action name="END IF">
    <Type>201</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    <Action name="Blank Line">
    <Type>203</Type>
    <Function>2</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    <Action name="IF">
    <Type>200</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Condition>%SelectedIndex% = 2</Condition>
    </Action>
    <Action name="Set Text">
    <Type>75</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <ObjectName>MouseOverText</ObjectName>
    <Text>You selected item 3</Text>
    </Action>
    <Action name="END IF">
    <Type>201</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    </IR_ACTIONS_LIST>
    </font color=green>
    --[[ Indigo Rose Software Developer ]]

    Comment


    • #3
      Re: Is this a Listbox bug?

      Lorne,
      Okay, I figured it out. There was a CRLF at the end of the %SelectedIndex%=0 line. Displayed, it looks like IF (%SelectedIndex%=0 ) Note the space character between the "0" and the ")" I think your parser's a bit overly sensitive here, but in any case I know what to watch out for. Thanks for the help.

      Comment


      • #4
        Re: Is this a Listbox bug?

        Are you sure? I actually wrote the parser, and it skips whitespace in the expression as it tokenizes.

        (Does a bit of testing...)

        Ah. For some reason a trailing newline is being seen as part of the value, so that instead of being "0" the last value is "0\n".

        Thanks for pointing this out! I'm on the case. [img]/ubbthreads/images/icons/smile.gif[/img]

        In the meantime, delete the trailing newline, and you should be fine.
        --[[ Indigo Rose Software Developer ]]

        Comment


        • #5
          Re: Is this a Listbox bug?

          Fixed it. [img]/ubbthreads/images/icons/smile.gif[/img]

          With luck this will make it into the next version.
          --[[ Indigo Rose Software Developer ]]

          Comment

          Working...
          X