Jump to content

Multiple Dataset entry?


 Share

Recommended Posts

Hi all, newbie here. Been loving AutoIt so far, but I'm wracking my brain right now on how to do the final part of my script:

Basically, I need to enter data into an input box with multiple fields, and then be able to enter a different set of data, and again, etc, until I give it the command to run, where it will then use each set of data for a function, looping until it's gone through all sets.

Any ideas?

 

Link to comment
Share on other sites

11 hours ago, Subz said:

Please post your code, also would be great to know if this is a third party app (if so the name of the app) or is this an app you have created with Autoit?

Hi, here's what I have so far:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

Global $Case, $Name, $Transit, $Amount, $Currency, $PVD, $Serial, $ICN, $Contra, $NameExt, $Authorization, $Ordering, $Identifier, $Queue

$MAIN = GUICreate("Loans", 220, 600)
GUICtrlCreateLabel("ICN:", 10, 15, 65, 25)
$ICN = GUICtrlCreateInput("", 80, 10, 120, 25)
GUICtrlCreateLabel("Transit:", 10, 55, 65, 25)
$Transit = GUICtrlCreateInput("", 80, 50, 120, 25)
GUICtrlCreateLabel("Queue:", 10, 95, 65, 25)
$Queue = GUICtrlCreateInput("", 80, 90, 120, 25)
GUICtrlCreateLabel("Case #:", 10, 135, 65, 25)
$Case = GUICtrlCreateInput("", 80, 130, 120, 25)
GUICtrlCreateLabel("Serial:", 10, 175, 65, 25)
$Serial = GUICtrlCreateInput("", 80, 170, 120, 25)
GUICtrlCreateLabel("Value Date:", 10, 215, 65, 25)
$ValueDate = GUICtrlCreateInput("", 80, 210, 120, 25)
GUICtrlCreateLabel("Amount:", 10, 255, 65, 25)
$Amount = GUICtrlCreateInput("", 80, 250, 120, 25)
GUICtrlCreateLabel("Currency:", 10, 295, 65, 25)
$Currency = GUICtrlCreateInput("", 80, 290, 120, 25)
GUICtrlCreateLabel("Ordering:", 10, 335, 65, 25)
$Ordering = GUICtrlCreateInput("", 80, 330, 120, 25)
GUICtrlCreateLabel("Contra:", 10, 375, 65, 25)
$Contra = GUICtrlCreateInput("", 80, 370, 120, 25)
GUICtrlCreateLabel("Beneficiary:", 10, 415, 65, 25)
$Beneficiary = GUICtrlCreateInput("", 80, 410, 120, 25)
GUICtrlCreateLabel("Identifier:", 10, 455, 65, 25)
$Identifier = GUICtrlCreateInput("", 80, 450, 120, 25)
GUICtrlCreateLabel("Authorization:", 10, 495, 65, 25)
$Authorization = GUICtrlCreateInput("", 80, 490, 120, 25)
$NEXT = GUICtrlCreateButton("NEXT", 40, 525, 60, 25)
$CANCEL = GUICtrlCreateButton("RUN", 120, 525, 60, 25)

GUISetState()
While 1
      $MSG = GUIGetMsg()
    Select
      Case $MSG = $NEXT
         MsgBox(0,"Error", $Amount)
      Case $MSG = $GUI_EVENT_CLOSE
         Exit
    EndSelect
WEnd

 

