Sign in to follow this  
Followers 0
Palestinian

Script loops when it shouldn't

16 posts in this topic

I changed something, somewhere, sometime in my script and now it sometimes loops when it shouldn't, sometimes it doesn't, I just need some of you guys to take a quick look at this code snippit and tell me if you can see anything that might cause it to loop, I'm pretty sure I'm missing something..

#include <Array.au3>
#include <ButtonConstants.au3>
#include <Date.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GUIEdit.au3>
#include <MsgBoxConstants.au3>
#include <DateTimeConstants.au3>


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


Local $iProvidedBy = RegRead("HKEY_CURRENT_USER\Software\RAIS", "Provided By")
Local $iProvidedThrough = RegRead("HKEY_CURRENT_USER\Software\RAIS", "Provided Through")
Local $iFund = RegRead("HKEY_CURRENT_USER\Software\RAIS", "Funded By")
Local $iLocation = RegRead("HKEY_CURRENT_USER\Software\RAIS", "Place where services were delivered")
Local $iPaymentType = RegRead("HKEY_CURRENT_USER\Software\RAIS", "Payment Type")
Local $title = WinGetTitle("Health Assistance - Windows Internet Explorer")
If $title <> "Health Assistance - Windows Internet Explorer" Then
    MsgBox(0, "Reminder", "This program only works on RAIS UNHCR's Health Assistance page.")
