Sign in to follow this  
Followers 0
schliden

While Loop Logic

4 posts in this topic

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

Share this post


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

Share this post


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

Share this post


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

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