Jump to content

Retrieve items in a 2D array and use them in "For" loop


Go to solution Solved by kylomas,

Recommended Posts

Hello everyone, it's me again having no clue what to do next with arrays...

kylomas nicely gave me a script that writes values to a 2D Array then ReDims it, but now I have no idea how to get the array in a "For" loop, I'm completely lost, no experience what-so-ever in dealing with Arrays and search gave me tons of results that I understood almost nothing from.

 

Here is the script kylomas gave me:

#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('', 400, 500)
Local $aSize = WinGetClientSize($gui010)
Local $Medical = GUICtrlCreateEdit('', 20, 20, 100, 60)
Local $Medical2 = GUICtrlCreateEdit('', 20, 150, 100, 60)
GUISetState()

Local $finalMC1, $finalMC2, $MC[0][2]

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    $finalMC1 = GUICtrlRead($Medical)
    $finalMC2 = GUICtrlRead($Medical2)
    If _GUICtrlEdit_LineLength($Medical) = 1 And _GUICtrlEdit_GetModify($Medical) > 0 Then
        GUICtrlSetState($Medical2, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical, False)
    EndIf
    If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) > 0 Then
        ReDim $MC[UBound($MC) + 1][2]
        $MC[UBound($MC) - 1][0] = $finalMC1
        $MC[UBound($MC) - 1][1] = $finalMC2
        GUICtrlSetState($Medical, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical2, False)
        _ArrayDisplay($MC)
    EndIf
WEnd

Now $MC array stores values just fine, how do I get around into retrieving the values and using them in my script? I tried reading about arrays in AutoIt wiki, came up with nothing, searched for examples and found none that apply to what I'm trying to accomplish here.

I can't post my script because it works on a secured website that requires username and password to access, and I did zero coding towards getting this thing to work so I have nothing else to share, so basically what I'm asking for sounds like what everyone in the forums hate, a working script without showing any scripting efforts from my side, so ignore this thread if you feel like it.

Edited by Palestinian
Link to comment
Share on other sites

I hope this example will help.  If it does not, can you be more specific on your confusion?

#include <array.au3>

Local $aTest[4][4] = [['a','b','c','d'],['e','f','g','h'],['i','j','k','l'],['m','n','o','p']]
_ArrayDisplay($aTest)

;Loop through each array item one by one
For $i1 = 0 To UBound($aTest,1) - 1
    ConsoleWrite("--Current index of dimension 1: " & $i1 & '/' & UBound($aTest,1) - 1 & @CRLF)
    For $i2 = 0 To UBound($aTest,2) - 1
        ConsoleWrite('Dimension 2 index: ' & $i2 & '/' & UBound($aTest,2) - 1 & ' = ' & $aTest[$i1][$i2] & @CRLF)
    Next
Next
Link to comment
Share on other sites

Palestinian,

It might help to visualize a 2D array as a spreadsheet where rows are D1 and columns are D2 such that $MC[3][2] will get the value from the second row, column 1 (arrays are '0' offset). 

The doc the MBALZESHARI pointed you to explains all of that, as does the example from DW1.

Building on the topic you previously posted I have added a button to dump the array to the console...

#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('', 400, 500)
Local $aSize = WinGetClientSize($gui010)
Local $Medical = GUICtrlCreateEdit('', 20, 20, 100, 60)
Local $Medical2 = GUICtrlCreateEdit('', 20, 150, 100, 60)
Local $dumparray = GUICtrlCreatebutton('Dump array MC to Console in Column Format', 20, 250, 360, 20)
GUISetState()

Local $finalMC1, $finalMC2, $MC[0][2]

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
                case $dumparray

                    _arraydisplay($MC)

                    for $1 = 0 to ubound($MC) - 1
                        for $2 = 0 to ubound($MC,2) - 1
                            ConsoleWrite(stringformat('%-10s',$MC[$1][$2]))
                        Next
                        ConsoleWrite(@LF)
                    next

    EndSwitch

    $finalMC1 = GUICtrlRead($Medical)
    $finalMC2 = GUICtrlRead($Medical2)
    If _GUICtrlEdit_LineLength($Medical) = 1 And _GUICtrlEdit_GetModify($Medical) > 0 Then
        GUICtrlSetState($Medical2, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical, False)
    EndIf
    If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) > 0 Then
        ReDim $MC[UBound($MC) + 1][2]
        $MC[UBound($MC) - 1][0] = $finalMC1
        $MC[UBound($MC) - 1][1] = $finalMC2
        GUICtrlSetState($Medical, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical2, False)
        EndIf

