Sign in to follow this  
Followers 0
Neoborn

Removing Empty Elements From Array?

3 posts in this topic

#1 ·  Posted (edited)

Hello Guys,

I have built a little tool that:

1. Opens a gui

2. I paste in a list of numbers such as the list below from an Excel file. There is always, when copying, a blank line at the end. I need to remove this element from the array but cannot find out how to do this.

446337 
  446338 
  446342 
  446637 
  446642 
  446699 
  446776

3. Upon pressing go it loops through each element in the array and opens a window in Fieldpro.

Here is the code, please can someone look into this / test it to see how I can remove the empty element? How do I see what the empty element consists of to remove it, I tried "", " " and @CRLF but doesn't seem to work.

#include <GuiConstants.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)

GUICreate("Open MSO's", 170, 283, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input1 = GUICtrlCreateEdit("", 10, 10, 90, 220)
$Button2 = GUICtrlCreateButton("Go!", 10, 240, 60, 30)
$Button3 = GUICtrlCreateButton("Exit", 80, 240, 60, 30)
$Label2 = GUICtrlCreateLabel("Total", 110, 7, 40, 20)
$Radio1 = GUICtrlCreateRadio ( "Case", 110, 50)

Global $Label1 = GUICtrlCreateinput("", 110, 20, 40, 20)
GUICtrlSetState ($Label1, $GUI_DISABLE)
Local $1stClick = 1

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $Button2
            $Result1 = GUICtrlRead($Input1, 1)
            StringStripWS($Result1, 4)
            
            ;this line:
            $Result2 = StringSplit($Result1, @CR)
            GuiCtrlSetData($Label1, UBound($Result2, 1)-1)
            
                If WinExists("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote")= 0 Then
                    MsgBox(16, "Warning!", " FieldPro is not currently running, please start FieldPro, Login and try again."& @CRLF & @CRLF & "                   Press OK when you are logged in!")
                    WinActivate("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote")
                EndIf
            
            
            
            For $i = 1 To $Result2[0]-1
;~                 
            Doit1()
            Next
        

        Case $msg = $Button3
            ExitLoop
            
        Case $msg = $Radio1
            If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED And $1stClick = 1 Then
            $1stClick = 2
            ElseIf BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED And $1stClick = 2 Then
            GUICtrlSetState($Radio1, $GUI_UNCHECKED)
            $1stClick = 1
            EndIf
        Case Else
            ;;;
    EndSelect
WEnd
Exit

;======================Functions=========================;
Func Doit1()
;~     MsgBox(0,"", "ffs")
    WinWait("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "")
    If Not WinActive("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "") Then WinActivate("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "")
    WinWaitActive("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "")
    Send("!sw")
    Sleep(500)
    Send("{F5}")
    Send("{TAB}")
    Send($Result2[$i])
    Send("{Enter}")
    Send("{Enter}")
    EndFunc   ;==>Doit1
;========================================================;
;~ Func Doit2()
;~     WinWait("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","")
;~     If Not WinActive("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","") Then WinActivate("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","")
;~         WinWaitActive("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","")
;~         Send("!sw")
;~         sleep(400)
;~         Send("{F5}")
;~         Send("d")
;~         sleep(200)
;~         Send("{TAB}")
;~         Sleep(200)
;~         Send($Result2[$i])
;~         Send("{Enter}")
;~         Send("{Enter}")
;~ EndFunc
;========================================================;
Edited by Neoborn

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites



Your line here is a NOOP, it doesn't do anything because you don't save the result:

StringStripWS($Result1, 4)oÝ÷ Ù.¦ºi¹r槵«­¢+ØÀÌØíIÍÕ±ÐÄôMÑÉ¥¹MÑÉ¥Á]L ÀÌØíIÍÕ±ÐİФoÝ÷ Øêò¢ç(ºWaj÷¦byÛaj×%y©î¦íçZµ¬!z|¨º·v+^)Þiº/zØZ¶Þjëh×6$Result1 = StringStripWS(GUICtrlRead($Input1, 1), 4)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Not Tested

#include <GuiConstants.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)

GUICreate("Open MSO's", 170, 283, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input1 = GUICtrlCreateEdit("", 10, 10, 90, 220)
$Button2 = GUICtrlCreateButton("Go!", 10, 240, 60, 30)
$Button3 = GUICtrlCreateButton("Exit", 80, 240, 60, 30)
$Label2 = GUICtrlCreateLabel("Total", 110, 7, 40, 20)
$Radio1 = GUICtrlCreateRadio ( "Case", 110, 50)

Global $Label1 = GUICtrlCreateinput("", 110, 20, 40, 20)
GUICtrlSetState ($Label1, $GUI_DISABLE)
Local $1stClick = 1

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
           
        Case $msg = $Button2
            $Result1 = GUICtrlRead($Input1, 1)
            $Result1 = StringStripWS($Result1, 4)
           
            ;this line:
            $Result2 = StringSplit($Result1, @CR)
            GuiCtrlSetData($Label1, UBound($Result2, 1)-1)
           
                If WinExists("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote")= 0 Then
                    MsgBox(16, "Warning!", " FieldPro is not currently running, please start FieldPro, Login and try again."& @CRLF & @CRLF & "                   Press OK when you are logged in!")
                    WinActivate("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote")
                EndIf
           
           
           
            For $i = 1 To $Result2[0]-1
;~                 
            If $Result2[$i] <> "" Then Doit1($Result2[$i])
            Next
       

        Case $msg = $Button3
            ExitLoop
           
        Case $msg = $Radio1
            If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED And $1stClick = 1 Then
            $1stClick = 2
            ElseIf BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED And $1stClick = 2 Then
            GUICtrlSetState($Radio1, $GUI_UNCHECKED)
            $1stClick = 1
            EndIf
        Case Else
            ;;;
    EndSelect
WEnd
Exit

;======================Functions=========================;
Func Doit1($info1)
;~     MsgBox(0,"", "ffs")
    WinWait("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "")
    If Not WinActive("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "") Then WinActivate("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "")
    WinWaitActive("FieldPro Enterprise  V4.17     (Fieldpro) - \\Remote", "")
    Send("!sw")
    Sleep(500)
    Send("{F5}")
    Send("{TAB}")
    Send($info1)
    Send("{Enter}")
    Send("{Enter}")
    EndFunc   ;==>Doit1
;========================================================;
;~ Func Doit2()
;~     WinWait("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","")
;~     If Not WinActive("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","") Then WinActivate("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","")
;~         WinWaitActive("FieldPro Enterprise  V4.17     (FieldPro) - \\Remote","")
;~         Send("!sw")
;~         sleep(400)
;~         Send("{F5}")
;~         Send("d")
;~         sleep(200)
;~         Send("{TAB}")
;~         Sleep(200)
;~         Send($Result2[$i])
;~         Send("{Enter}")
;~         Send("{Enter}")
;~ EndFunc
;========================================================;

Added Salty's notation

8)

Edited by Valuater

NEWHeader1.png

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