AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with included files having function definitions

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Krogdor



Joined: 18 Apr 2008
Posts: 903
Location: The Interwebs

PostPosted: Fri May 30, 2008 3:33 am    Post subject: Problem with included files having function definitions Reply with quote

Well, I have had this problem for quite some time, although before it has always been intermittent, although it would require removing the include file, and of course, going through and commenting out anywhere that calls functions from that file... ><
Annoying, but I could live with it.

However, now it has become... more serious. Recently it happened more often, and now no matter what I do I cannot get it to load. If I remove one function library, it returns the error from a different one, and when I remove them all then put them back (as has fixed it in the past) I still receive the same error:

The Error Message wrote:

Error at line 30 in #include file "C:\Users\***\AutoHotkey\Lib\CommandFunctions.ahk".

Line Text: IfBetween(ByRef var, LowerBound, UpperBound)
Error: Functions cannot contain functions.

The script was not reloaded; the old version will remain in effect.



When the include file is:
Code:
CommandFunctions()
{
return, true
}

IfBetween(ByRef var, LowerBound, UpperBound)
{
   If var between %LowerBound% and %UpperBound%
      Return, true
}

I believe that the script is somehow not recognizing the closing brace on the first function, therefore believing a function is defined within another function; however, even adding extra closing braces (which fixed it once in the past) has no effect. I have also tried completely ending the process on all AHK instances then restarting them to no avail.

This is quite serious for me, since at the moment I cannot use my script at all, and I rely on it for quite a few things... ><

Has anyone else experienced this, or know a way to fix it?


EDIT: Well, I forgot to mention that it was actually a file in my library file called by a function, and including it rather than using the library fixed the problem! However, this leads me to believe that AHK was, for some reason, making the entire included file into a function (i.e. if I called the function/file CommandFunctions(), instead of just including the file it did it as
Code:
CommandFunctions() {
file goes here
}


This assumption is supported by the fact that even a function-called file with only one function inside was getting the problem.


So, basically, the bug is now this: files included through a library call are --possibly--read as a single function definition encompassing the whole file.


Last edited by Krogdor on Sat May 31, 2008 12:20 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
[VxE]



Joined: 07 Oct 2006
Posts: 1125

PostPosted: Fri May 30, 2008 4:47 am    Post subject: Reply with quote

Well, first off, this thread should be in 'ask for help'.

What you could do is this: seperate all of your functions into separate files, then make sure that each one has balanced {}, then use another file with nothing but #Include lines, then have your scripts include that one file.

Alternatively, you can have each function in its own file and put them in a library.
_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 903
Location: The Interwebs

PostPosted: Fri May 30, 2008 5:12 am    Post subject: Reply with quote

[VxE] wrote:
Well, first off, this thread should be in 'ask for help'.

Well, since I'm not doing anything wrong, wouldn't this be considered a bug...? Anyway, if it does belong in Ask for Help, I am sorry.


And I suppose I can try putting each function in a separate file, although that does become a bit tedious and complicated with so many different files... However I suppose that has to fix the problem, so I'll try it out.
Back to top
View user's profile Send private message AIM Address
corrupt



Joined: 29 Dec 2004
Posts: 2397

PostPosted: Sun Jun 01, 2008 7:05 pm    Post subject: Reply with quote

Could you please give a complete example so that we could try to reproduce the error? It might just be me reading through too quickly but I don't fully understand your explanation so far...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group