Sign in to follow this  
Followers 0
microbious

How to reference from one script to another ?

16 posts in this topic

#1 ·  Posted (edited)

Yes now that i covered few more basics coding with autoit i would like to know or find an example of how i would reference separate scripts to other scripts.

What are advantages and disadvantages ? What should i watch out for in both scripts. IF some $vars are same is there a problem ?

SO anyway i am working on a project that come's in 2 parts, one is for one purpose and another is for another.

I also want to make third one for GUI only.

Once GUI is finished, Button1 will activate script 1 and button2 will activate script 2

How is this accomplished ?

Here is what i have in mind but am pretty sure its not the way to go.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("",200,100)
$button1 = GUICtrlCreateButton ("Backup",0,0,60,20)
$button2 = GUICtrlCreateButton ("Start 3DsMax",100,0,60,20)
$button3 = GUICtrlCreateButton ("Restore",160,0,60,20)
GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()

   Switch $nMsg
          case $button1
       #include <3dsmax 2010 backup.au3>
   case $button2
   case $button3
       #include <3dsmax 2010 restore.au3>
       Case $GUI_EVENT_CLOSE
           Exit
EndSwitch
WEnd

Can you guys point me to the right direction ?

Maybe u can call a function using GUI script from script1 or 2 ?

I am clueless how this is gonna work :D

Any ideas are welcome

Thanks in advance

Edited by Gettingsmarter

Share this post


Link to post
Share on other sites



Yes now that i covered few more basics coding with autoit i would like to know or find an example of how i would reference separate scripts to other scripts.

What are advantages and disadvantages ? What should i watch out for in both scripts. IF some $vars are same is there a problem ?

SO anyway i am working on a project that come's in 2 parts, one is for one purpose and another is for another.

I also want to make third one for GUI only.

Once GUI is finished, Button1 will activate script 1 and button2 will activate script 2

How is this accomplished ?

Here is what i have in mind but am pretty sure its not the way to go.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("",200,100)
$button1 = GUICtrlCreateButton ("Backup",0,0,60,20)
$button2 = GUICtrlCreateButton ("Start 3DsMax",100,0,60,20)
$button3 = GUICtrlCreateButton ("Restore",160,0,60,20)
GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()

   Switch $nMsg
          case $button1
       #include <3dsmax 2010 backup.au3>
   case $button2
   case $button3
       #include <3dsmax 2010 restore.au3>
       Case $GUI_EVENT_CLOSE
           Exit
EndSwitch
WEnd

Can you guys point me to the right direction ?

Maybe u can call a function using GUI script from script1 or 2 ?

I am clueless how this is gonna work :D

Any ideas are welcome

Thanks in advance

You could put all the functions in one au3 file with nothing in the main program and use that as your include file, which you include in the beginning of your code (as above). The contents that should execute in the backup could be a function, and the same goes with restore. So, instead of including the au3 when you click on the button, you call the function instead.

---3dsinclude.au3
Func Backup()
   ;whatever was in 3ds backup
Endfunc
Func Restore()
   ;whatever was in 3ds restore
Endfunc

---3dsbackup.au3
#include <3dsinclude.au3>
Backup()

---3dsrestore.au3
#include <3dsinclude.au3>
Restore()

---The script above
Case Button1
   Backup()
Case Button2
   Restore()

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You could put all the functions in one au3 file with nothing in the main program and use that as your include file, which you include in the beginning of your code (as above). The contents that should execute in the backup could be a function, and the same goes with restore. So, instead of including the au3 when you click on the button, you call the function instead.

Yes i could do that, but i want to organize my work and have separate actions in separate script so i can fix/work/improve them separate and have plenty of work space.

If i #include <file.ua3>

then its executed without asking so i wonder how to include file and execute it from main GUI script as a button action.

Can i create button action as another ua3 and make it one function and then call this function from main GUI ua3 ?

If so then this would take me to rewrite plenty of backup and restore code :D

Maybe something to CALL function from another script ? I tried call but not sure how it works :D

Any ideas are welcome

Thanks in advance for quick response

Edited by Gettingsmarter

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

hydroxide is right, what is the problem with include?

You just need to break it all up into functions.

test.au3

#include <testinc.au3>
Global Const $GUI_EVENT_CLOSE = -3

