GodForsakenSoul Posted December 27, 2009 Share Posted December 27, 2009 (edited) i got an idea, but i can't seem to get it right. i want one file to have all the guis, and another file to have all the actual functions of the guis. here's the idea GUICreate("Japanese basic training",350,250) Opt("GuiCoordMode",0) $mbutton1=GUICtrlCreateButton("Practice Kana",50,50,100,20) $mbutton2=GUICtrlCreateButton("Practice Conjucation",0,30,150,20) $mbutton3=GUICtrlCreateButton("Options",0,30,150,20) $mbutton4=GUICtrlCreateButton("Exit",0,100,150,20) GUISetState() FUNCTIONSOFGUI() and the other file to describe the functions of each button. while 1=1 $mgmsg=GUIGetMsg() Select Case $mgmsg=$mbutton1 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","1") Sleep(10) ExitLoop Case $mgmsg=$mbutton2 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","2") Sleep(10) ExitLoop Case $mgmsg=$mbutton3 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","3") Sleep(10) ExitLoop Case $mgmsg=$mbutton4 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","4") Sleep(10) ExitLoop Case $mgmsg=$GUI_EVENT_CLOSE ExitLoop EndSelect WEnd simply moving the thing into another file and cutting the while loop doesn't quite do it. i'm getting alot of errors about undeclared variables. i tried every thing i could think of, and i admit it wasn't that many attempts... suggestions? Edited January 16, 2010 by GodForsakenSoul Link to comment Share on other sites More sharing options...
Bert Posted December 27, 2009 Share Posted December 27, 2009 (edited) Yes, this is really simple. Use #include. http://www.autoitscript.com/autoit3/docs/keywords/include.htm Let me expand on this.. If I remember right, I fixed your multi GUI script a while back. I take it your script has gotten so large it is becoming unmanageable. This is what you do: Take some of the functions you have finished and are happy with. Put them in a file in the same folder as your main script and save it. In your main script, use #include "your file" at the top of your main script to point to the function file. Make sure you have declared all your variables first. You remember how I used DIM? Hope this helps. Edited December 27, 2009 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted December 27, 2009 Author Share Posted December 27, 2009 (edited) actually, it's mostly for easier updates. instead of writing a huge new file, i'll just write a smaller file with... say... prettier guis or something. the problem is when i cut/paste the while loop into the function file, it starts whining about undeclared variables. i DID include the function file in the gui file, but it persists with whining. here's my error log D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(5,25) : WARNING: $mbutton1: possibly used before declaration. Case $mgmsg=$mbutton1 ~~~~~~~~~~~~~~~~~~~~~^ D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(9,25) : WARNING: $mbutton2: possibly used before declaration. Case $mgmsg=$mbutton2 ~~~~~~~~~~~~~~~~~~~~~^ D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(13,25) : WARNING: $mbutton3: possibly used before declaration. Case $mgmsg=$mbutton3 ~~~~~~~~~~~~~~~~~~~~~^ D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(17,25) : WARNING: $mbutton4: possibly used before declaration. Case $mgmsg=$mbutton4 ~~~~~~~~~~~~~~~~~~~~~^ D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(21,32) : WARNING: $GUI_EVENT_CLOSE: possibly used before declaration. Case $mgmsg=$GUI_EVENT_CLOSE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(5,25) : ERROR: $mbutton1: undeclared global variable. Case $mgmsg=$mbutton1 ~~~~~~~~~~~~~~~~~~~~~^ D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3 - 1 error(s), 5 warning(s) those variables. ESPECIALLY $mgmsg are very much mentioned, as you can see. while 1=1 $mgmsg=GUIGetMsg() Select Case $mgmsg=$mbutton1 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","1") Sleep(10) ExitLoop Case $mgmsg=$mbutton2 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","2") Sleep(10) ExitLoop Case $mgmsg=$mbutton3 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","3") Sleep(10) ExitLoop Case $mgmsg=$mbutton4 IniWrite("Data\OPT.INI","OPTIONS","BUTTONMG","4") Sleep(10) ExitLoop Case $mgmsg=$GUI_EVENT_CLOSE ExitLoop EndSelect WEnd edit: ok, so, i gave it guiconstants.au3 and it eliminated the $GUI_EVENT_CLOSE error.... but still. 4 errors that, imho, shouldn't be there. edit2: actually... no... i don't remember how you used dim... point me in the right location? Edited December 27, 2009 by GodForsakenSoul Link to comment Share on other sites More sharing options...
Mat Posted December 27, 2009 Share Posted December 27, 2009 I think you can use "#forceref" to get rid of those. AutoIt Project Listing Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted December 27, 2009 Author Share Posted December 27, 2009 (edited) I think you can use "#forceref" to get rid of those.it's not documented in the help file O.owhat does it do?@MAT: BWAHAHAHAHA!yeah, your little idea got rid of my errors. now a new one.D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(3,10) : ERROR: syntax error#forcerefXD Edited December 27, 2009 by GodForsakenSoul Link to comment Share on other sites More sharing options...
Bert Posted December 27, 2009 Share Posted December 27, 2009 it's not documented in the help file O.owhat does it do?@MAT: BWAHAHAHAHA!yeah, your little idea got rid of my errors. now a new one.D:\Autoit Work\Autoit Japanese Training\Data\FUNCMainFunc.au3(3,10) : ERROR: syntax error#forcerefXDI second that. I'm running the latest beta too. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
trancexx Posted December 28, 2009 Share Posted December 28, 2009 It should be: #forceref $iSomeVariable, $sSomeOtherVariable ; The rest of the code ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 28, 2009 Share Posted December 28, 2009 Topic: #forceref [Answered]Examples by Jos. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted December 28, 2009 Author Share Posted December 28, 2009 allright, so... let me see if i got you guys right.... what you are suggeting is that when i put the function part in a new file, i #forceref all my variables? Link to comment Share on other sites More sharing options...
Bert Posted December 28, 2009 Share Posted December 28, 2009 You can do what Jos suggested, or do what I suggest. either one works. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted December 28, 2009 Author Share Posted December 28, 2009 (edited) It should be: #forceref $iSomeVariable, $sSomeOtherVariable ; The rest of the code uh... retard question: are the i and s before the variable names important? edit: i don't think i understand what you mean... it doesn't seem to work Edited December 28, 2009 by GodForsakenSoul Link to comment Share on other sites More sharing options...
Mat Posted December 28, 2009 Share Posted December 28, 2009 The "i" and the "s" indicate the type pf variable. this page has more info under variable names. AutoIt Project Listing Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 28, 2009 Share Posted December 28, 2009 (edited) Using #forceref doesn't clear up "possibly used before declaration" errors. The way to clear that up is properly declare the variables. $GUI_EVENT_CLOSE, for example, is contained in GuiConstantsEx.au3, so adding "#include <GuiConstantsEx.au3>" to the top of your script will clear that one. The #forceref keyword is for the opposite problem, where variables appear to be declared then not used in the script or function. The error fixed by "#forceref $x" would be something like: "WARNING: $x: declared, but not used in func." Edited December 28, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted January 16, 2010 Author Share Posted January 16, 2010 I DID IT!!!! for future reference, this should get documented or something. i can't really explain it in words, but here's a piece of code i wanted to get from this thread. GUICreate("Japanese basic training: Main menu",350,250) ;Main menu screen Opt("GuiCoordMode",0) $mmBut1=GUICtrlCreateButton("Pracitce Kana",25,25,150,20) $mmBut2=GUICtrlCreateButton("Practice Conjugation",0,25,150,20) $mmBut8=GUICtrlCreateButton("Options",0,25,150,20) $mmBut9=GUICtrlCreateButton("Exit",0,50,150,20) $mmBut0=GUICtrlCreateButton("About",0,25,150,20) GUISetState() guiusage($mmBut1,$mmBut2,$mmBut8,$mmBut9,$mmBut0) Func guiusage($gummb1,$gummb2,$gummb8,$gummb9,$gummb0) While 1=1 $gumsg=GUIGetMsg() Select Case $gumsg=$gummb1 MsgBox(1,"","working") Case $gumsg=$gummb2 MsgBox(1,"","working") Case $gumsg=$gummb8 MsgBox(1,"","working") Case $gumsg=$gummb9 MsgBox(1,"","working") Case $gumsg=$gummb0 MsgBox(1,"","working") EndSelect WEnd EndFunc the idea is that you call the function with the actual gui function using all the handles of buttons and such. guiusage($mmBut1,$mmBut2,$mmBut8,$mmBut9,$mmBut0) i know necro-posting is bad, but my excuse is documentation and help for future generations 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