List box item value to set up loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • bruciori
    Forum Member
    • Apr 2003
    • 25

    List box item value to set up loop

    8 hours passed already since I tried to set this thing up... No result [img]/ubbthreads/images/icons/frown.gif[/img] 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... [img]/ubbthreads/images/icons/frown.gif[/img] I tried "<>" and "!=" - all the same [img]/ubbthreads/images/icons/frown.gif[/img] 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
    Indigo Rose Customer
    • Jul 2002
    • 3971

    #2
    Re: List box item value to set up loop

    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

    Comment

    • Adam
      Indigo Rose Staff Member
      • May 2000
      • 2149

      #3
      Re: List box item value to set up loop

      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>

      Comment

      • bruciori
        Forum Member
        • Apr 2003
        • 25

        #4
        Re: List box item value to set up loop

        Thank you guys! [img]/ubbthreads/images/icons/smile.gif[/img] Besides I messed up with the operations order a bit [img]/ubbthreads/images/icons/smile.gif[/img]

        Comment

        Working...
        X