$Form1 = GUICreate("Form1", 200, 100)
$Button1 = GUICtrlCreateButton("Button1", 10, 10, 180, 80)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Leave($Form1)
        Case $Button1
            ButtonAction()
    EndSwitch
WEnd

testinc.au3

#include-once

Func ButtonAction()
    MsgBox(0, "TEST", "Button Action")
EndFunc

Func Leave($handle)
    For $a = 255 To 1 Step -1
        WinSetTrans( $handle, '', $a )
        Sleep(5)
    Next
    Exit
EndFunc
Edited by danwilli

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i tried following your example and its not working.

I am not sure what i do wrong, maybe i need some code in main script rather then in button action script.

I attach both launcher and backup scripts for u guys to see what i did wrong.

Correct me if i am wrong, Func is used to jump to places like CMD GOTO :SOMETHING right ?

And thanks allot for trying to help

3dsmax 2010 launcher.au3

buttonrestore.au3

Edited by Gettingsmarter

Share this post


Link to post
Share on other sites

The example works. Save both au3 files to the same directory. Run the test.au3 file from scite, or just compile then run.

Share this post


Link to post
Share on other sites

The example works. Save both au3 files to the same directory. Run the test.au3 file from scite, or just compile then run.

i am sure your example would work, its that i asked for someone to look into my script to see what i did wrong.

I think i didnt wrap whole code with FUNC somename() correctly.

Please have a look at previously attached code and let me know what i did wrong.

THanks

Share this post


Link to post
Share on other sites

My example shows what you did wrong. I am not going to write out the code for you.

Share this post


Link to post
Share on other sites

My example shows what you did wrong. I am not going to write out the code for you.

thats not what i asked for, i asked if u could look into my code and tell me what is wrong with it.

I am still learning use of functions so at this point i dont even understand how could i convert your example into mine so i can use it.

Also i did not as you in particular, i asked anyone who wants to help.

If you dont want to help then you dont have to

Share this post


Link to post
Share on other sites

#include <3dsmax 2010 backup.au3> and #include <3dsmax 2010 restore.au3> should only be called once at the top of the file. Actions should be broken up into functions in the include files and they should be called as if they were functions in the main au3.

What is the content of:

#include <3dsmax 2010 backup.au3>

#include <3dsmax 2010 restore.au3>

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

What is the content of:

#include <3dsmax 2010 backup.au3>

#include <3dsmax 2010 restore.au3>

i previously attached same script with minor changes and diferent file names but because i keep trying new things i constantly change the script.

Here is main GUI

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <buttonrestore.au3>
FileInstall ("instsrv.exe",@TempDir & "\instsrv.exe",1)
TraySetIcon (@TempDir & "\icon.ico",1)
$Form1 = GUICreate("",200,100)
$button1 = GUICtrlCreateButton ("Restore",0,0,60,20)
$programs32 = EnvGet ("programfiles")
$programs64 = EnvGet ("ProgramFiles(x86)")
$OS = @OSVersion
$OSbit = @OSArch

GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
case $button1
buttonrestore()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

and here is that button code i need to execute when its pressed

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include-once
#AutoIt3Wrapper_icon=icon.ico
Global $programs32, $programs64, $OS, $OSbit
Func buttonrestore() ;Call this function from Restore Button
MsgBox (0,'','works') ;This message is not working somehow but the fuction is reference in launcher.au3
;Check XP version
if $OS = "WIN_XP" And $OSbit = "X86" Then
TrayTip ("STATUS", "Windows XP 32bit Found",2)
actionXP()
ElseIf $OS = "WIN_XP" And $OSbit = "X64" Then
TrayTip ("STATUS", "Windows XP 64bit Found",2)
actionXP()
;If none of the above, go to next to determent Vista version
ElseIf $OS = "WIN_Vista" And $OSbit = "X86" Then
TrayTip ("STATUS", "Windows Vista/W7 32bit Found",2)
actionVista()
ElseIf $OS = "WIN_Vista" And $OSbit = "X64" Then
TrayTip ("STATUS", "Windows Vista/W7 64bit Found",2)
actionVista()
EndIf
EndFunc
    #Region ###  XP ###