WEnd

Look at the CASE statment for the button to see if that makes sense.

Also, You might describe in language what you are trying to do because your use of the edit controls can probably be improved.
 

kylomas

edit: spelling

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Thank you guys for the quick response, Thank you DW1 for the example, and thank you MBALZESHARI for your suggestion.

 


Also, You might describe in language what you are trying to do because your use of the edit controls can probably be improved.

 

@kylomas: The script you gave me is getting half the job done, I tried tracking down whats wrong and found out that $MC[$1][$2] contains 2 separate values that cannot be used in "_IEFormElementOptionSelect" with "ByText" mode

What I'm trying to do is the following:

The user (Data entry officer) will be entering a medical diagnosis code into a website, the medical code includes a letter and 2 numbers, 1st the letter must be selected from a drop down menu, once that part is done, another menu values gets update according to which letter was selected in the 1st one, the 2nd menu includes the letter and 01-99 numbers, in my script the 2 edit controls are there for the letter and 2 numbers, in some cases there is more than 1 medical code, that's why I need an array, to store all the medical codes in case there is more than one and then enter them one by one, 1st by entering the letter, and then by entering both the letter and the number, I tried using _ArrayToString but the variable I try to assign $MS[$1][$2] to returns empty, I'll try and fixing it/different approach for this one, hopefully I'll be able to do it tonight.

Thank you again guys, I really appreciate all the help you guys are giving me.

Edited by Palestinian
Link to comment
Share on other sites

In case there is more than one code, how do you collect and store the data entered ?

This is not very clear, yet the way all this happens drives the way you'll have to manage it

 

If you are referring to the way the data is being collected and stored in the script provided in this thread, then it goes like the following:

I collect the data entered by using the edit controls, store them in the array, once $Medical = 1 char the script sets focus to $Medical2 and data gets stored in the array, once $Medical2 = 2 chars the script sets focus to $Medical and stores the data in the array, the process goes on until a button is clicked which then will recall the data from the array and put it in the website, 1st it calls the letter for the 1st menu, then the letter and the number as a single string for the 2nd menu.

The only remaining problem I'm left with at the moment is recalling the data from the array "both letter and numbers" as a single string to be used with the "_IEFormElementOptionSelect" "ByText" mode.

Link to comment
Share on other sites

Do you mean something like this ?

#include <GUIConstantsEx.au3>
#Include <Array.au3>

$gui = GUICreate( "Renommer fichiers par lots", 400, 400)
Local $e1 = GUICtrlCreateEdit("a", 20, 20, 100, 100)
Local $e2 = GUICtrlCreateEdit('', 20, 150, 100, 100)
$data2 = "15" & @crlf& "25"& @crlf& "42"

GUICtrlSetData($e2, $data2)
GUISetState()

$a2 = StringRegExp(GuiCtrlRead($e2), '(?i)[^\r\n]+', 3)
Dim $array[UBound($a2)][2]
For $i = 0 to UBound($a2)-1
    $array[$i][0] = GuiCtrlRead($e1)
    $array[$i][1] = $a2[$i]
Next
_ArrayDisplay($array)

$txt = ""
For $i = 0 to UBound($array)-1
    $txt &= $array[$i][0] & $array[$i][1] & @crlf
Next
Msgbox(0,"", $txt)


While 1
$msg = GUIGetMsg()
Switch $msg
    Case $GUI_EVENT_CLOSE
        Exit
EndSwitch
WEnd
Link to comment
Share on other sites

 

Do you mean something like this ?

#include <GUIConstantsEx.au3>
#Include <Array.au3>

$gui = GUICreate( "Renommer fichiers par lots", 400, 400)
Local $e1 = GUICtrlCreateEdit("a", 20, 20, 100, 100)
Local $e2 = GUICtrlCreateEdit('', 20, 150, 100, 100)
$data2 = "15" & @crlf& "25"& @crlf& "42"

GUICtrlSetData($e2, $data2)
GUISetState()

$a2 = StringRegExp(GuiCtrlRead($e2), '(?i)[^\r\n]+', 3)
Dim $array[UBound($a2)][2]
For $i = 0 to UBound($a2)-1
    $array[$i][0] = GuiCtrlRead($e1)
    $array[$i][1] = $a2[$i]
Next
_ArrayDisplay($array)

$txt = ""
For $i = 0 to UBound($array)-1
    $txt &= $array[$i][0] & $array[$i][1] & @crlf
