Sign in to follow this  
Followers 0
ksmith247

Help with displaying Arrays

7 posts in this topic

The following code is used to check for the existence of a particular file on a server share. If I use an Inputbox instead of GUICreate it works but it closes after each run. I figured I would do it properly so I could search for several files without having to relaunch the script each time. It sort of works but what happens is I get a complete list of all files (around 5000 of them) then the whittled down list that I am asking for after closing the first full list. Also the whittled down list continues to display itself instead of closing. I have to kill the script from the SysTray. Any help appreciated as always.

#include <File.au3>
#include <Array.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

$Server = "\\SERVER\SHARE\"
;$List = _FileListToArray($Server, $CompName & "*")

#Region ### START Koda GUI section ### 
;RecKey.kxf
$Form1 = GUICreate("Search for Recovery Key", 251, 129, 393, 303)
$Label1 = GUICtrlCreateLabel("Enter Computer Name", 72, 16, 108, 17)
$Input1 = GUICtrlCreateInput("", 56, 48, 137, 21)
$Button1 = GUICtrlCreateButton("Search", 88, 88, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    $CompName = GUICtrlRead($Input1)
    $List = _FileListToArray($Server, $CompName & "*")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button1
            If @error <> 0 Then
                MsgBox(0, "No Key", "No Recovery Key found for " & $CompName & ".")
                Exit
            EndIf
            _ArrayDisplay($List)
            ;Exit
    EndSwitch
WEnd

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Share this post


Link to post
Share on other sites



#include <File.au3>
#include <Array.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

$Server = "\\SERVER\SHARE\"
;$List = _FileListToArray($Server, $CompName & "*")

#Region ### START Koda GUI section ### 
;RecKey.kxf
$Form1 = GUICreate("Search for Recovery Key", 251, 129, 393, 303)
$Label1 = GUICtrlCreateLabel("Enter Computer Name", 72, 16, 108, 17)
$Input1 = GUICtrlCreateInput("", 56, 48, 137, 21)
$Button1 = GUICtrlCreateButton("Search", 88, 88, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button1
            $CompName = GUICtrlRead($Input1)
    $List = _FileListToArray($Server, $CompName & "*")
    If @error <> 0 Then
                MsgBox(0, "No Key", "No Recovery Key found for " & $CompName & ".")
                ContinueLoop
            EndIf
            _ArrayDisplay($List)
            ;Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

It is bad practice to call a function inside your GUI loop (filelisttoarray) without requiring user interaction first. This loop needs to be fast for your GUI to respond in a timely fashion.

Share this post


Link to post
Share on other sites

<br />It is bad practice to call a function inside your GUI loop (filelisttoarray) without requiring user interaction first. This loop needs to be fast for your GUI to respond in a timely fashion.<br />

<br /><br /><br />

So what would be proper?


Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Share this post


Link to post
Share on other sites

<br /><br /><br />

So what would be proper?

Zedna posted a proper solution.

Share this post


Link to post
Share on other sites

Ahh... not sure who you were talking too. Thanks.


Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Nevermind. Changed Switch to Select and all is well. Guess I need to read up on those.

Edited by ksmith247

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

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