VinitMeta Posted September 15, 2008 Posted September 15, 2008 (edited) Here is another similar problem> for following code i am getting error as "Variable used without being declared" The variable for which i am getting this error is $LogPath in function Func WriteLog($strText) which i have already defined as Global. Edited September 23, 2008 by VinitMeta
DjDeep00 Posted September 15, 2008 Posted September 15, 2008 @VinitMeta... First of all always wrap any code using the code tag like this: expandcollapse popup#Region Include files #include "Common.au3" #EndRegion Include files #NoTrayIcon #Region Parameter Explaination #comments-start ;Input Parameters ;1. psexecPath = Path of psexec Utility. ;2. BaseMachine = Machine Name or Ip address Without Backslash ;3. UserName = UserName under which this command need to be execute ;4. Password = Corrosponding password for base Machine. ;5. VMstartUtilityPath = File to be Execute remotely. This File must be presnt on local system. ; The file contsionas VMRun command to start the virtual Machine. ;6. VMImageToLoad = Image path for virtual Machine. #comments-End #EndRegion Global $Result = 1 Global $psexecCommnd_FileName Global $BaseMachine Global $UserName Global $Password Global $ExecuteFile Global $ImagePath #Region OnAutoItStart Func OnAutoItStart() #comments-start Global $psexecCommnd_FileName = "" Global $BaseMachine= "" Global $UserName= "" Global $Password= "" Global $ExecuteFile= "" Global $ImagePath= "" #comments-end SetEnv("AUTODEPLOYMENT_STATUS","NOTSTARTED") $exitCode = 0 BeginLog() if $CmdLine[0] < 6 then WriteLog("Invalid Arguments") Else WriteLog("Calling ParseInput()") Call("ParseInput") WriteLog("Calling StartVirtualMachine()") call ("StartVirtualMachine") EndIf EndFunc #EndRegion OnAutoItStart ;Stores Command line parameters And create comman to start the Vitrual machine on given host. Func StartVirtualMachine() LogFuncStart("StartVM->StartVirtualMachine") WriteLog("Calling ValidateParameters()") $Valid = call("ValidateParameters") If $Valid == False Then Exit EndIf WriteLog(StringLeft($BaseMachine,2)) if StringLeft($BaseMachine,2) == "\\" then $BaseMachine = StringTrimLeft($BaseMachine,2) EndIf ;Execute Command to start Virtual Machine. WriteLog("Invoking ShellExecuteWait() with Parameter" & $psexecCommnd_FileName &' \\' &$BaseMachine & ' -i -u ' & $UserName & ' -p ' &$Password & ' -c "' &$ExecuteFile &'" "' &$ImagePath) $StartVM = ShellExecuteWait($psexecCommnd_FileName,' \\' &$BaseMachine & ' -i -u ' & $UserName & ' -p ' &$Password & ' -c "' &$ExecuteFile &'" "' &$ImagePath& '"','','',@SW_MAXIMIZE) WriteLog("Return code is "&$StartVM &" Error Code is - "& @error) ;if Both the codes are zero means command executed successfully. if $StartVM == 0 AND @error == 0 Then SetEnv("AUTODEPLOYMENT_STATUS","STARTVM") WriteLog("Virtual Machine startup SUCCSSS") else SetEnv("AUTODEPLOYMENT_STATUS","FAILED") WriteLog("Virtual Machine startup FAILED") EndIf EndFunc ;Function to validate the parameters. Func ValidateParameters() $Valid = True LogFuncStart("StartVM->ValidateParameters") ;Check if psexec.exe file path is valid. if (FileExists($psexecCommnd_FileName) ==0 ) Then WriteLog("psexec is not available at specified path") $Valid = False EndIf ;Check if base machine is reachable. if ($Result = Ping($BaseMachine)) == 0 Then WriteLog("Host not Reachable Error Code Returned is - " & @error) $Valid = False EndIf ;Check if Usrname is empty string if not StringLen($UserName) > 0 Then WriteLog("User Name can not be blank") $Valid = False EndIf ;check if password is empty if not StringLen($Password) > 0 Then WriteLog("Password can not be blank") $Valid = False EndIf ;Check if file to be execte on remote system is presnt. if Not FileExists($ExecuteFile) Then WriteLog("File to execute is not available. Please check the Path specified. ("&$ExecuteFile&")") $Valid = False EndIf ;check if image path is defined. if StringLen($ImagePath) > 0 Then WriteLog("Please specify the path of Image to load") $Valid = False EndIf return $Valid EndFunc ;Function to Parse the Input parametrs. Func ParseInput() Dim $VarTemp FOR $element IN $CmdLine $VarTemp = StringSplit($element,"=",1) Switch($VarTemp[1]) case "UserName" $UserName = $VarTemp[2]; UserName Under which one want to execute command remotely WriteLog("UserName - "&$UserName) Case "password" $Password = $VarTemp[2]; Corrosponding Password. WriteLog("password - ") Case "BaseMachine" $BaseMachine = $VarTemp[2]; Remote Machine on which command is to executed. WriteLog("BaseMachine - "&$BaseMachine) Case "psexecPath" $psexecCommnd_FileName = $VarTemp[2]; Complete Path of psexec tool. WriteLog("psexecPath - "&$psexecCommnd_FileName) case "VMstartUtilityPath" $ExecuteFile = $VarTemp[2]; File to be execute on remote syste. This file contains command to be exec. WriteLog("VMstartUtilityPath - "&$ExecuteFile) Case "VMImageToLoad" $ImagePath = $VarTemp[2]; Path of the image to be load to start Virtual Machine. WriteLog("VMImageToLoad - "&$ImagePath) EndSwitch NEXT EndFunc Second copy and paste the exact error which u see in Scite.
MrCreatoR Posted September 15, 2008 Posted September 15, 2008 @VinitMeta... Where is Common.au3 file? no one can check this code because there is missing UDFs and probably some more variables. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
MrCreatoR Posted September 16, 2008 Posted September 16, 2008 The variable for which i am getting this error is $LogPath in function Func WriteLog($strText) which i have already defined as Global.You declare it at the end of script, you should declare global variables at the begining, because when you call functions at the begining, the variable does not declared yet as Global. #include-once #include <File.au3> ..... Global $LogLevel Global $LogPath ..... Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
trancexx Posted September 16, 2008 Posted September 16, 2008 (edited) Here is another similar problem> for following code i am getting error as "Variable used without being declared" The variable for which i am getting this error is $LogPath in function Func WriteLog($strText) which i have already defined as Global.That is virtually impossible. Btw, you have declared it twice. And you haven't declared $text and $value (that's not problem but still...) [codеbox][/codеbox] is maybe more appropriate Edited September 16, 2008 by trancexx ♡♡♡ . eMyvnE
MrCreatoR Posted September 16, 2008 Posted September 16, 2008 Here is the code snippet but still their is errorI repeat, no one can check those kind of script, they not full, how we supose to check part of some big script, where used variables and functions called...Provide full working example of your problem (or the full script you are using), otherwise i don't think anyone can help you with this info. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
VinitMeta Posted September 17, 2008 Author Posted September 17, 2008 (edited) I repeat, no one can check those kind of script, they not full, how we supose to check part of some big script, where used variables and functions called...Provide full working example of your problem (or the full script you are using), otherwise i don't think anyone can help you with this info.Ok As per your saying i am posting full code here. What i am trying to do is: -in Logger.au3 I have written function to write the log file. I want to provide the different log levels. So with BeginLog() i am trying to set the log level. Now this logger.au3 i have included in temp.au3.but when i run the code with it gives me error saying "Variable used without being declared"Common.au3 Edited September 23, 2008 by VinitMeta
MrCreatoR Posted September 17, 2008 Posted September 17, 2008 Func OnAutoItStart() .... This one tells me all - OnAutoItStart() called before even script is started, so no variables declared on this step. You can check it like this: Func OnAutoItStart() If Not IsDeclared("LogPath") Then Exit MsgBox(16, "", "Variable [$LogPath] is not declared yet") BeginLog(1,"C:\Test.log") Call("LogTester") EndFuncoÝ÷ Ø Ý£*.綬zØb±û§rبrcºËn±ëazX§zÊ.¶ÈzØ^~éܶ*'±´Þ²Ö®ßöÚºÚ"µÍYÚ[ÙÊK ][ÝÐÎÌLÕÝÙÉ][ÝÊBØ[ ][ÝÓÙÕÝ][ÝÊB[ÈÙÕÝ BÜ]SÙ×ÑXYÊ ][ÝÑXYÉ][ÝÊBÜ]SÙ×ÑÜ ][ÝÑÜ][ÝÊBÜ]SÙ×ÕØ ][ÝÕØ[É][ÝÊB[[ Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
VinitMeta Posted September 22, 2008 Author Posted September 22, 2008 This one tells me all >_< - OnAutoItStart() called before even script is started, so no variables declared on this step. You can check it like this: Func OnAutoItStart() If Not IsDeclared("LogPath") Then Exit MsgBox(16, "", "Variable [$LogPath] is not declared yet") BeginLog(1,"C:\Test.log") Call("LogTester") EndFuncoÝ÷ Ø Ý£*.綬zØb±û§rبrcºËn±ëazX§zÊ.¶ÈzØ^~éܶ*'±´Þ²Ö®ßöÚºÚ"µÍYÚ[ÙÊK ][ÝÐÎÌLÕÝÙÉ][ÝÊBØ[ ][ÝÓÙÕÝ][ÝÊB[ÈÙÕÝ BÜ]SÙ×ÑXYÊ ][ÝÑXYÉ][ÝÊBÜ]SÙ×ÑÜ ][ÝÑÜ][ÝÊBÜ]SÙ×ÕØ ][ÝÕØ[É][ÝÊB[[ Thanks a lot 'MrCreatoR'.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now