Jump to content

While Loop Logic


schliden
 Share

Recommended Posts

Hi,

Wondering if there is a way to do the following:

I Have an input control that allows entry/selection of a path and a corresponding button that allows selection of same via FileSelectFolder

Here is the main While loop

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _End()
        Case $Input2
            ' How do I trigger the block of code below ?
        Case $Button2
            if _Target() Then
                if $gsFileList <> "" Then
                    if _BuildArray() Then
                        _BuildList()
                    endif
                    GUICtrlSetState($ListView1, $GUI_ENABLE)
                endif
            endif
    EndSwitch
WEnd

What I would like to do, is trigger the same code that occurs when Case $Button2 when Case $Input2.

Of course, I could just repeat the code under Case $Input2, or put the whole lot in a function, but I thought there might be an easier way ?

TIA

Link to comment
Share on other sites

Hi,

Wondering if there is a way to do the following:

I Have an input control that allows entry/selection of a path and a corresponding button that allows selection of same via FileSelectFolder

Here is the main While loop

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _End()
        Case $Input2
            ' How do I trigger the block of code below ?
        Case $Button2
            if _Target() Then
                if $gsFileList <> "" Then
                    if _BuildArray() Then
                        _BuildList()
                    endif
                    GUICtrlSetState($ListView1, $GUI_ENABLE)
                endif
            endif
    EndSwitch
WEnd

What I would like to do, is trigger the same code that occurs when Case $Button2 when Case $Input2.

Of course, I could just repeat the code under Case $Input2, or put the whole lot in a function, but I thought there might be an easier way ?

TIA

Try an 'or'... so your code would look like:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _End()
        Case $Button2 or $Input2
            if _Target() Then
                if $gsFileList <> "" Then
                    if _BuildArray() Then
                        _BuildList()
                    endif
                    GUICtrlSetState($ListView1, $GUI_ENABLE)
                endif
            endif
    EndSwitch
WEnd

See how that goes :shocked:

Link to comment
Share on other sites

Try an 'or'... so your code would look like:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _End()
        Case $Button2 or $Input2
            if _Target() Then
                if $gsFileList <> "" Then
                    if _BuildArray() Then
                        _BuildList()
                    endif
                    GUICtrlSetState($ListView1, $GUI_ENABLE)
                endif
            endif
    EndSwitch
WEnd

See how that goes :shocked:

Bert,

Of course. Yes that works.

It has introduced a new problem however.

The or $Input2 seems to be getting triggered when I least expect it, by a GUICtrlSetData.

I will have to re-think that logic.

Thanks

Sean

Link to comment
Share on other sites

Bert,

Of course. Yes that works.

It has introduced a new problem however.

The or $Input2 seems to be getting triggered when I least expect it, by a GUICtrlSetData.

I will have to re-think that logic.

Thanks

Sean

Yes that does seem to happen. I know there's a fix somewhere....

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