au3scr Posted October 18, 2008 Posted October 18, 2008 What i did wrong? I MUST use function to define variables,but when i define them i cant use them. Func ReadINI() $Refresh = 2000 DoFunc() EndFunc Func DoFunc() Sleep ($Refresh) EndFunc And error is long >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\rain\Desktop\lol.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>17:17:33 Starting AutoIt3Wrapper v.1.10.1.12 Environment(Language:0409 Keyboard:00000425 OS:WIN_XP/Service Pack 2 CPU:X86 ANSI) >Running AU3Check (1.54.13.0) from:C:\Program Files\AutoIt3 C:\Documents and Settings\rain\Desktop\lol.au3(7,17) : WARNING: $Refresh: possibly used before declaration. Sleep ($Refresh) ~~~~~~~~~~~~~~~^ C:\Documents and Settings\rain\Desktop\lol.au3(7,17) : ERROR: $Refresh: undeclared global variable. Sleep ($Refresh) ~~~~~~~~~~~~~~~^ C:\Documents and Settings\rain\Desktop\lol.au3 - 1 error(s), 1 warning(s) !>17:17:33 AU3Check ended.rc:2 +>17:17:43 AutoIt3Wrapper Finished >Exit code: 0 Time: 10.972
Zisly Posted October 18, 2008 Posted October 18, 2008 Declare it in a global scope. Ex; Global $myvariable
martin Posted October 18, 2008 Posted October 18, 2008 (edited) What i did wrong? I MUST use function to define variables,but when i define them i cant use them. Func ReadINI() $Refresh = 2000 DoFunc() EndFunc Func DoFunc() Sleep ($Refresh) EndFunc And error is long >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\rain\Desktop\lol.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>17:17:33 Starting AutoIt3Wrapper v.1.10.1.12 Environment(Language:0409 Keyboard:00000425 OS:WIN_XP/Service Pack 2 CPU:X86 ANSI) >Running AU3Check (1.54.13.0) from:C:\Program Files\AutoIt3 C:\Documents and Settings\rain\Desktop\lol.au3(7,17) : WARNING: $Refresh: possibly used before declaration. Sleep ($Refresh) ~~~~~~~~~~~~~~~^ C:\Documents and Settings\rain\Desktop\lol.au3(7,17) : ERROR: $Refresh: undeclared global variable. Sleep ($Refresh) ~~~~~~~~~~~~~~~^ C:\Documents and Settings\rain\Desktop\lol.au3 - 1 error(s), 1 warning(s) !>17:17:33 AU3Check ended.rc:2 +>17:17:43 AutoIt3Wrapper Finished >Exit code: 0 Time: 10.972If you need to have a variable which can be used in different functions then either declare it as Global or pass the variable as a parameter to the function which needs to use it. Global Func ReadINI() Global $Refresh = 2000;Preferably have Global $Refresh in your main script DoFunc() EndFunc Func DoFunc() Sleep ($Refresh) EndFunc Passing a parameter Func ReadINI() $Refresh = 2000 DoFunc($Refresh) EndFunc Func DoFunc($iTime) Sleep ($iTime) EndFunc Edit:spelling Edited October 18, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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