Sign in to follow this  
Followers 0
Velnes

#include (adding diff .au3 into gui)

7 posts in this topic

hi again im here with a different topic

umm i cant figure out how to do this :

this is example dont mind all code :)

$gui = guicreate("")
$button = guictrlcreatebutton("", xx,xx,xx,xx)

while 1
switch guigetmsg()
case $button
#include <my other file.au3>
endswitch
wend

so when pressing button... the #include file would create an input box or something in this current $gui not in the other file... :)

i dont know how else to explain ... i tryed this #include thing few ways but everytime i just get error at that line

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

case $button
#include <my other file.au3>
endswitch

I made this same mistake before. You can't put an #include statement within a block statment (case, func, if-then, etc...), and there is no way to do a conditional #include.

All #include statements will be replaced by the contents of the include file BEFORE any code is executed.

Edited by willichan

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You put the code that creates the inputbox (or Whatever) in a function in the include file. The include file should have the line #Include-Once at the top of it.

Now you move that #Include line to the top of the script. If it's a local file and not one in your AutoIt\Include\ folder then use the Quote method.

#Include "<path>\my other file.au3"

Where you now have the #Include<my other file.au3> line, replace it with a function call to bring up the inputbox.

EDIT: I should have mentioned that #Include is a pre-processor directive so you can't call it in a loop like you did.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Move the #include line to the top of the script. When the script is started the file is included. AutoIt does not support conditional includes.

In your case statement you have to call a function thas is included with <my other file.au3>


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ok thank you all i got it now :) thnx very much

Share this post


Link to post
Share on other sites

hmm i tryed with calling func

and put in func the #include but not working at all :)

maybe i understood u wrong :)

but isnt there anyway to do sumtin like that?

coz i want like when u press button then add into the $gui an edit box or inputbox or anything :P

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You DO NOT put the #Include in the Include file

You DO NOT use #Include in a loop.

#Include is a pre-processor directive and the file must only be #Included once, preferably at the top of the script.

Your include file can be as simple as this.

#Include-Once
Func _Run_InputBox()
   Local $sStr = InputBox("My Input Box", "Enter whatever you want")
   Return ($sStr)
EndFunc

Then Call the FUNCTION in the loop, NOT the file.

#Include "C:\Some\Folder\my other file.au3"
$gui = guicreate("")
$button = guictrlcreatebutton("", xx,xx,xx,xx)

While 1
   Switch guigetmsg()
       Case $button
           $s_Rtn = _Run_InputBox()
           MsgBox(4096, "Result", $s_Rtn)
   EndSwitch
WEnd

All clear now?

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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