Next
Msgbox(0,"", $txt)


While 1
$msg = GUIGetMsg()
Switch $msg
    Case $GUI_EVENT_CLOSE
        Exit
EndSwitch
WEnd

 

Yes sir, it's something like that, the $txt is exactly what I need to be able to use the _IEFormElementOptionSelect, most of the script you posted sounds like gibberish to me due to my experience in the fields arrays and StringRegExp, I'll try and break it down and hopefully understand how it works so I can implement it in my script, thank you :)

Link to comment
Share on other sites

  • Solution

Palestinian,

Using the code from before I've changed the button routine to create a variable that is a concatenation of both columns in each row...

#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('', 400, 500)
Local $aSize = WinGetClientSize($gui010)
Local $Medical = GUICtrlCreateEdit('', 20, 20, 100, 60)
Local $Medical2 = GUICtrlCreateEdit('', 20, 150, 100, 60)
Local $dumparray = GUICtrlCreatebutton('Dump array MC to Console in Column Format', 20, 250, 360, 20)
GUISetState()

Local $finalMC1, $finalMC2, $MC[0][2], $str

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
                case $dumparray

                    _arraydisplay($MC)

                    for $1 = 0 to ubound($MC) - 1
                        $str &= $MC[$1][0] & ' - ' & $MC[$1][1]
                        ;
                        ;  here is where you would do something with the variable
                        ;
                        ConsoleWrite($str & @LF)
                        $str = ''
                    next

    EndSwitch

    $finalMC1 = GUICtrlRead($Medical)
    $finalMC2 = GUICtrlRead($Medical2)
    If _GUICtrlEdit_LineLength($Medical) = 1 And _GUICtrlEdit_GetModify($Medical) > 0 Then
        GUICtrlSetState($Medical2, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical, False)
    EndIf
    If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) > 0 Then
        ReDim $MC[UBound($MC) + 1][2]
        $MC[UBound($MC) - 1][0] = $finalMC1
        $MC[UBound($MC) - 1][1] = $finalMC2
        GUICtrlSetState($Medical, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical2, False)
        EndIf

WEnd

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Palestinian,

There is no need to use edit controls if you are not going to enter more than one line at a time (although you can if you like).

The way the code was structured it is possible to enter more than 2 chars in the second edit control.

I changed the code around somewhat and added the following:

  - message handler

      This routine is called for every character entered into the input controls.  This gives you the opportunity to edit/deny/change what is entered.

  - changed you edit controls to input controls

  - added labels

  - added dummy controls

      These are where you get control at every char entered

  - added logic to test for alpha / num where appropriate (you can do the error routine(s))

Again, the Help files and the Wiki are your best friend right now.

#include <GuiEdit.au3>
#include <array.au3>
#include <GUIConstants.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('', 400, 500)
Local $aSize = WinGetClientSize($gui010)
GUICtrlCreateLabel('Medical', 20, 20, 70, 20)
Local $Medical = GUICtrlCreateInput('', 80, 20, 30, 20)
GUICtrlCreateLabel('Medical2', 20, 50, 70, 20)
Local $Medical2 = GUICtrlCreateInput('', 80, 50, 30, 20)

; the following two controls are actioned by the command routine

Local $Medical_dummy = GUICtrlCreateDummy()
Local $Medical2_dummy = GUICtrlCreateDummy()

Local $Process_Entries = GUICtrlCreateButton('Process Entries', 20, 250, 360, 20)
GUISetState()
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

Local $MC[0][2], $str

While 1

    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            Exit

        Case $Process_Entries

            _ArrayDisplay($MC)

            For $1 = 0 To UBound($MC) - 1
                $str &= $MC[$1][0] & ' - ' & $MC[$1][1]
                ;
                ;  here is where you would do something with the variable
                ;
                ConsoleWrite($str & @LF)
                $str = ''
            Next

        Case $Medical_dummy

            If Not StringIsAlpha(GUICtrlRead($Medical)) Then ; make sure character entered is alpha
                ;
                ; do some error routine
                ;
            Else
                GUICtrlSetState($Medical2, $GUI_FOCUS)
            EndIf

        Case $Medical2_dummy

            If Not StringIsDigit(GUICtrlRead($Medical2)) Then ; make sure char entered is number
                ;
                ; do sone error routine
                ;
            EndIf

            If _GUICtrlEdit_LineLength($Medical2) = 2 Then ; when two chars have been entered....
                ReDim $MC[UBound($MC) + 1][2] ;    increase array
                $MC[UBound($MC) - 1][0] = GUICtrlRead($Medical) ;    add each input control to the array
                $MC[UBound($MC) - 1][1] = GUICtrlRead($Medical2);        ...
                GUICtrlSetData($Medical, '') ;    blank the input controls
                GUICtrlSetData($Medical2, '') ;    ...
                GUICtrlSetState($Medical, $GUI_FOCUS) ; set focus back to first input control
            EndIf

    EndSwitch

