Jump to content

Selecting part of a loop and then continuing


Recommended Posts

ok what I am wanting to do is, Have a Combo with lets say 6 choices. And after one of them is selected it would be written to an ini file.

After start is pressed, it would send it to a function with 6 different options. And where it would start would depend on the choice in the Combo box. So it would run that one, go on to the next to the end then repeat that function.

I am having a hard time figuring out how to keep it from calling from the ini after the 1st run is done.

Here's my example

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)

start()

Func start()

    Local $hcombo, $hGUI, $hButton, $hcombo2, $hLabel2

    $hGUI = GUICreate("test - Start from", 340, 115, 10, 100, 1, $WS_EX_TOPMOST)
    $hLabel2 = GUICtrlCreateLabel(" Please choose where you want to start.", 10, 10, 330, 20)
    GUICtrlSetFont($hLabel2, Default, 600)


    $hcombo = GUICtrlCreateCombo("1", 10, 30, 50, 25)
    GUICtrlSetData(-1, "2|3|4|5|6")


    $hButton = GUICtrlCreateButton("Start", 115, 60, 100, 20)

    GUISetState()

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $hButton
                IniWrite(@ScriptDir & "\settings.ini", "start from", "start", GUICtrlRead($hcombo))

                GUIDelete()
                gotofunc()
        EndSwitch

    WEnd
EndFunc

So that would allow me to select where to start from.

And then go into the func

gotofunc()

local $iniread
$iniread = iniread((@ScriptDir & "\settings.ini", "start from", "start", "")

while 1
if $iniread = 1 then
do option 1
end if
if $iniread = 2 then
option2
endif
ect ect...
wend
endfunc

But as you can see I want it to loop all the actions and only start at 1 spot.

I hope this makes sense and appreciate any feed back on this.

Thanks

Cue

Link to comment
Share on other sites

Why exactly do you need to save the setting? If you just want to be able to do a set of actions based on the value of the combo box, something like this would be better:

Func start()
    Local $hcombo, $hGUI, $hButton, $hcombo2, $hLabel2, $iStart

    $hGUI = GUICreate("test - Start from", 340, 115, 10, 100, 1, $WS_EX_TOPMOST)
    $hLabel2 = GUICtrlCreateLabel(" Please choose where you want to start.", 10, 10, 330, 20)
    GUICtrlSetFont($hLabel2, Default, 600)
    $hcombo = GUICtrlCreateCombo("1", 10, 30, 50, 25)
    GUICtrlSetData(-1, "2|3|4|5|6")
    $hButton = GUICtrlCreateButton("Start", 115, 60, 100, 20)
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $hButton
                $iStart = GUICtrlRead($hcombo)
                IniWrite(@ScriptDir & "\settings.ini", "start from", "start", $iStart)
                Switch $iStart
                    Case 1
                        ; option 1
                    Case 2
                        ; option 2
                EndSwitch
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc
Link to comment
Share on other sites

If your not going to reuse the information in the *.ini why not just use a variable?

and then put your goto func loop inside the $hbutton case.

Edit: :idea: yeah thats what I meant... | Note to self: refresh before posting.:)

Edited by billo
Link to comment
Share on other sites

what im worried about is it not looping once it is has completed the 1st option.

Is there a way to do it like this:

local $hGUI, $hButton, $hcombo, $hLabel2, $istart

$hGUI = GUICreate("Test - Start Test", 340, 115, 10, 100, 1, $WS_EX_TOPMOST)
    $hLabel2 = GUICtrlCreateLabel(" Please choose which where you want to start.", 10, 10, 330, 20)
    GUICtrlSetFont($hLabel2, Default, 600)


    $hcombo = GUICtrlCreateCombo("1", 10, 30, 50, 25)
    GUICtrlSetData(-1, "2|3|4|5|6")


    $hButton = GUICtrlCreateButton("Start", 115, 60, 100, 20)

    GUISetState()

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $hButton
            $iStart = GUICtrlRead($hcombo)
                GUIDelete()

        EndSwitch
    wend

    if $istart = 1 Then
        msgbox(0, "#1", "1")
    EndIf

Im just playing around with it now to try ang get it to work the way I am wanting.

The goal is to take the $istart and insert it at different points of a function.

so it would have everything above and all I would add is if $istart = 1 then

and then send it to part of the function.

then it would loop the entire function starting where i decide.

hope its not too confusing. Think i might have just confused myself :idea:

Link to comment
Share on other sites

Just playing around...maybe this is sort of what your looking for:

Local $hGUI, $hButton, $hcombo, $hLabel2, $istart

$hGUI = GUICreate("Test - Start Test", 340, 115, 10, 100, 1, $WS_EX_TOPMOST)
$hLabel2 = GUICtrlCreateLabel(" Please choose which where you want to start.", 10, 10, 330, 20)
GUICtrlSetFont($hLabel2, Default, 600)


$hcombo = GUICtrlCreateCombo("1", 10, 30, 50, 25)
GUICtrlSetData(-1, "2|3|4|5|6")


$hButton = GUICtrlCreateButton("Start", 115, 60, 100, 20)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            $istart = GUICtrlRead($hcombo)
            GUIDelete()
    EndSwitch
    If $istart = 1 Then
        For $istart = 1 To 6
            MsgBox(0, "Count", $istart)
        Next
    EndIf
    If $istart = 2 Then
        For $istart = 2 To 7
            MsgBox(0, "Count", $istart)
        Next
    EndIf
    If $istart = 3 Then
        For $istart = 3 To 8
            MsgBox(0, "Count", $istart)
        Next
    EndIf
    If $istart = 4 Then
        For $istart = 4 To 9
            MsgBox(0, "Count", $istart)
        Next
    EndIf
;======>and so on
WEnd

I'm sure theres a way to loop this but ut's getting late :idea:

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...