Func actionXP()
TrayTip ("STATUS","Restore Registry",3)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\current 3dsmax.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\current SendMiniDimp.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local 3dsmax.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local backburner.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local MC3.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local ObjectDBX.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local PLM.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local Reg.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\local UPI.reg"',"",@SW_HIDE)
RunWait(@ComSpec & '/c regedit.exe /s "SAVED\XP\registry\Local flexLicence.reg"',"",@SW_HIDE)

TrayTip ("STATUS","Creating directories",3)
DirCreate (@UserProfileDir & "\My Documents\Adlm")
DirCreate (@UserProfileDir & "\Application Data\Autodesk\3DSMAX\12")
DirCreate (@UserProfileDir & "\Application Data\Autodesk\MC3")
DirCreate (@UserProfileDir & "\Local Settings\Application Data\Autodesk\3dsmax")
DirCreate (@HomeDrive & "\Documents and Settings\All Users\Application Data\Autodesk\3DSMAX\12")
DirCreate (@HomeDrive & "\Documents and Settings\All Users\Application Data\Autodesk\Adlm")
DirCreate (@HomeDrive & "\Documents and Settings\All Users\Application Data\Autodesk\MAX\12.0")
DirCreate (@HomeDrive & "\Documents and Settings\All Users\Application Data\Autodesk\MC3")
DirCreate (@HomeDrive & "\Documents and Settings\All Users\Application Data\FLEXnet")
DirCreate ($programs32 & "\Common Files\Macrovision Shared")
DirCreate ($programs32 & "\Common Files\Autodesk Shared")
DirCreate ($programs64 & "\Common Files\Macrovision Shared")
DirCreate ($programs64 & "\Common Files\Autodesk Shared")

TrayTip ("STATUS","Restore Files/Folders",3)
RunWait(@ComSpec & ' /c xcopy "saved\XP\My Documents\Adlm" "%USERPROFILE%\My Documents\Adlm"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\userprofile\Application Data\Autodesk\3DSMAX\12" "%USERPROFILE%\Application Data\Autodesk\3DSMAX\12"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\userprofile\Application Data\Autodesk\MC3" "%USERPROFILE%\Application Data\Autodesk\MC3"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\userprofile\Local Settings\Application Data\Autodesk\3dsmax" "%USERPROFILE%\Local Settings\Application Data\Autodesk\3dsmax"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\XP\alluser\3DSMAX\12" "%ALLUSERSPROFILE%\Application Data\Autodesk\3DSMAX\12"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\XP\alluser\Adlm" "%ALLUSERSPROFILE%\Application Data\Autodesk\Adlm"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\XP\alluser\MAX\12.0" "%ALLUSERSPROFILE%\Application Data\Autodesk\MAX\12.0"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\XP\alluser\MC3" "%ALLUSERSPROFILE%\Application Data\Autodesk\MC3"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E/H "saved\XP\alluser\FLEXnet" "%ALLUSERSPROFILE%\Application Data\FLEXnet"/Y',"",@SW_HIDE)
;Compare 32 and 64bit OS version
if $OS = "WIN_XP" And $OSbit = "X86" Then
    TrayTip ("STATUS","Restore Service",3)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\programfiles\Common Files\Autodesk Shared" "%PROGRAMFILES%\Common Files\Autodesk Shared"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\programfiles\Common Files\Macrovision Shared" "%PROGRAMFILES%\Common Files\Macrovision Shared"/Y',"",@SW_HIDE)
Elseif $OS = "WIN_XP" And $OSbit = "X64" Then
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\programfiles64\Common Files\Autodesk Shared" "%PROGRAMFILES%\Common Files\Autodesk Shared"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\XP\programfiles64\Common Files\Macrovision Shared" "%PROGRAMFILES%\Common Files\Macrovision Shared"/Y',"",@SW_HIDE)
EndIf 

RunWait(@ComSpec & ' /c %TEMP%\instsrv.exe "FLEXnet Licensing Service" "%PROGRAMFILES%\Common Files\Macrovision Shared\FLEXnet Publisher\FNPLicensingService.exe"',"",@SW_HIDE)
RunWait(@ComSpec & ' /c sc config "FLEXnet Licensing Service" start= demand',"",@SW_HIDE)
TrayTip ("3Ds Max 2010 Restore", 'Files restored.' & @CRLF & 'Loading 3Ds Max 2010',3)

