PDA

View Full Version : List box item value to set up loop


bruciori
04-17-2003, 02:23 PM
8 hours passed already since I tried to set this thing up... No result /ubbthreads/images/icons/frown.gif Guys, could you please share your wisdom with me?

Here's the thing:

I set up a basic list box object with items like:

1::1
2::2
10::10
etc::etc

Those listbox items/values on selection act like "set up %counter% value" to do some macro stuff (if set to 10 - then loop 10 times, etc). Then I have a button which starts the loop thing based on %counter% value on mouse click: first it sets %loop%=0 and then while %loop%<%counter% it does macro and evaluates %loop%+1 to make %loop%=%counter% (end while)... But it provides infinite loop... /ubbthreads/images/icons/frown.gif I tried "<>" and "!=" - all the same /ubbthreads/images/icons/frown.gif I want to know where's my mistake... Also I would like to know how to zero %loop% value when %counter%=%loop% (ie macro completed).

Worm
04-17-2003, 02:43 PM
It sounds like your %counter% variable isn't getting set properly. To debug things, try using a Message box dialog before the If statement and have it show the value of %counter% so you can tell whether it is being set properly.

As for setting the %counter% value to the selected item in the listbox try something like this:

%SelectedIndex% = ListBoxObject[ListBox1].GetSelected
IF (%SelectedIndex% != -1)
%counter% = ListBoxObject[ListBox1].GetItemData (%SelectedIndex%)
%loop% = "0"
WHILE (%loop% < %counter%)
// Do your Macro stuff here
%loop% = Evaluate (%loop% + 1)
END WHILE
ELSE
%Result% = Dialog.MessageBox ("Item not Selected", "Please select an item in the l...", Ok, Question)
END IF

Adam
04-17-2003, 02:46 PM
Here is an action list that you can copy and paste into a text object that demonstrates how to perform a while loop:

<IR_ACTIONS_LIST>
<Action name="Comment">
<Type>202</Type>
<Function>2</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Comment>This gets set by your List Box as described in your post</Comment>
</Action>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%Counter%</Variable>
<Value>10</Value>
<Evaluate>0</Evaluate>
</Action>
<Action name="Comment">
<Type>202</Type>
<Function>2</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Comment>Always set the loop variable to 0, just in case it is not already 0</Comment>
</Action>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%loop%</Variable>
<Value>0</Value>
<Evaluate>0</Evaluate>
</Action>
<Action name="Comment">
<Type>202</Type>
<Function>2</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Comment>while loop &amp;lt; counter</Comment>
</Action>
<Action name="WHILE">
<Type>204</Type>
<Function>1</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Condition>%loop% &amp;lt; %Counter%</Condition>
</Action>
<Action name="Comment">
<Type>202</Type>
<Function>2</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Comment>Just so that you can see that the loop works</Comment>
</Action>
<Action name="Message Box">
<Type>5</Type>
<Function>0</Function>
<DTIndentLevel>1</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<DialogTitle>Title</DialogTitle>
<DialogMessage>the value of the loop variable is = %loop%</DialogMessage>
<Icon>3</Icon>
<Variable>%Result%</Variable>
<DialogType>0</DialogType>
<DefaultButton>0</DefaultButton>
</Action>
<Action name="Comment">
<Type>202</Type>
<Function>2</Function>
<DTIndentLevel>1</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Comment>Increment the %loop% variable</Comment>
</Action>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>1</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%loop%</Variable>
<Value>%loop% + 1</Value>
<Evaluate>1</Evaluate>
</Action>
<Action name="END WHILE">
<Type>205</Type>
<Function>1</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
</Action>
<Action name="Comment">
<Type>202</Type>
<Function>2</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Comment>set %loop% back to 0 for the next time</Comment>
</Action>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%loop%</Variable>
<Value>0</Value>
<Evaluate>0</Evaluate>
</Action>
</IR_ACTIONS_LIST>

bruciori
04-17-2003, 04:06 PM
Thank you guys! /ubbthreads/images/icons/smile.gif Besides I messed up with the operations order a bit /ubbthreads/images/icons/smile.gif