PDA

View Full Version : Is this a Listbox bug?



Barsky
09-03-2002, 09:12 AM
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?

Lorne
09-03-2002, 10:15 AM
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>

Barsky
09-03-2002, 12:24 PM
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.

Lorne
09-03-2002, 01:02 PM
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. /ubbthreads/images/icons/smile.gif

In the meantime, delete the trailing newline, and you should be fine.

Lorne
09-03-2002, 02:03 PM
Fixed it. /ubbthreads/images/icons/smile.gif

With luck this will make it into the next version.