RunWait ("3dsmax.exe",@ScriptDir) ;RUN  3ds max
TrayTip ("STATUS", 'Removing any temporary files used',2)
Sleep (2000)
FileDelete (@TempDir & "\instsrv.exe")
ProcessClose ("FNPLicensingService.exe")
ProcessClose ("LMU.exe")
EndFunc ;XP END
Exit

#EndRegion ### End XP ###
    #Region ### VISTA ###
Func actionVista() ; vista function begins here
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\current 3dsmax.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\current SendMiniDimp.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local 3dsmax.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local backburner.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local MC3.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local ObjectDBX.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local PLM.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local Reg.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\local UPI.reg"',"")
RunWait(@ComSpec & ' /c regedit.exe /s "SAVED\VISTA\registry\Local flexLicence.reg"',"")

DirCreate (@UserProfileDir & "\My Documents\Adlm")
DirCreate (@UserProfileDir  & "\AppData\Roaming\Autodesk\3DSMAX\12")
DirCreate (@UserProfileDir  & "\AppData\Roaming\Autodesk\MC3")
DirCreate (@UserProfileDir  & "\AppData\Local\Autodesk\3dsmax")
DirCreate (@DocumentsCommonDir  & "\Autodesk\3DSMAX\12")
DirCreate (@DocumentsCommonDir  & "\Autodesk\Adlm")
DirCreate (@DocumentsCommonDir  & "\Autodesk\MAX\12.0")
DirCreate (@DocumentsCommonDir  & "\Autodesk\MC3")
DirCreate (@DocumentsCommonDir  & "\FLEXnet")
DirCreate ($programs32 & "\Common Files\Macrovision Shared")
DirCreate ($programs32 & "\Common Files\Autodesk Shared")
DirCreate ($programs64 & "\Common Files\Macrovision Shared")
DirCreate ($programs64 & "\Common Files\Autodesk Shared")

RunWait(@ComSpec & ' /c xcopy "saved\My Documents\Adlm" "%USERPROFILE%\Documents\Adlm"/Y',"")
RunWait(@ComSpec & ' /c xcopy /D/E "saved\userprofile\Application Data\Autodesk\3DSMAX\12" "%USERPROFILE%\AppData\Roaming\Autodesk\3DSMAX\12"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\userprofile\Application Data\Autodesk\MC3" "%USERPROFILE%\AppData\Roaming\Autodesk\MC3"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\userprofile\Local Settings\Application Data\Autodesk\3dsmax" "%USERPROFILE%\AppData\Local\Autodesk\3dsmax"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\alluser\3DSMAX\12" "%ALLUSERSPROFILE%\Autodesk\3DSMAX\12"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\alluser\Adlm" "%ALLUSERSPROFILE%\Autodesk\Adlm"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\alluser\MAX\12.0" "%ALLUSERSPROFILE%\Autodesk\MAX\12.0"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E "saved\alluser\MC3" "%ALLUSERSPROFILE%\Autodesk\MC3"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /E/H "saved\alluser\FLEXnet" "%ALLUSERSPROFILE%\FLEXnet"/Y',"",@SW_HIDE)

    if $OS = "WIN_Vista" And $OSbit = "X86" Then
RunWait(@ComSpec & ' /c xcopy /D/E "saved\programfiles\Common Files\Autodesk Shared" "%PROGRAMFILES%\Common Files\Autodesk Shared"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\programfiles\Common Files\Macrovision Shared" "%PROGRAMFILES%\Common Files\Macrovision Shared"/Y',"",@SW_HIDE)
ElseIf $OS = "WIN_Vista" And $OSbit = "X64" Then
RunWait(@ComSpec & ' /c xcopy /D/E "saved\VISTA\programfiles64\Common Files\Autodesk Shared" "%PROGRAMFILES%\Common Files\Autodesk Shared"/Y',"",@SW_HIDE)
RunWait(@ComSpec & ' /c xcopy /D/E "saved\VISTA\programfiles64\Common Files\Macrovision Shared" "%PROGRAMFILES%\Common Files\Macrovision Shared"/Y',"",@SW_HIDE)
EndIf

