Jump to content

Edit Box to Array


Bionicjoe
 Share

Recommended Posts

I've created a GUI with an edit box for entering a series of email addresses.

After clicking OK I want the text in the edit box put into an array so I can loop through each entry to run a command.

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Email Ticket Processor", 256, 250)

$Restore = GUICtrlCreateRadio("Restore", 8, 32, 90, 10)

$Move = GUICtrlCreateRadio("Move", 8, 56, 90, 10)

$Merge = GUICtrlCreateRadio("Merge", 8, 80, 90, 10)

$Edit1 = GUICtrlCreateEdit("", 8, 112, 241, 89)

GUICtrlSetData(-1, "Enter Addresses Here")

$Input1 = GUICtrlCreateInput("New Acct #", 100, 56, 140, 20)

$OKButton = GUICtrlCreateButton("OK", 16, 216, 75, 25, $WS_GROUP)

$CancelButton = GUICtrlCreateButton("Cancel", 160, 216, 75, 25, $WS_GROUP)

;$Label1 = GUICtrlCreateLabel("Email Ticket Processor", 1, 8, 248, 17, $SS_CENTER)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nmsg = GUIGetMsg()

Switch $nmsg

Case $GUI_EVENT_CLOSE

Exit

Case $CancelButton

Exit

Case $Restore

$Radio = 0

Case $Move

$Radio = 1

Case $Merge

$Radio = 2

Case $OKButton

Dim $Radio ;This is needed in case no radio buttons are checked.

If $Radio == 0 Then

RestoreAcct()

ElseIf $Radio == 1 Then

MoveAcct()

ElseIf $Radio == 2 Then

MergeAcct()

Else

EndIf

EndSwitch

WEnd

Func RestoreAcct ()

WinActivate ("Untitled - Notepad") ;Just dumping text into Notepad for now.

$InputText = GUICtrlRead ($Edit1)

;Create an array & run the command below for each entry.

Send ( "sudo restore_userid " & $InputText & "{ENTER}" )

EndFunc

Func MoveAcct ()

;To be completed later

EndFunc

Func MergeAcct ()

;To be completed later

EndFunc

Link to comment
Share on other sites

Welcome to the forums.

If you were using a multi-line edit.

GUICtlRead

StringSplit By @LF, @CR, @LF, ',' whatever your deliminator is.

Now your using an input control.

Try this:

GUICtrlRead

Ubound the array

Redim Ubound + 1

Add the email.

And additional step would be to run a regexp on the email or to validate it.

Cheers,

Brett

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