elbywong Posted November 1, 2017 Share Posted November 1, 2017 Hi there, I am the newbie of Autoit and deal with some issue when I am implementing the Autoit script. Can anyone help to check whether my concept or implementation is wrong or not? I have a <main.au3> file that contains the global variables named as "caseNo" and "caseTitle" which the variables will call in another function file named as <CommonFunc.au3>. But, the variables only able to update within the <main.au3> but not <CommonFunc.au3>. In <main.au3>, I am trying to update the variables and the log file can show the changes of variables. For example, the string value of "CaseNo" can change from "Case01" into "Case06". However, when I am trying to capture the variables from <CommonFunc.au3> into log file, the variable of "caseNo" and "caseTitle" are both cached in "Case01" and its own title. Can anyone help to investigate and advise on it? I am so confused and trapped into this issue for two days which I cannot figure out what went wrong.... main.au3 CommonFunc_modified.au3 Link to comment Share on other sites More sharing options...
jchd Posted November 1, 2017 Share Posted November 1, 2017 Do you invoke any function in CommonFunc from either #include <login.au3> ; case 1 #include <deleteProject.au3> ; case 6 or from some other UDF you include? If yes, then realize that at this point your global variables aren't declared yet. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
elbywong Posted November 1, 2017 Author Share Posted November 1, 2017 10 minutes ago, jchd said: Do you invoke any function in CommonFunc from either #include <login.au3> ; case 1 #include <deleteProject.au3> ; case 6 or from some other UDF you include? If yes, then realize that at this point your global variables aren't declared yet. I have included all of the cases and plus with the <CommonFUnc.au3> into the <main.au3> already. I think the global variables suppose declared in <main.au3> and inherit to <CommunFunc.au3> as well Link to comment Share on other sites More sharing options...
jchd Posted November 1, 2017 Share Posted November 1, 2017 Stop thinking forward! AutoIt uses an interpretor, it isn't a compiled language. When AutoIt processes includes up to CommonFunc it has not yet seen declarations placed some lines after that in Main. So there is no "inheritance" possible from line 200 in line 100. When interpretor processes line 100, it can have no idea what's declared in line 200 because it can't "see" forward. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
elbywong Posted November 1, 2017 Author Share Posted November 1, 2017 1 minute ago, jchd said: Stop thinking forward! AutoIt uses an interpretor, it isn't a compiled language. When AutoIt processes includes up to CommonFunc it has not yet seen declarations placed some lines after that in Main. So there is no "inheritance" possible from line 200 in line 100. When interpretor processes line 100, it can have no idea what's declared in line 200 because it can't "see" forward. So, you are now suggesting me to include the case into <CommonFUnc.au3> as well? I am getting a little bit lost Link to comment Share on other sites More sharing options...
jchd Posted November 1, 2017 Share Posted November 1, 2017 Only you know what you mean by "case". What I'm saying is that: in your #includes if you have any active statement (not within a function) referencing variables which are only defined after then you'll fall into "variable not defined" trap. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Juvigy Posted November 3, 2017 Share Posted November 3, 2017 Define and declare ALL your global variables in the beginning of your master script. Earthshine 1 Link to comment Share on other sites More sharing options...
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