RunWait(@ComSpec & ' /c %TEMP%\instsrv.exe "FLEXnet Licensing Service" "%PROGRAMFILES%\Common Files\Macrovision Shared\FLEXnet Publisher\FNPLicensingService.exe"',"",@SW_HIDE)
RunWait(@ComSpec & ' /c SC \\myServer CONFIG "FLEXnet Licensing Service" start= demand',@SW_HIDE)
TraySetToolTip ("3Ds Max 2010")
TrayTip ("STATUS", 'Files restored.' & @CRLF & 'Loading 3Ds Max 2010',3)
RunWait ("3dsmax.exe",@ScriptDir) ;RUN 3dsmax

TrayTip ("STATUS", 'Removing any temporary files used',2)
Sleep (2000)
FileDelete (@TempDir & "\instsrv.exe")
RunWait(@ComSpec & ' /c net stop "FLEXnet Licensing Service"',"")
ProcessClose ("FLEXnet Licensing Service")
EndFunc ;VISTA function END's here
Exit
#EndRegion ### VISTA ###

Using Global i dont get error saying var used before declaration but i still dont understand use of declaring variables so as you can see i am trying everything i can think of.

Thanks for trying to help. i really appreciate you trying to help caz i really need it.

Edited by Gettingsmarter

Share this post


Link to post
Share on other sites

From helpfile

The difference between Dim, Local and Global is the scope in which they are created:
Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)
Global = Forces creation of the variable in the Global scope
Local = Forces creation of the variable in the Local/Function scope

For example:

Global $var = 1
test()
MsgBox(0, "test",  "After test() has ran" & @CRLF & "This is 2 because we declared Global variable $var = 1 and then added 1 to it in the test() function prior to the test function declaring a local version." & @CRLF & "$nonglobal = " & $var)

Func test()
    $var += 1 ; This one will be applied to the global $var
    Local $var = 1
    $var += 10 ; This will be added to the declared local variable $var which is different than the global version of $var
    MsgBox(0, "test",  "Inside test() function (after the local version of $var was declared." & @CRLF & "This is 11 because we declared the lacal $var = 1 and then added 10 to it." & @CRLF & "$var = " & $var)
EndFunc

Share this post


Link to post
Share on other sites

From helpfile

The difference between Dim, Local and Global is the scope in which they are created:
Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)
Global = Forces creation of the variable in the Global scope
Local = Forces creation of the variable in the Local/Function scope

Thanks. Is this something that would help me to solve my problem ?

If so, i dont see how :D

Thanks for the INFO but i already knew it from help file.

Ok lets make it simpler

that button script has 3 functions in it. I need to find the way to wrap all those 3 functions into one big function and then when button is pressed, execute that big function.

can u give me couple of examples how func works ?

Examples like:

func main()
if something then
1() ;first function
elseif somethingelse then
2() ;second function
elseif somethignese then
3() ;thiord function
endfunc

func 1()
endfunc

func 2()
endfunc

func 3()
endfunc

This is how i have it setup but as soon as i load main script nothing happens

As you can see i have 3 functions.

Main tells where to go from there but only if main function is executed which is not the case.

I dont understand why it doesnt work

by looking at this code i my self find it imposible to work and it makes ton of sense to me so it has to work but it doesnt.

when main script executed, it does nothign at all and just exits without any errors :D

Thanks for trying to help

Share this post


Link to post
Share on other sites

that button script has 3 functions in it. I need to find the way to wrap all those 3 functions into one big function and then when button is pressed, execute that big function.

Sure no problem.

If this is the file we are including:

Func one()
    ;function one actions
EndFunc

Func two()
    ;function two actions
EndFunc

Func three()
    ;function three actions
EndFunc

We could call all three functions from our main script like this:

...
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $button1
            one()
            two()
            three()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch;### Tidy Error -> while is never closed in your script.
WEnd
...

Or if you want you could just modify our included file to have a single function that calls all three, like this:

Func one()
    ;function one actions
EndFunc   ;==>one

Func two()
    ;function two actions
EndFunc   ;==>two

Func three()
    ;function three actions
EndFunc   ;==>three

Func AllInOne()
    one()
    two()
    three()
EndFunc

Then we just need to call the AllInOne() function and one() two() and three() will be ran.

Share this post


Link to post
Share on other sites

Sure no problem.

If this is the file we are including:

Or if you want you could just modify our included file to have a single function that calls all three, like this:

Then we just need to call the AllInOne() function and one() two() and three() will be ran.

ok i got it

i had exit before endfunc lol

i am very sorry for being so blind.

Thanks man i have learned so much thanks to you.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0