Jump to content
BatMan22

ComboBox Can't Remove Elements Properly

Recommended Posts

BatMan22

Hey guys.. I can't figure out how to properly remove elements from a gui combo box, help? Please see the funtion DelTestCode() below. 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Iconleak-Cerulean-Science-chemistry.ico
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include "UIAWrappers.au3"
#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Clipboard.au3>
#include <ComboConstants.au3>
#include <GuiComboBox.au3>
;~ #include <GuiComboBox.au3>


Global $analytical, $tcholder
Global $program = "appname"
Global $TubingID, $VolumeID, $TubingUnitsID, $VolumeUnitsID, $FinalUnitsID ; Called for Sample Loop Calculator

Start()

Func Start()
    Global $Form1 = GUICreate("Helper - Main Page", 274, 510, -1, -1)
    $AsciiArtTurtle = GUICtrlCreateLabel("                          Helper" & @CRLF & '           _ ' & @CRLF & '         <- )' & @CRLF & '         /( \' & @CRLF & '         \_\_>' & @CRLF & '         " "', 8, 8, 252, 73)
    $Button1 = GUICtrlCreateButton("Sample Loop Calculator", 16, 256, 241, 49)
    $DilutionHelper = GUICtrlCreateButton("Dilution Helper", 16, 144, 241, 49)
    $Button3 = GUICtrlCreateButton("Surface Area Conversions", 16, 200, 241, 49)
    $Button4 = GUICtrlCreateButton("Concentration Conversions", 16, 88, 241, 49)
    $Button2 = GUICtrlCreateButton("Load Sample Due Sheet", 16, 312, 241, 49)
    Global $Department = GUICtrlCreateCombo("Choose Your Department for Sample Due Sheet", 8, 368, 249, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "AQUATIC_TOXICITY|CALC|CHARGES|EXTRACT|GC_FID|GC_FIDPID|GC_MS_MISC|GC_MS_SVOC|GC_MS_TD|GC_MS_VOC|GC_PESTICIDE|GCMS_DIOXIN|Generic|HPLC|LC_MS|METAL_AA|METAL_MS|METAL_OES|Metals_Hg1631|MICRO|REEFER GAS|Solids_XRD_XRF_IR|SUB|SUMMA|Unassigned|WC_CNS|WC_MANUAL|WC_OG|WC_SKALAR|WC_SPECTRO|WC_TITRINO")
    $AddTC = GUICtrlCreateButton("Add PrepBatch", 16, 472, 89, 25)
    Global $MyTestCodes = GUICtrlCreateCombo("", 16, 448, 249, 25)
    $DelTC = GUICtrlCreateButton("Remove Selected PrepBatch", 112, 472, 153, 25)
    $GoToPrepBatch = GUICtrlCreateButton("Go to Prep Batch Listed Below", 16, 400, 241, 41)

    _FileReadToArray(@ScriptDir & "\mytestcodes.txt", $tcholder, @CRLF)
    For $i = 0 To UBound($tcholder) - 1
        GUICtrlSetData($MyTestCodes, $tcholder[$i])
    Next
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                GUIDelete($Form1)
                SampleLoopCalc()

            Case $Button2
                Global $rDepartment = "SUMMA"
                Isitrunning()
                GoToSampleDueSheet()
                TrayTip("Sample Sheet Loaded", "Samples Sheet Loaded!", 5)
                Sleep(100)
                WinWait(" Helper - Main Page")
                WinActivate(" Helper - Main Page")

            Case $DilutionHelper
                GUIDelete($Form1)
                DilutionHelper()

            Case $Button3
                GUIDelete($Form1)
                SurfaceAreaConv()

            Case $Button4
                GUIDelete($Form1)
                ConcentrationConv()

            Case $AddTC
                AddTestCode()

            Case $DelTC
;~              Local $whattodel = GUICtrlRead($MyTestCodes)
;~              ConsoleWrite("Whattodelis:" & $whattodel)
;~              Local $dump = _ArraySearch($MyTestCodes, $whattodel)
;~              ConsoleWrite("Found position in GUI is:" & $whattodel)
;~              _GUICtrlComboBox_DeleteString($MyTestCodes, 1)
                DelTestCode()
;~              GUISetState(@SW_DISABLE)
;~              GUISetState(@SW_ENABLE)
;~              GUISetState(@SW_



        EndSwitch
    WEnd
EndFunc   ;==>Start


;~ Sample Loop Calculation Functions Start HERE = = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = =
;~ Global Variables called for Sample Loop Calc Function: $TubingID, $VolumeID, $TubingUnitsID, $VolumeUnitsID, $FinalUnitsID
Func SampleLoopCalc()
    #Region ### START Koda GUI section ### Form=c:\users\ash\desktop\programmingsheeet\ helper\sampleloop.kxf
    $Form2 = GUICreate("Form1", 407, 190, -1, -1)
    $TubingID = GUICtrlCreateInput("ID of tubing", 8, 72, 153, 21, $ES_NUMBER)
    $Label1 = GUICtrlCreateLabel("Sample Loop Calculator", 72, 24, 207, 27)
    GUICtrlSetFont(-1, 16, 400, 0, "Times New Roman")
    $Label2 = GUICtrlCreateLabel("Inside Diameter of tubing", 224, 72, 121, 17)
    $VolumeID = GUICtrlCreateInput("Desired Volume", 8, 104, 153, 21, $ES_NUMBER)
    $Label4 = GUICtrlCreateLabel("Sample Loop Desired Volume", 224, 104, 143, 17)
;~ $TubingIDUnits = GUICtrlCreateList("", 168, 72, 49, 19)
    $TubingUnitsID = GUICtrlCreateCombo("mm", 168, 72, 49, 19, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "cm|inches")
    $VolumeUnitsID = GUICtrlCreateCombo("mL", 168, 104, 49, 19, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "uL|Liters")
    $Label3 = GUICtrlCreateLabel("Length of tubing required is:", 16, 136, 138, 17)
    $FinalUnitsID = GUICtrlCreateCombo("mm", 168, 136, 49, 19, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "cm|inches")
    $Answer = GUICtrlCreateLabel("", 224, 136, 160, 30)
    $GO = GUICtrlCreateButton("Calculate!", 16, 160, 121, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                Start()
            Case $GO
                Local $updans = CalculateSampleLoopRAWMath()
                GUICtrlSetData($Answer, Round($updans, 3) & " is the length in " & GUICtrlRead($FinalUnitsID))
        EndSwitch
    WEnd
EndFunc   ;==>SampleLoopCalc


Func CalculateSampleLoopRAWMath()

    Local $Tubing = GUICtrlRead($TubingID)
    If $Tubing = "ID of tubing" Then
        MsgBox(0, "Error", "Please Enter Tubing Inside Diameter")
    EndIf

    Local $Volume = GUICtrlRead($VolumeID)
    If $Volume = "Desired Volume" Then
        MsgBox(0, "Error", "Please Enter Sample Loop Volume")
    EndIf

;~ Unit Conversions
    Local $TubingUnits = GUICtrlRead($TubingUnitsID)
    If $TubingUnits = "cm" Then $Tubing = $Tubing * 10
    If $TubingUnits = "inches" Then $Tubing = $Tubing * 25.4

    Local $VolumeUnits = GUICtrlRead($VolumeUnitsID)
    If $VolumeUnits = "uL" Then $Volume = $Volume / 1000
    If $VolumeUnits = "Liters" Then $Volume = $Volume * 1000

    ; Volume = pie * R^2 * h
    ; $Volume = ((IDtubing in mm)/2)^2  * pie * length of tubing in mm
;~ $TubingID = .1 ; in mm

    Local $radius = $Tubing / 2 ; in mm
    ConsoleWrite("Radius of ID Tubing is: " & $radius & "mm" & @CRLF)
    ConsoleWrite("Volume Requested is: " & $Volume & "mL" & @CRLF)
    Local $radiussq = $radius * $radius
    ConsoleWrite("Radius Squared is: " & $radiussq & @CRLF)

    Local $radiussqtimespie = $radiussq * 3.14159
    ConsoleWrite("Radius Squared times pie is: " & $radiussqtimespie & "in mm^2" & @CRLF)
    Local $cubicmillimeters = $Volume * 1000 ;1000cubic millimeters = 1mL
    ConsoleWrite("Cubic millimeters is: " & $cubicmillimeters & @CRLF)
    Local $lengthinmm = $cubicmillimeters / $radiussqtimespie
    ConsoleWrite("Length required for 1000mL loop is: " & $lengthinmm & "'s mm of tubing" & @CRLF)
    Local $lengthininches = $lengthinmm / 25.4
    ConsoleWrite("Length required for 1000mL loop is: " & $lengthininches & "'s inches of tubing" & @CRLF)

    Local $FinalUnits = GUICtrlRead($FinalUnitsID)
    If $FinalUnits = "cm" Then $lengthinmm = $lengthinmm / 10
    If $FinalUnits = "inches" Then $lengthinmm = $lengthinmm / 25.4
;~  GUICtrlSetData($Answer, Round($lengthinmm, 4) & " is the length in " & $FinalUnits)
    Return ($lengthinmm)
EndFunc   ;==>CalculateSampleLoopRAWMath



;~ Sample Loop Calculation Functions END HERE = = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = =

;~ Dilution Helper Calculation Functions Start HERE = = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = =

Func DilutionHelper()
    #Region ### START Koda GUI section ### Form=
    $Form4 = GUICreate("Dilution Helper", 623, 190, -1, -1)
    $Label1 = GUICtrlCreateLabel("Dilution Helper", 176, 24, 207, 27)
    GUICtrlSetFont(-1, 16, 400, 0, "Times New Roman")
    Global $DF = GUICtrlCreateInput("Dilution Needed", 64, 72, 89, 21, $ES_NUMBER)
    Global $DDesiredVol = GUICtrlCreateInput("Desired Final Volume", 168, 72, 153, 21, $ES_NUMBER)
    Global $DFinalAnswer = GUICtrlCreateLabel("Please enter dilution needed and the Final Volume you would like to make", 8, 144, 390, 41)
    Global $DDesiredVolumeUnits = GUICtrlCreateCombo("mL", 328, 72, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "uL|Liters|")
    Global $DCalculate = GUICtrlCreateButton("DCalculate", 160, 104, 193, 25)
    Global $DReset = GUICtrlCreateButton("DReset", 360, 104, 121, 25)
    Global $DFinalUnits = GUICtrlCreateCombo("mL", 416, 152, 81, 25)
    GUICtrlSetData(-1, "uL|Liters")
    $Label2 = GUICtrlCreateLabel("x", 56, 72, 9, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form4)
;~              Exit
                Start()

            Case $DCalculate

                Local $updans = DFHelpRAWMath()
                GUICtrlSetData($DFinalAnswer, "Take: " & Round($updans, 6) & GUICtrlRead($DFinalUnits) & " of standard and dilute to " & GUICtrlRead($DDesiredVol) & GUICtrlRead($DDesiredVolumeUnits) & "'s")
            Case $DReset
                GUICtrlSetData($DF, "Dilution Needed")
                GUICtrlSetData($DDesiredVol, "Desired Final Volume")
                GUICtrlSetData($DDesiredVolumeUnits, "mL")
                GUICtrlSetData($DFinalUnits, "mL")
                GUICtrlSetData($DFinalAnswer, "Please enter dilution needed and the Final Volume you would like to make")

        EndSwitch
    WEnd
EndFunc   ;==>DilutionHelper


Func DFHelpRAWMath() ;C1 * V1 = C2* V2 -->  V1 = (C2 * V2) / C1

    Local $rDF = GUICtrlRead($DF)
    If $rDF = "Dilution Needed" Then
        MsgBox(0, "Error", "Error: Calculation will not be correct, choose Dilution Factor Required")
    EndIf

    Local $rDDesiredVol = GUICtrlRead($DDesiredVol)
    If $rDDesiredVol = "Desired Volume" Then
        MsgBox(0, "Error", "Error: Calculation will not be correct, choose the desired Final Volume after dilution!")
    EndIf


;~  Local $rDF = GUICtrlRead($DF)
;~  Local $rDDesiredVol = GUICtrlRead($DDesiredVol)
    Local $rDDesiredVolumeUnits = GUICtrlRead($DDesiredVolumeUnits)
    Local $rDFinalUnits = GUICtrlRead($DFinalUnits)


;~  DV = 10, and DF = x10
    $Answer = $rDDesiredVol / $rDF

    If $rDDesiredVolumeUnits = "mL" And $rDFinalUnits = "mL" Then $Answer = $Answer
    If $rDDesiredVolumeUnits = "uL" And $rDFinalUnits = "uL" Then $Answer = $Answer
    If $rDDesiredVolumeUnits = "Liters" And $rDFinalUnits = "Liters" Then $Answer = $Answer
    If $rDDesiredVolumeUnits = "mL" And $rDFinalUnits = "uL" Then $Answer = $Answer * 1000
    If $rDDesiredVolumeUnits = "mL" And $rDFinalUnits = "Liters" Then $Answer = $Answer / 1000
    If $rDDesiredVolumeUnits = "uL" And $rDFinalUnits = "mL" Then $Answer = $Answer / 1000
    If $rDDesiredVolumeUnits = "uL" And $rDFinalUnits = "Liters" Then $Answer = $Answer / 1000000
    If $rDDesiredVolumeUnits = "Liters" And $rDFinalUnits = "uL" Then $Answer = $Answer * 1000000
    If $rDDesiredVolumeUnits = "Liters" And $rDFinalUnits = "mL" Then $Answer = $Answer * 1000

    Return ($Answer)
EndFunc   ;==>DFHelpRAWMath

;~ Dilution Helper Calculation Functions END HERE = = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = =
;~ Concentration Conversions Calculation Functions START HERE = = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = =

Func ConcentrationConv()
    #Region ### START Koda GUI section ### Form=C:\Users\Ash\Desktop\ProgrammingSheeet\ Helper\ConcentrationConverter.kxf
    $Form3 = GUICreate("Concentration Converter for Standards", 622, 189, -1, -1)
    $Label1 = GUICtrlCreateLabel("Concentration Converter", 176, 24, 207, 27)
    GUICtrlSetFont(-1, 16, 400, 0, "Times New Roman")
    Global $StartingConc = GUICtrlCreateInput("Concentration of Standard", 8, 72, 137, 21, $ES_NUMBER)
    Global $StartingConcUnit = GUICtrlCreateCombo("", 152, 72, 49, 25)
    GUICtrlSetData(-1, "ppm|ppb|mg/L|ug/L", "ppm")
    Global $DesiredConc = GUICtrlCreateInput("Desired Concentration", 224, 72, 121, 21, $ES_NUMBER)
    Global $DesiredVol = GUICtrlCreateInput("Desired Volume", 408, 72, 153, 21, $ES_NUMBER)
    Global $FinalAnswer = GUICtrlCreateLabel("Amount of Standard to take is:", 8, 144, 390, 41)
    Global $DesiredConUnits = GUICtrlCreateCombo("", 352, 72, 49, 25)
    GUICtrlSetData(-1, "ppm|ppb|mg/L|ug/L", "ppm")
    Global $DesiredVolumeUnits = GUICtrlCreateCombo("", 568, 72, 41, 25)
    GUICtrlSetData(-1, "mL|uL|Liters|", "mL")
    $Calculate = GUICtrlCreateButton("Calculate", 160, 104, 193, 25)
    $Reset = GUICtrlCreateButton("Reset", 360, 104, 121, 25)
    Global $FinalUnits = GUICtrlCreateCombo("Final Units", 416, 152, 81, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "mL|uL|Liters", "mL")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form3)
                Start()

            Case $Calculate
                Local $updans = ConcentrationConvRAWMath()
                GUICtrlSetData($FinalAnswer, "Take: " & Round($updans, 6) & GUICtrlRead($FinalUnits) & " of standard and dilute to " & GUICtrlRead($DesiredVol) & GUICtrlRead($DesiredVolumeUnits) & "'s")
            Case $Reset
                GUICtrlSetData($StartingConc, "Concentration of Standard")
                GUICtrlSetData($DesiredConc, "Desired Concentration")
                GUICtrlSetData($DesiredVol, "Desired Volume")

        EndSwitch
    WEnd
EndFunc   ;==>ConcentrationConv


Func ConcentrationConvRAWMath() ;C1 * V1 = C2* V2 -->  V1 = (C2 * V2) / C1
    Local $rStartingConcUnit = GUICtrlRead($StartingConcUnit)
    Local $rDesiredConUnits = GUICtrlRead($DesiredConUnits)
    Local $rDesiredVolumeUnits = GUICtrlRead($DesiredVolumeUnits)
    Local $rStartingConc = GUICtrlRead($StartingConc)
    Local $rDesiredVol = GUICtrlRead($DesiredVol)
    Local $rDesiredConc = GUICtrlRead($DesiredConc)
    Local $rFinalUnits = GUICtrlRead($FinalUnits)
    If $rStartingConcUnit = "ppm" Or $rStartingConcUnit = "mg/L" Then $rStartingConc = $rStartingConc
    If $rStartingConcUnit = "ppb" Or $rStartingConcUnit = "ug/L" Then $rStartingConc = $rStartingConc / 1000
    If $rDesiredConUnits = "ppm" Or $rDesiredConUnits = "mg/L" Then $rDesiredConc = $rDesiredConc
    If $rDesiredConUnits = "ppb" Or $rDesiredConUnits = "ug/L" Then $rDesiredConc = $rDesiredConc / 1000
    If $rDesiredVolumeUnits = "mL" Then $rDesiredVol = $rDesiredVol
    If $rDesiredVolumeUnits = "uL" Then $rDesiredVol = $rDesiredVol / 1000
    If $rDesiredVolumeUnits = "Liters" Then $rDesiredVol = $rDesiredVol * 1000
;~  If $rStartingConcUnit = "ppm" then $rStartingConcUnit = $rStartingConcUnit


    $Answer = $rDesiredVol * $rDesiredConc
    ConsoleWrite($Answer & @CRLF)
    $Answer = $Answer / $rStartingConc
    ConsoleWrite($Answer & @CRLF)
    If $rFinalUnits = "mL" Then $Answer = $Answer
    If $rFinalUnits = "uL" Then $Answer = $Answer * 1000
    If $rFinalUnits = "Liters" Then $Answer = $Answer / 1000

    Return ($Answer)
EndFunc   ;==>ConcentrationConvRAWMath

;~ Concentration Conversions Calculation Functions END HERE = = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = == = = = = = = = = = = = = =





Func SurfaceAreaConv()

    #Region ### START Koda GUI section ### Form=
    $Form6 = GUICreate("Form1", 615, 438, -1, -1)
    $AsciiHeader = GUICtrlCreateLabel("                                        Surface Area and Volume Converter" & @CRLF & "        ___________________________________________________________________" & @CRLF & "        |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  '  |  " & @CRLF & "        |____1____2____3____4____5____6____7____8____9_____10____11__12____|", 16, 16, 589, 64)
    Global $SAStart = GUICtrlCreateInput("Surface Area", 8, 96, 129, 21, $ES_NUMBER)
    Global $SAStartUnits = GUICtrlCreateCombo("cm²", 144, 96, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "inches²|mm²|foot²|meters²")
    $bSA = GUICtrlCreateButton("Convert Surface Area", 208, 92, 193, 25)
    Global $SADesUnits = GUICtrlCreateCombo("cm²", 408, 96, 73, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "inches²|mm²|foot²|meters²")
    $Label1 = GUICtrlCreateLabel("Click Calculate Button to Calculate Surface Area", 488, 100, 124, 25)
    Global $VolStart = GUICtrlCreateInput("Volume", 8, 128, 129, 21, $ES_NUMBER)
    Global $VolStartUnits = GUICtrlCreateCombo("cm³", 144, 128, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "meters³|ft³|in³|mm³|yd³|liter|mL|uL|fluid oz|fluid gallon")
    $bVol = GUICtrlCreateButton("Convert Volume", 208, 124, 193, 25)
    Global $VolDesUnits = GUICtrlCreateCombo("cm³", 408, 128, 73, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "meters³|ft³|in³|mm³|yd³|liter|mL|uL|fluid oz|fluid gallon")
    $Label2 = GUICtrlCreateLabel("Click Calculate Button to Calculate Volume", 488, 132, 124, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###





    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form6)
                Start()
            Case $bSA
                Local $ccsa = SA()
                GUICtrlSetData($Label1, "converted:" & Round($ccsa, 5) & " " & GUICtrlRead($SADesUnits, 1))

            Case $bVol
                Local $ccvol = Vol()
                GUICtrlSetData($Label2, "converted:" & Round($ccvol, 5) & " " & GUICtrlRead($VolDesUnits, 1))

        EndSwitch
    WEnd



EndFunc   ;==>SurfaceAreaConv


Func SA()
    Local $rSAStart = GUICtrlRead($SAStart)
    Local $rSAStartUnits = GUICtrlRead($SAStartUnits)
    Local $rSADesUnits = GUICtrlRead($SADesUnits)
    If $rSADesUnits = "inches²" Then $rSAStart = $rSAStart * 0.1550003100006
    If $rSADesUnits = "foot²" Then $rSAStart = $rSAStart * 0.001076391041671
    If $rSADesUnits = "meters²" Then $rSAStart = $rSAStart * 0.0001
    If $rSADesUnits = "mm²" Then $rSAStart = $rSAStart * 100
    If $rSAStartUnits = "inches²" Then $rSAStart = $rSAStart / 0.1550003100006
    If $rSAStartUnits = "foot²" Then $rSAStart = $rSAStart / 0.001076391041671
    If $rSAStartUnits = "meters²" Then $rSAStart = $rSAStart / 0.0001
    If $rSAStartUnits = "mm²" Then $rSAStart = $rSAStart / 100
    Return ($rSAStart)
EndFunc   ;==>SA


Func Vol()
    Local $rVolStart = GUICtrlRead($VolStart)
    Local $rVolStartUnits = GUICtrlRead($VolStartUnits)
    Local $rVolDesUnits = GUICtrlRead($VolDesUnits)
;~  If $rVolDesUnits = "cm³" then $rVolStart = $rVolStart
    If $rVolDesUnits = "meters³" Then $rVolStart = $rVolStart * 0.000001
    If $rVolDesUnits = "ft³" Then $rVolStart = $rVolStart * 0.00003531466672149
    If $rVolDesUnits = "in³" Then $rVolStart = $rVolStart * 0.06102374409473
    If $rVolDesUnits = "mm³" Then $rVolStart = $rVolStart * 1000
    If $rVolDesUnits = "yd³" Then $rVolStart = $rVolStart * 0.000001307950619314
    If $rVolDesUnits = "Liter" Then $rVolStart = $rVolStart * 0.001
    If $rVolDesUnits = "mL" Then $rVolStart = $rVolStart * 1
    If $rVolDesUnits = "uL" Then $rVolStart = $rVolStart * 1000
    If $rVolDesUnits = "fluid oz" Then $rVolStart = $rVolStart * 0.03381402270184
    If $rVolDesUnits = "fluid gallon" Then $rVolStart = $rVolStart * 0.0002641720523582

;~  If $rVolStartUnits = "cm³" then $rVolStart = $rVolStart
    If $rVolStartUnits = "meters³" Then $rVolStart = $rVolStart / 0.000001
    If $rVolStartUnits = "ft³" Then $rVolStart = $rVolStart / 0.00003531466672149
    If $rVolStartUnits = "in³" Then $rVolStart = $rVolStart / 0.06102374409473
    If $rVolStartUnits = "mm³" Then $rVolStart = $rVolStart / 1000
    If $rVolStartUnits = "yd³" Then $rVolStart = $rVolStart / 0.000001307950619314
    If $rVolStartUnits = "Liter" Then $rVolStart = $rVolStart / 0.001
    If $rVolStartUnits = "mL" Then $rVolStart = $rVolStart / 1
    If $rVolStartUnits = "uL" Then $rVolStart = $rVolStart / 1000
    If $rVolStartUnits = "fluid oz" Then $rVolStart = $rVolStart / 0.03381402270184
    If $rVolStartUnits = "fluid gallon" Then $rVolStart = $rVolStart / 0.0002641720523582
    Return ($rVolStart)
EndFunc   ;==>Vol

Func Isitrunning()
    Local $c1 = WinExists(" Omega_Me")
    If $c1 = 0 Then
        MsgBox(0, "LIMS is not running!", "Please launch LIMS before Clicking Sample Due Sheet! Closing Now!")
        ConsoleWrite("Omega is NOT running")
        Exit
    EndIf
    WinActivate(" Omega_Me")
    WinSetState(" Omega_Me", "", @SW_MAXIMIZE)

EndFunc   ;==>Isitrunning

Func GoToSampleDueSheet()
    Analytical()
    Local $rDepartment = GUICtrlRead($Department)
    If $rDepartment = "Choose Your Department for Sample Due Sheet" Then
        MsgBox(0, "Error", "You didn't choose your department, I'll assume you want to work in the IC Department, because who doesn't right?")
        $rDepartment = "IC"
    EndIf
    WinWait(" Omega_Me - [frmMC_SampleDue]")
    WinActivate(" Omega_Me - [frmMC_SampleDue]")
    MouseClick("Main", 143, 156, 1, 0) ; Click Dropdown
    Sleep(100)
    Send($rDepartment)
    Sleep(100)
    Send("{Enter}")
EndFunc   ;==>GoToSampleDueSheet

Func Analytical()
    Send("^m")
    Local $omega = _UIA_getFirstObjectOfElement($UIA_oDesktop, $program, $treescope_children)
    $analytical = _UIA_getFirstObjectOfElement($omega, "name:=Analytical", $treescope_subtree) ; Works but chooses wrong item apparently?
    Local $oLegacyP = _UIA_getPattern($analytical, $UIA_LegacyIAccessiblePatternId)
    $oLegacyP.dodefaultaction()
    AutoItSetOption("MouseCoordMode", 0)
    AutoItSetOption("PixelCoordMode", 0)
    Local $vHandle = WinGetHandle(" Omega_Me - [ODBC;DRIVER=SQL Server Native Client 10.0;SERVER=tcp:MAI-SQL\MAI_BACKEND;UID=huan;PWD=;Trusted_Connection=Yes;APP=Microsoft Offi]")
    Local $vPixSum = PixelChecksum(201, 359, 269, 367, 0, $vHandle)
    If $vPixSum = 2050117383 Or $vPixSum = 499904782 Then
        MouseClick("Main", 213, 362, 1, 0) ; Click Sample Due
    Else
        Do
            Sleep(10)
            Local $vPixSum = PixelChecksum(201, 359, 269, 367, 0, $vHandle)
        Until $vPixSum = 2050117383 Or $vPixSum = 499904782
        MouseClick("Main", 213, 362, 1, 0) ; Click Sample Due
        TrayTip("Loading Sample Due Sheet", "", 5)
    EndIf
EndFunc   ;==>Analytical


Func AddTestCode()
    $Value = InputBox("TC Wanting to add", "What test code do you want to add to  Helper")
    ConsoleWrite($Value)
    _FileReadToArray(@ScriptDir & "\mytestcodes.txt", $tcholder, @CRLF)
;~  _ArrayDisplay($tcholder, "Before ADDING")
    FileWrite(@ScriptDir & "\mytestcodes.txt", $Value & @CRLF)
    _FileReadToArray(@ScriptDir & "\mytestcodes.txt", $tcholder, @CRLF)
;~  _ArrayDisplay($tcholder, "After ADDING")
    For $i = 0 To UBound($tcholder) - 1
        GUICtrlSetData($MyTestCodes, $tcholder[$i])
    Next
EndFunc   ;==>AddTestCode


Func DelTestCode()
    Global $Tcs
    Local $whattodel = GUICtrlRead($MyTestCodes)
    Local $dump = _ArraySearch($MyTestCodes, $whattodel)
    _GUICtrlComboBox_DeleteString($MyTestCodes, $dump)
    ConsoleWrite(@CRLF & $whattodel & @CRLF)
    $fo=FileOpen(@ScriptDir & "\mytestcodes.txt")
    _FileReadToArray(@ScriptDir & "\mytestcodes.txt", $Tcs)
    $dump = _ArraySearch($Tcs, $whattodel)
    ConsoleWrite($dump)
    _ArrayDisplay($Tcs, "before")
    _ArrayDelete($Tcs, $dump)
    _ArrayDisplay($Tcs, "after")
    _GUICtrlComboBox_DeleteString($MyTestCodes, 1)
    _FileWriteFromArray (@ScriptDir & "\mytestcodes.txt", $Tcs, 1)
    FileClose($fo)
;~  Sleep(500)

;~  For $i = 0 To UBound($Tcs) - 1
;~      GUICtrlSetData($MyTestCodes, $Tcs[$i])
;~  Next

EndFunc   ;==>DelTestCode

 

Share this post


Link to post
Share on other sites
Subz

$dump should be using _GUICtrlComboBox_FindString, not sure why you're using _ArraySearch on $MyTestCodes which isn't an array.

  • Like 1

Share this post


Link to post
Share on other sites
BatMan22
16 hours ago, Subz said:

$dump should be using _GUICtrlComboBox_FindString, not sure why you're using _ArraySearch on $MyTestCodes which isn't an array.

Thanks dude.. I see my mistake ;)

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

×