Basically, it creates a GUI with multiple fields to enter data. A function (that I haven't included for the sake of brevity) will use the assigned variables. 

My issue is that I want to be able to enter a set of data, press the NEXT button, and it'll store that dataset while clearing the fields, allowing me to enter a new dataset and repeat. Then, when I hit RUN, I want it to run the function again and again for each set of data. Which would basically mean assigning the variables, running the function, assigning the variables to the next set of data, and running the function again. 

The MsgBox at the bottom was just me checking the value of the variables. 

Link to comment
Share on other sites

You can basically store the information into an Array then once you have finished loop through the array to run each line of the array for example, please note I would have used an array in the _NextDataSet function but thought it would give you a better understanding, feel free to modify as you like.  I also added in an optional _RequiredCheck function so you can check the field meets a certain criteria, again you can add to this for example check for digits or whatever, hope that helps.

#include <Array.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

Global $idICN, $idTransit, $idQueue, $idCase, $idSerial, $idValueDate, $idAmount, $idCurrency, $idOrdering, $idContra, $idBeneficiary, $idIdentifier, $idAuthorization, $Name, $PVD, $NameExt
Global $aInfo[1][13]

$MAIN = GUICreate("Loans", 220, 600)
GUICtrlCreateLabel("ICN:", 10, 15, 65, 25)
$idICN = GUICtrlCreateInput("", 80, 10, 120, 25)
GUICtrlCreateLabel("Transit:", 10, 55, 65, 25)
$idTransit = GUICtrlCreateInput("", 80, 50, 120, 25)
GUICtrlCreateLabel("Queue:", 10, 95, 65, 25)
$idQueue = GUICtrlCreateInput("", 80, 90, 120, 25)
GUICtrlCreateLabel("Case #:", 10, 135, 65, 25)
$idCase = GUICtrlCreateInput("", 80, 130, 120, 25)
GUICtrlCreateLabel("Serial:", 10, 175, 65, 25)
$idSerial = GUICtrlCreateInput("", 80, 170, 120, 25)
GUICtrlCreateLabel("Value Date:", 10, 215, 65, 25)
$idValueDate = GUICtrlCreateInput("", 80, 210, 120, 25)
GUICtrlCreateLabel("Amount:", 10, 255, 65, 25)
$idAmount = GUICtrlCreateInput("", 80, 250, 120, 25)
GUICtrlCreateLabel("Currency:", 10, 295, 65, 25)
$idCurrency = GUICtrlCreateInput("", 80, 290, 120, 25)
GUICtrlCreateLabel("Ordering:", 10, 335, 65, 25)
$idOrdering = GUICtrlCreateInput("", 80, 330, 120, 25)
GUICtrlCreateLabel("Contra:", 10, 375, 65, 25)
$idContra = GUICtrlCreateInput("", 80, 370, 120, 25)
GUICtrlCreateLabel("idBeneficiary:", 10, 415, 65, 25)
$idBeneficiary = GUICtrlCreateInput("", 80, 410, 120, 25)
GUICtrlCreateLabel("Identifier:", 10, 455, 65, 25)
$idIdentifier = GUICtrlCreateInput("", 80, 450, 120, 25)
GUICtrlCreateLabel("Authorization:", 10, 495, 65, 25)
$idAuthorization = GUICtrlCreateInput("", 80, 490, 120, 25)
$NEXT = GUICtrlCreateButton("NEXT", 40, 525, 60, 25)
$CANCEL = GUICtrlCreateButton("RUN", 120, 525, 60, 25)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $NEXT
            _NextDataSet()
            If @error Then ContinueLoop
            _ArrayDisplay($aInfo)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _NextDataSet()
    Local $sICN = _RequiredFields(GuiCtrlRead($idICN), "ICN")
    If @error Then Return SetError(1, 0, $sICN)
    Local $sTransit = GuiCtrlRead($idTransit)
    Local $sQueue = GuiCtrlRead($idQueue)
    Local $sCase = GuiCtrlRead($idCase)
    Local $sSerial = GuiCtrlRead($idSerial)
    Local $sValueDate = GuiCtrlRead($idValueDate)
    Local $sAmount = GuiCtrlRead($idAmount)
    Local $sCurrency = GuiCtrlRead($idCurrency)
    Local $sOrdering = GuiCtrlRead($idOrdering)
    Local $sContra = GuiCtrlRead($idContra)
    Local $sBeneficiary = GuiCtrlRead($idBeneficiary)
    Local $sIdentifier = GuiCtrlRead($idIdentifier)
    Local $sAuthorization = GuiCtrlRead($idAuthorization)
    _ArrayAdd($aInfo, $sICN & _
    "|" & $sTransit & _
    "|" & $sQueue & _
    "|" & $sCase & _
    "|" & $sSerial & _
    "|" & $sValueDate & _
    "|" & $sAmount & _
    "|" & $sCurrency & _
    "|" & $sOrdering & _
    "|" & $sContra & _
    "|" & $sBeneficiary & _
    "|" & $sIdentifier & _
    "|" & $sAuthorization)
    $aInfo[0][0] = UBound($aInfo) - 1
    GUICtrlSetData($idICN, "")
    GUICtrlSetData($idTransit, "")
    GUICtrlSetData($idQueue, "")
    GUICtrlSetData($idCase, "")
    GUICtrlSetData($idSerial, "")
    GUICtrlSetData($idValueDate, "")
    GUICtrlSetData($idAmount, "")
    GUICtrlSetData($idCurrency, "")
    GUICtrlSetData($idOrdering, "")
    GUICtrlSetData($idContra, "")
    GUICtrlSetData($idBeneficiary, "")
    GUICtrlSetData($idIdentifier, "")
    GUICtrlSetData($idAuthorization, "")
EndFunc

Func _RequiredFields($_sDataInfo, $_sFieldName = "")
    If StringStripWS($_sDataInfo, 8) = "" Then
        MsgBox(16, "Loans Error", "Field Error: " & $_sFieldName & " cannot be empty")
        Return SetError(1, 0, "Field Error: " & $_sFieldName & " cannot be empty")
    EndIf
    Return $_sDataInfo
EndFunc

 

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