Sign in to follow this  
Followers 0
Maffe811

For loop thing to simplify repetition...

4 posts in this topic

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]

Share this post


Link to post
Share on other sites



Yes something like that. You don't need to state Step 1 because For loops do that by default. If you want to step a different interval either positive or negative, that's when you need to use Step $nval. So is your code not working?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0