Jump to content

For loop thing to simplify repetition...


Recommended Posts

I know there is a simple way of making this:

_GUICtrlComboBox_SetCurSel($Switch_Combo_Hotkey, 0)
$StringCount = _GUICtrlComboBox_GetCount($Switch_Combo_Hotkey)
_GUICtrlComboBox_DeleteString($Switch_Combo_Hotkey, $StringCount - 1)

_GUICtrlComboBox_SetCurSel($Prog1_Combo_Hotkey, 0)
$StringCount = _GUICtrlComboBox_GetCount($Prog1_Combo_Hotkey)
_GUICtrlComboBox_DeleteString($Prog1_Combo_Hotkey, $StringCount - 1)

_GUICtrlComboBox_SetCurSel($Prog2_Combo_Hotkey, 0)
$StringCount = _GUICtrlComboBox_GetCount($Prog2_Combo_Hotkey)
_GUICtrlComboBox_DeleteString($Prog2_Combo_Hotkey, $StringCount - 1)

Something like this:

For $i = 1 to $Array[0] step 1
_GUICtrlComboBox_SetCurSel($Array[$i], 0)
$StringCount = _GUICtrlComboBox_GetCount($Array[$i])
_GUICtrlComboBox_DeleteString($Array[$i], $StringCount - 1)
Next

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

So is your code not working?

No, its not. :(

$Array = StringSplit("$Switch_Combo_Hotkey|$Prog1_Combo_Hotkey|$Prog2_Combo_Hotkey","|")

For $i = 1 to $Array[0] step 1
_GUICtrlComboBox_SetCurSel($Array[$i], 0)
$StringCount = _GUICtrlComboBox_GetCount($Array[$i])
_GUICtrlComboBox_DeleteString($Array[$i], $StringCount - 1)
Next

To me, this should do what the code in my first post do, except it doesn't.

What i'm i doing wrong?

You don't need to state Step 1 because For loops do that by default.

I know, i just got a habbit of stating it. :P

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

you are doing _guictrlcombo actions on the array?

are you just trying to delete it out of the combo like so:

#include
#Include



$Array = StringSplit("$Switch_Combo_Hotkey|$Prog1_Combo_Hotkey|$Prog2_Combo_Hotkey","|")


_ArrayDisplay ($Array)


$hGUI = GUICreate("(UDF) ComboBox Create", 400, 296)
$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296)
GUISetState()

sleep (1000)



For $i = 1 to $Array[0]
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddString($hCombo, $Array[$i])
_GUICtrlComboBox_EndUpdate($hCombo)
sleep (1000)
Next

sleep (1000)

For $i = 1 to $Array[0]
_GUICtrlComboBox_SetCurSel($hcombo, 0)
$StringCount = _GUICtrlComboBox_GetCount($hcombo)
_GUICtrlComboBox_DeleteString($hcombo, $StringCount - 1)
sleep (1000)
Next
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...