WEnd

; this routine is called every time something is entered in one of the input boxes
; The routine then actions a control (dummy) where you do stuff

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Switch BitShift($wParam, 16)
        Case $EN_UPDATE
            Switch BitAND($wParam, 0xFFFF)
                Case $Medical
                    GUICtrlSendToDummy($Medical_dummy)
                Case $Medical2
                    GUICtrlSendToDummy($Medical2_dummy)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

 

Palestinian,

Using the code from before I've changed the button routine to create a variable that is a concatenation of both columns in each row...

#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('', 400, 500)
Local $aSize = WinGetClientSize($gui010)
Local $Medical = GUICtrlCreateEdit('', 20, 20, 100, 60)
Local $Medical2 = GUICtrlCreateEdit('', 20, 150, 100, 60)
Local $dumparray = GUICtrlCreatebutton('Dump array MC to Console in Column Format', 20, 250, 360, 20)
GUISetState()

Local $finalMC1, $finalMC2, $MC[0][2], $str

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
                case $dumparray

                    _arraydisplay($MC)

                    for $1 = 0 to ubound($MC) - 1
                        $str &= $MC[$1][0] & ' - ' & $MC[$1][1]
                        ;
                        ;  here is where you would do something with the variable
                        ;
                        ConsoleWrite($str & @LF)
                        $str = ''
                    next

    EndSwitch

    $finalMC1 = GUICtrlRead($Medical)
    $finalMC2 = GUICtrlRead($Medical2)
    If _GUICtrlEdit_LineLength($Medical) = 1 And _GUICtrlEdit_GetModify($Medical) > 0 Then
        GUICtrlSetState($Medical2, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical, False)
    EndIf
    If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) > 0 Then
        ReDim $MC[UBound($MC) + 1][2]
        $MC[UBound($MC) - 1][0] = $finalMC1
        $MC[UBound($MC) - 1][1] = $finalMC2
        GUICtrlSetState($Medical, $GUI_FOCUS)
        _GUICtrlEdit_SetModify($Medical2, False)
        EndIf

WEnd

 

I honestly don't know how to thank you enough kylomas, you and everyone who helped me in this matter, I still have a lot to learn about arrays and this made a perfect start for me, you guys are awesome :)

Here is a snippet of my script where this code is implemented:

#include <GuiEdit.au3>
#include <array.au3>
#include <GUIConstants.au3>
#include <IE.au3>
#include <string.au3>
#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('', 400, 500)
Local $aSize = WinGetClientSize($gui010)
GUICtrlCreateLabel('Medical', 20, 20, 70, 20)
Local $Medical = GUICtrlCreateInput('', 80, 20, 30, 20)
GUICtrlCreateLabel('Medical2', 20, 50, 70, 20)
Local $Medical2 = GUICtrlCreateInput('', 80, 50, 30, 20)

$s = GUICtrlCreateLabel('resault', 20, 100, 70, 20)

; the following two controls are actioned by the command routine

Local $Medical_dummy = GUICtrlCreateDummy()
Local $Medical2_dummy = GUICtrlCreateDummy()

Local $Process_Entries = GUICtrlCreateButton('Process Entries', 20, 250, 360, 20)
GUISetState()
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

Local $MC[0][2], $str