EndIf
$hParent = GUICreate('', 124, 0, 275, 24, 0, $WS_EX_TOOLWINDOW)
$IMC = GUICreate("IMC", 125, 485, @DesktopWidth - 155, @DesktopHeight - 650, $WS_POPUP, $WS_EX_TOPMOST, $hParent)
GUISetBkColor(0xDBECF9)
$Medication = GUICtrlCreateCheckbox("Medication", 8, 5, 107, 19)
$HealthEducation = GUICtrlCreateCheckbox("Health Education", 8, 24, 107, 19)
$LAB = GUICtrlCreateCheckbox("LAB Services", 8, 43, 107, 19)
$GP = GUICtrlCreateButton("GP", 24, 72, 75, 25)
$AddB4Service = GUICtrlCreateCheckbox("", 8, 95, 15, 15)
$Internist = GUICtrlCreateButton("Internist", 24, 104, 75, 25)
$Dental = GUICtrlCreateButton("Dental", 24, 136, 75, 25)
$OBG = GUICtrlCreateButton("OBG", 24, 168, 75, 25)
$Optha = GUICtrlCreateButton("Optha", 24, 200, 75, 25)
$Pediatric = GUICtrlCreateButton("Pediatric", 24, 232, 75, 25)
$AddAssistant = GUICtrlCreateButton("Add Assistant", 24, 264, 75, 25)
$Save = GUICtrlCreateCheckbox("", 8, 268, 15, 15)
$Date = GUICtrlCreateLabel("Date", 24, 299, 28, 19)
$Dates = GUICtrlCreateDate("mm/dd/yyyy", 24, 314, 85, 23, $DTS_SHORTDATEFORMAT)
$MC = GUICtrlCreateLabel("Medical Code:", 24, 344, 75, 19)
$Medical = GUICtrlCreateInput("", 24, 360, 20, 23, $ES_UPPERCASE)
GUICtrlSetLimit(-1, 1)
$Medical2 = GUICtrlCreateInput("", 50, 360, 45, 23, $ES_NUMBER)
$MP = GUICtrlCreateLabel("Money Paid:", 24, 394, 67, 19)
$Money = GUICtrlCreateInput("0", 24, 414, 85, 23)
$EXIT = GUICtrlCreateButton("EXIT", 24, 449, 75, 25)
$Medical_dummy = GUICtrlCreateDummy()
$Medical2_dummy = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)
GUICtrlSetState($Medical, $GUI_FOCUS)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop
        Case $GP
            If GUICtrlRead($AddB4Service) = 1 Then
                $oIE = _IEAttach("Case View")
                $sTitle = WinGetTitle("[CLASS:IEFrame]")
                Local $sString = StringTrimRight($sTitle, 28)
                $oIE = _IEAttach($sString)
                $url = _IEPropertyGet($oIE, "locationurl")
                Local $sString = StringTrimLeft($url, 53)
                Local $URL2 = "http://raisunhcr.org/user/Case_HealthAssistance.aspx?caseId="
                $HA = _IENavigate($oIE, $URL2 & $sString)
                Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm")
                Local $payday = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAdd")
                _IEAction($payday, "click")
                Local $hwin = WinGetState("Health Assistance", "Add")
                WinSetState($hwin, "", @SW_SHOW)
                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
            EndIf
            Local $iDate = GUICtrlRead($Dates)
            Local $iMedical1 = GUICtrlRead($Medical)
            Local $iMedical2 = GUICtrlRead($Medical2)
            Local $iMoney = GUICtrlRead($Money)
            $oIE = _IEAttach("Health Assistance")
            $oForm = _IEFormGetObjByName($oIE, "aspnetForm")
            $eProvidedBy = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListProvidedBy")
            $eProvidedThrough = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListProvidedThrough")
            $eFundedBy = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListFundedBy")
            $eInputDate = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$txtDateProvided")
            $eProcedures = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListProcedures")
            $eLocation = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListPlace")
            $eSpecialty = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListSpeciality")
            $ePayment = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListPaymentType")
            $oPayment = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$TextBoxAmount")
            _IEFormElementOptionSelect($eProvidedBy, $iProvidedBy, 1, "ByText")
            _IEFormElementOptionSelect($eProvidedThrough, $iProvidedThrough, 1, "ByText")
            _IEFormElementOptionSelect($eFundedBy, $iFund, 1, "ByText")
            _IEFormElementOptionSelect($eProcedures, 1, 1, "ByValue")
            _IEFormElementOptionSelect($eLocation, $iLocation, 1, "ByText")
            _IEFormElementSetValue($eInputDate, $iDate)
            _IEFormElementOptionSelect($eSpecialty, 43, 1, "ByValue")
            _IEFormElementSetValue($oPayment, $iMoney)
            _IEFormElementOptionSelect($ePayment, $iPaymentType, 1, "ByText")
            For $1 = 0 To UBound($MC) - 1
                $str &= $MC[$1][0] & '' & $MC[$1][1]
                $iDisease = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListDiseaseGroupCode")
                _IEFormElementOptionSelect($iDisease, $str, 1, "ByText")
                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
                ConsoleWrite($str & @LF)
                $str = ''
            Next
            $oAddProcedures = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddProcedure")
            _IEAction($oAddProcedures, "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
            $oAddSpeciality = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddSpeciality")
            _IEAction($oAddSpeciality, "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
            $oAddPayment = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddPayment")
            _IEAction($oAddPayment, "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
            If GUICtrlRead($HealthEducation) = 1 Then
                $eProcedures = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListProcedures")
                $eLocation = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListPlace")
                $eSpecialty = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListSpeciality")
                _IEFormElementOptionSelect($eProcedures, 30, 1, "ByValue")
                _IEFormElementOptionSelect($eLocation, $iLocation, 1, "ByText")
                _IEFormElementOptionSelect($eSpecialty, 44, 1, "ByValue")
                $oAddProcedures = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddProcedure")
                _IEAction($oAddProcedures, "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
                $oAddSpeciality = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddSpeciality")
                _IEAction($oAddSpeciality, "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
            EndIf
            If GUICtrlRead($Medication) = 1 Then
                $eProcedures = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListProcedures")
                $eLocation = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListPlace")
                $eSpecialty = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListSpeciality")
                _IEFormElementOptionSelect($eProcedures, 2, 1, "ByValue")
                _IEFormElementOptionSelect($eLocation, $iLocation, 1, "ByText")
                $oAddProcedures = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddProcedure")
                _IEAction($oAddProcedures, "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
            EndIf
            If GUICtrlRead($Save) = 1 Then
                $oSave = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnSave")
                _IEAction($oSave, "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
            EndIf
            If GUICtrlRead($LAB) = 1 Then
                $eProcedures = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListProcedures")
                $eLocation = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListPlace")
                $eSpecialty = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$DropDownListSpeciality")
                _IEFormElementOptionSelect($eProcedures, 12, 1, "ByValue")
                _IEFormElementOptionSelect($eLocation, $iLocation, 1, "ByText")
                $oAddProcedures = _IEGetObjByName($oForm, "ctl00$ContentPlaceHolder1$btnAddProcedure")
                _IEAction($oAddProcedures, "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
            EndIf
            GUICtrlSendMsg($GP, $BM_CLICK, 0, 0)
            $finalMC1 = ''
            $finalMC2 = ''
            Global $MC[1][2] = [[$finalMC1, $finalMC2]]
    EndSwitch
WEnd

 

Unfortunitly, access to the website this code runs on is restricted, so you guys can't actually test the code...

Share this post


Link to post
Share on other sites



There are many "While" loops and a "For" loop.

All of them will cause your script to loop.

 

all "While" loops are locked, I'm using many to check if the page is done adding the information, the "For" loop adds the items in array and moves on, items in array are obtained from the GUI.

The loop I'm talking about is when the script is supposed to be done, it restarts and readds everything all over again..

Share this post


Link to post
Share on other sites

Not sure if this is affecting it

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")

I see 2 "H" and no "U"

Might be looping an extra time when "H" is selected.


[u]Forum Rules[/u]

Follow the rules or be b*t**slapped into next week.

Share this post


Link to post
Share on other sites

Not sure if this is affecting it

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")

I see 2 "H" and no "U"

Might be looping an extra time when "H" is selected.

 

There is no U and 2 H's because the list this part of the script belongs to doesn't contain the letter "U" and its got "H00-H49" and "H50-H99", H is divided and got 2 different values on the webpage

Share this post


Link to post
Share on other sites

Do you need a "Case Else" near the end?


[u]Forum Rules[/u]

Follow the rules or be b*t**slapped into next week.

Share this post


Link to post
Share on other sites

You're resetting the array $MC when you create the label with the same variable name. There's no array any longer at this point so I'm surprised it runs at all.

Global $MC[0][2], $str ; <<<<<<<<<<<<<<<< array created called $MC

$MC = GUICtrlCreateLabel("Medical Code:", 24, 344, 75, 19) ; <<<<<<<<<<<<< array destroyed and is now a simple variable holding the ControlID of the label.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Do you need a "Case Else" near the end?

 

Nope, Case $GP is one out of six cases and it refers to a button.

 

You're resetting the array $MC when you create the label with the same variable name. There's no array any longer at this point so I'm surprised it runs at all.

Global $MC[0][2], $str ; <<<<<<<<<<<<<<<< array created called $MC

$MC = GUICtrlCreateLabel("Medical Code:", 24, 344, 75, 19) ; <<<<<<<<<<<<< array destroyed and is now a simple variable holding the ControlID of the label.

 

Indeed, I gathered the code from my script and wasn't paying much attention to it, just wanted to make sure that the Case $GP was there and working without throwing errors as a standalone case, the array gets declared again right before the GUI is shown in the full script, even with the array getting a reset when the script is executed the script still runs, ignores the part where the array takes place, adds everything else then restarts all over again.

Edited by Palestinian

Share this post


Link to post
Share on other sites

Just an FYI, if you're not going to ever reset the contents of a label, there's no need to worry about the control ID of it, so you don't need to assign a variable to them at all. That label appears to be used to describe what to put in the Input control right after it, so you don't really need to use a variable there.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

In most normal circumstances, you should not declare variables inside loops. Declare them outside the loop/s and only reassign the values they hold inside the loop/s. In the code you posted GUIDelete() can probably be removed: I imagine you plan to quit the program at that point.

What's this line for?

GUICtrlSendMsg($GP, $BM_CLICK, 0, 0)
Edited by czardas

Share this post


Link to post
Share on other sites

Just an FYI, if you're not going to ever reset the contents of a label, there's no need to worry about the control ID of it, so you don't need to assign a variable to them at all. That label appears to be used to describe what to put in the Input control right after it, so you don't really need to use a variable there.

 

Thank you, I didn't know that, been using AutoIt for a while but did not learn the very basics of it, using 'learn on the go' method sort of speak

 

In most normal circumstances, you should not declare variables inside loops. Declare them outside the loop/s and only reassign the values they hold inside the loop/s. In the code you posted GUIDelete() can probably be removed: I imagine you plan to quit the program at that point.

What's this line for?

GUICtrlSendMsg($GP, $BM_CLICK, 0, 0)

 

I'm using the GUIDelete() because the main script is using a tray menu, if the user wanted to exit the data entry GUI the script won't exit in all.

Share this post


Link to post
Share on other sites

Okay, but you didn't answer my question. Why are you sending the message to the control? - It could be the problem.

1 person likes this

Share this post


Link to post
Share on other sites

Okay, but you didn't answer my question. Why are you sending the message to the control? - It could be the problem.

 

I added that line about 2 weeks ago in an attempt to do exactly what its doing now, it didn't work back then so I used a while loop on the entire case, today I removed the while loop and forgot about that simple line, and it started working.

Thank you for pointing that one out. also thank you to everyone else who replied.

1 person likes this

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Cool. :) The script could still do with a little tidying up. BrewmanNH gave some good suggestions. Put those Local/Global keywords somewhere before/outside the loops - it's better - unless you are redeclaring an array with different dimensions.

Edited by czardas

Share this post


Link to post
Share on other sites

Cool. :) The script could still do with a little tidying up. BrewmanNH gave some good suggestions. Put those Local/Global keywords somewhere before/outside the loops - it's better - unless you are redeclaring an array with different dimensions.

 

The script could do with a lot of tidying up, its as messy as it gets, but its doing the job its suppose to do, didn't have much time to tide it up, and it took me a while to make it because i don't have that much free time.

Share this post


Link to post
Share on other sites

I know the feeling. It's always a good idea to take what you learn forward to future projects when you write another script though. :)

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