AutoHotkey Community

It is currently May 27th, 2012, 1:15 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: April 22nd, 2005, 1:23 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi,

is it possible to prevent stopping a script, when a inlcude is not found? I thougt about extending a script with a include. If the extension-file does not exist, the script should run without that extension.

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2005, 10:37 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Most of the time one would want such an error to occur, since #Include files are sometimes critical to operation. However, since it seems that there's no other way to avoid this, perhaps a new directive could be added, or a new parameter to the existing one (like "ignore"). Even better, there could be a directive case structure like that found in some scripting languages, where an ahk command capable of returning true or false is pre-executed. See example below. But maybe that's going a little too far. :D

Code:
#If IfExist,Lib1.ahk
#Include Lib1.ahk
#EndIf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2005, 1:26 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Since file names can contain real commas, additional parameters can't be added to #include without breaking existing scripts. Also, adding a new directive for this (such as #IncludeIgnore) seems unwarranted.

The remaining option is to support a prefix such as *i in front of the filename to ignore loading problems.

What kind of alternate behavior are you trying to achieve? Perhaps it can be done by means other than a conditional Include. If not, it could probably be done by having a master script that rewrites the top line of a dependent script and then runs that script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2005, 12:41 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi Chris,

I have a masterscript which can be extendend by the include-file. the include-file itself only has other includes which will load the extensions. May aim is, that no one has to modify the masterscript but can extend it with own functions. The advantage of the includes is, that they will be compiled. An option to ignore includes if the file was not found would be very great and is solving my problems.

Tekl[/b]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2005, 3:39 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
This capability has been added in the latest release. Please let me know if you have any problems with it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2009, 9:07 pm 
Offline

Joined: February 3rd, 2009, 12:43 am
Posts: 11
Location: Abbotsford, BC, Canada
Chris wrote:
This capability has been added in the latest release. Please let me know if you have any problems with it.


The help file still says you cannot have a conditional #Include. Has this changed ever?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2009, 9:08 pm 
Online
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
j0dan wrote:
Chris wrote:
This capability has been added in the latest release. Please let me know if you have any problems with it.


The help file still says you cannot have a conditional #Include. Has this changed ever?

Code:
#include *i fooBar.ahk
works even if the file is not present.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2009, 9:23 pm 
Offline

Joined: February 3rd, 2009, 12:43 am
Posts: 11
Location: Abbotsford, BC, Canada
Thanks fincs!

Somehow I missed that in the help file. :X


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group