While 1

    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            Exit

        Case $Process_Entries
            
            $oIE = _IEAttach("Health Assistance")
            $oForm = _IEFormGetObjByName($oIE, "aspnetForm")
            
            For $1 = 0 To UBound($MC) - 1
                $str &= $MC[$1][0] & '' & $MC[$1][1]
                $iDisease = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListDiseaseGroupCode")
                If StringInStr($str, "A") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 2, 1, "ByValue")
                If StringInStr($str, "B") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 2, 1, "ByValue")
                If StringInStr($str, "C") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 3, 1, "ByValue")
                If StringInStr($str, "E") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 5, 1, "ByValue")
                If StringInStr($str, "F") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 6, 1, "ByValue")
                If StringInStr($str, "G") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 7, 1, "ByValue")
                If StringInStr($str, "H") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 8, 1, "ByValue")
                If StringInStr($str, "H") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 9, 1, "ByValue")
                If StringInStr($str, "I") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 10, 1, "ByValue")
                If StringInStr($str, "J") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 11, 1, "ByValue")
                If StringInStr($str, "K") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 12, 1, "ByValue")
                If StringInStr($str, "L") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 13, 1, "ByValue")
                If StringInStr($str, "M") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 14, 1, "ByValue")
                If StringInStr($str, "N") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 15, 1, "ByValue")
                If StringInStr($str, "O") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 16, 1, "ByValue")
                If StringInStr($str, "P") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 17, 1, "ByValue")
                If StringInStr($str, "Q") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 18, 1, "ByValue")
                If StringInStr($str, "R") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 19, 1, "ByValue")
                If StringInStr($str, "S") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 20, 1, "ByValue")
                If StringInStr($str, "T") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 20, 1, "ByValue")
                If StringInStr($str, "V") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 21, 1, "ByValue")
                If StringInStr($str, "W") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 21, 1, "ByValue")
                If StringInStr($str, "X") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 21, 1, "ByValue")
                If StringInStr($str, "Y") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 21, 1, "ByValue")
                If StringInStr($str, "Z") Then $iDiseaseG = _IEFormElementOptionSelect($iDisease, 22, 1, "ByValue")
                
                Sleep(500)
                While 1
                    $oIE = _IEAttach("Health Assistance")
                    $iPleaseWait = _IEGetObjById($oIE, "ctl00_panelUpdateProgress")
                    $inner = $iPleaseWait.innerhtml
                    $iLoading = StringInStr($inner, 'true')
                    If $iLoading Then
                        ExitLoop
                    EndIf
                    Sleep(100)
                WEnd
                
                $eMedicalCode = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListDiagnosisCode")
                _IEFormElementOptionSelect($eMedicalCode, $str, 1, "ByText")
                
                Sleep(500)
                While 1
                    $oIE = _IEAttach("Health Assistance")
                    $iPleaseWait = _IEGetObjById($oIE, "ctl00_panelUpdateProgress")
                    $inner = $iPleaseWait.innerhtml
                    $iLoading = StringInStr($inner, 'true')
                    If $iLoading Then
                        ExitLoop
                    EndIf
                    Sleep(100)
                WEnd
                
                $oAddMCode = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddDiagnosis")
                _IEAction($oAddMCode, "click")
                
                Sleep(500)
                While 1
                    $oIE = _IEAttach("Health Assistance")
                    $iPleaseWait = _IEGetObjById($oIE, "ctl00_panelUpdateProgress")
                    $inner = $iPleaseWait.innerhtml
                    $iLoading = StringInStr($inner, 'true')
                    If $iLoading Then
                        ExitLoop
                    EndIf
                    Sleep(100)
                WEnd
                
                $str = ''
            Next

        Case $Medical_dummy

            If Not StringIsAlpha(GUICtrlRead($Medical)) Then ; make sure character entered is alpha
                ;
                ; do some error routine
                ;
            Else
                GUICtrlSetState($Medical2, $GUI_FOCUS)
            EndIf

        Case $Medical2_dummy

            If Not StringIsDigit(GUICtrlRead($Medical2)) Then ; make sure char entered is number
                ;
                ; do sone error routine
                ;
            EndIf

            If _GUICtrlEdit_LineLength($Medical2) = 2 Then ; when two chars have been entered....
                ReDim $MC[UBound($MC) + 1][2] ;    increase array
                $MC[UBound($MC) - 1][0] = GUICtrlRead($Medical) ;    add each input control to the array
                $MC[UBound($MC) - 1][1] = GUICtrlRead($Medical2);        ...
                GUICtrlSetData($Medical, '') ;    blank the input controls
                GUICtrlSetData($Medical2, '') ;    ...
                GUICtrlSetState($Medical, $GUI_FOCUS) ; set focus back to first input control
            EndIf

    EndSwitch

WEnd

; this routine is called every time something is entered in one of the input boxes
; The routine then actions a control (dummy) where you do stuff

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Switch BitShift($wParam, 16)
        Case $EN_UPDATE
            Switch BitAND($wParam, 0xFFFF)
                Case $Medical
                    GUICtrlSendToDummy($Medical_dummy)
                Case $Medical2
                    GUICtrlSendToDummy($Medical2_dummy)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

 

Please feel free to point out anything that I might be doing wrong or if anything can be improved :)

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