Jump to content
Sign in to follow this  
Chimaera

#include and other scripts

Recommended Posts

Chimaera

I have a script im working on where i have modules that i can change to give it different programs

a module consists of

A detection section where it decides whether the app is up to date etc

An install section where it has the actual install code and params

And a update section for updating from the net

There is only 5 programs in the program at a time and copy and pasting diff programs in an out is prone to copy errors and mistakes

So i wondered if i can use the modules by using the #include section to load the 5 modules i need.

How do i write it so the sections from the module appear in the right sections in the main script?

Do i wrap them in an variable and just add that at the point of the script i need it?

Can this be wrapped in that way? e.g install section below

$CBoxStatDTL = GUICtrlRead($CBoxDTL)
    If $CBoxStatDTL = $GUI_CHECKED Then
     SplashTextOn(" Installing ", " DAEMON Tools Is Being Installed ", 300, 50, -1, -1, 0, "Tahoma", 10, 600)
     ShellExecuteWait(@ScriptDir & "\file_includes\down_daemon.exe", IniRead(@ScriptDir & "\file_includes\support\updates.ini", "DTL", "Switch_0", "Not Found"))
     Sleep(1500)
     SplashOff()
     GUICtrlSetData($DTL_check, "Up To Date")
     GUICtrlSetState($CBoxDTL, $GUI_UNCHECKED)
    ElseIf @error Then
     MsgBox(48, "Error", $DTL_name & " Install Failed", 2)
    EndIf
    Sleep(500)

Or do i make that one module and have three for each product?

Any advice

Share this post


Link to post
Share on other sites
BrewManNH

What you're asking for isn't clear, so I'm not sure I'm answering what you're asking. If you want to know if you can conditionally use #include in sections of your script, then the answer is no. All #include statements are processed before the script is run, and when compiled, they're added at where ever in the script you place the statement, then the script is compiled.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Chimaera

Ok ill try and explain more clearly

I get these ideas and they drive me nuts on how to do it

Main Script goes like this

includes etc

gui stuff

detection section

Module 1a

Module 2a

Module 3a

Module 4a

Module 5a

[While loop]

install stuff

Module 1b

Module 2b

Module 3b

Module 4b

Module 5b

update stuff

Module 1c

Module 2c

Module 3c

Module 4c

Module 5c

[End of while loop]

Functions etc

Each program has 3 parts to a module

To change a module like the one i posted earlier i have to copy the module section and for eg paste it here so it changes the program in the script plus the two other sections

includes etc

gui stuff

detection section

Module 1a

Module 2a

Module 3a

Module 4a

Module 5a

[While loop]

install stuff

Module 1b

Module 2b

Module 3b <<<<<<<<<<<<<<

Module 4b

Module 5b

update stuff

Module 1c

Module 2c

Module 3c

Module 4c

Module 5c

[End of while loop]

Functions etc

Overwriting the previous one this is not a healthy way because it has an high error factor

So what i wondered is can i do it this way

Main Script

includes etc

gui stuff

detection section

Module 1a

Module 2a

Using #includes Link to Module 3a

Module 4a

Module 5a

[While loop]

install stuff

Module 1b

Module 2b

Using #includes Link to Module 3b

Module 4b

Module 5b

update stuff

Module 1c

Module 2c

Using #includes Link to Module 3c

Module 4c

Module 5c

[End of while loop]

Functions etc

Module 3 script

Module 3a

Module 3b

Module 3c

$Module_1a ;  <<<<<<<<<<<<<  or should this be a function??
$CBoxStatDTL = GUICtrlRead($CBoxDTL)
    If $CBoxStatDTL = $GUI_CHECKED Then
     SplashTextOn(" Installing ", " DAEMON Tools Is Being Installed ", 300, 50, -1, -1, 0, "Tahoma", 10, 600)
     ShellExecuteWait(@ScriptDir & "\file_includes\down_daemon.exe", IniRead(@ScriptDir & "\file_includes\support\updates.ini", "DTL", "Switch_0", "Not Found"))
     Sleep(1500)
     SplashOff()
     GUICtrlSetData($DTL_check, "Up To Date")
     GUICtrlSetState($CBoxDTL, $GUI_UNCHECKED)
    ElseIf @error Then
     MsgBox(48, "Error", $DTL_name & " Install Failed", 2)
    EndIf
    Sleep(500)

So the main script calls the others or the relevant parts when needed and requires no copy and paste

And as an after thought when you compile do the includes get included within the exe?

Does that make any sense?

EDIT

Yes its possible although i seem to have to Global all the variables in the module as that doesnt seem to carry across

Ill have a play around with it and see what happens

It would be usefull to know if the includes get included into the main script on compile though

Edited by Chimaera

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  

×