Jump to content

Fresh set of eyes please - undefined function


ZenKensei
 Share

Recommended Posts

Group,

Ok, someone with a fresh set of eyes please take a look at the code snippet below. The entire script runs and appears to do everything correctly, however when I run a syntax check I receive the following error:

ERROR: GUICtrlRead(): undefind function

$ServerSelected = (GUICtrlRead ($mylist)

Yeah, I know, if it's not broke don't fix it. I just want to make sure I'm not creating a problem down the road as the script continues to grow.

Below is the snippet of code, minus the break out functions:

#include <GUIConstants.au3>

Global $GUIWidth
Global $GUIHeight
$GUIWidth = 200
$GUIHeight = 250

; create serverlist for use with listbox
$mylist = ""
$ServerList = ""
$file = FileOpen("C:\RetServers.txt", 0); 'RetServers.txt' contains the name of servers, one per line, to work with
If $file = -1 Then
   MsgBox(0, "Error", "Unable to open file.")
   Exit
EndIf

While 1
   $line = FileReadLine($file)
   If @error = -1 Then ExitLoop
   $ServerList = $ServerList & "|" & $line
Wend

FileClose($file)

GUICreate("Server Tools", $GUIWidth, $GUIHeight); will create a dialog box that when displayed is centered
GUICtrlCreateLabel("Select A Server", 50, 10, 100, 20)
$mylist = GUICtrlCreateList("", 35, 35, 121, 97)
GUICtrlSetLimit(-1, 200); to limit horizontal scrolling
GUICtrlSetData(-1, $ServerList)
$ping = GUICtrlCreateButton("Ping", 20, 125, 75, 25)
$FTP = GUICtrlCreateButton("FTP", 20, 150, 75, 25)
$RClient = GUICtrlCreateButton("RClient", 100, 125, 75, 25)
$TServer = GUICtrlCreateButton("TServer", 100, 150, 75, 25)
$ITAssist = GUICtrlCreateButton("ITAssist", 20, 175, 75, 25)
$close = GUICtrlCreateButton("Exit", 60, 215, 75, 25)

GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
   $msg = GUIGetMsg()
   [B]$ServerSelected = GUICtrlRead ($mylist)[/B]
   Select
      Case $msg = ($ping)
         _PingFunc($ServerSelected)
      Case $msg = ($FTP)
         _FTPFunc($ServerSelected)
      Case $msg = ($RClient)
         _RClientFunc($ServerSelected)
      Case $msg = ($TServer)
         _TServerFunc($ServerSelected)
      Case $msg = ($ITAssist)
         _ITAssistFunc($ServerSelected)
      Case $msg = $close
         MsgBox(0, "EXIT", "Closing the Application", 2)
         Exit
   EndSelect
Wend

The selection is bold is what I'm assuming the error is referring to. When I check the help file for the GUICtrlRead function, I see no real differences between the way it is used in the example and my use of it in the code above.

Is there an issue with the syntax in my code or am I simply using it in such a way that the syntax check only perceives an error (where no error exist).

Thanks in advance for any comments or feedback,

ZK

Edited by ZenKensei
Link to comment
Share on other sites

JPM,

DOH!!!! Thanks for the response, you were correct. I was using the latest beta version of AutoIT but was not using the latest definitions in Scite4Autoit, so the syntax checker did not understand what I was trying to accomplish.

Seems like I needed a fresh brain and not just a set of eyes... :idiot:

Thanks again as always,

ZK

Link to comment
Share on other sites

You don't need the parenthesis around the function either, I think:

$ServerSelected = (GUICtrlRead ($mylist))

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

Insolence,

Thanks for the response and taking the time proof read the code. I have made the suggested code changes to the script I posted (as well as to my own working copy). I wasn't sure about the parenthesis originally either, but decided to leave them as the script still worked. However, I agree with you that for consistency they should be left off.

Thanks again,

ZK

Link to comment
Share on other sites

No problem o'course :idiot:

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
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...