Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: #include Include Call Library 111 execution error encrypted encoded verification failed
;; Create an file to include strData = "#definefunction foo()":@CRLF strData = strData:"Message('In Foo', 'Bar')":@CRLF strData = strData:"#endfunction":@CRLF FilePut( "foobar.wbt", strData ) x = 1 If x == 0 #Include "foobar.wbt" EndIf ;; Errors if foobar.wbt contents not processed. (IT IS ALWAYS PROCESSED BEFORE THE SCRIPT EXECUTES ITS FIRST LINE) foo() FileDelete("foobar.wbt")
I have built a function framework in Winbatch with about 40 function libraries (from low-level to high-level function libraries), where the high-level libraries use functions of the low-level libraries (and therefore include these scripts).
As different high-level libraries include the same low-level libraries (eg. logging, file operations, ...), a main script that includes some of these high-level libraries (indirectly) includes the low-level libraries several times.
The way I do this is a clean solution (data encapsulation, independent modules), but it has become a performance issue: Including one (very, very) high-level library now takes 28 seconds !!!
Helpful would be some sort of #ifndef or an intelligent WinBatch interpreter that checks the loaded scripts before executing another include.
To the support team: Could something like that be integrated into one of the next versions of WinBatch?
To all: I am thinking of refactoring the framework and switching from #include to call (and checking if the script has been loaded before executing the call).What do you think about this "workaround"? What are the risks of doing so?
Short sample to illustrate this:
LibA includes nothing LibB includes LibA LibC includes LibA and LibB LibD includes LibA and LibC The main script includes LibD and LibB So the includes will be resolved like that: LibD,LibA,LibC,LibA,LibB,LibA,LibB,LibA - 8 includes for 4 librariesIn our framework this scenario explodes and leads to a timespan of 28 seconds for including one big library! Advantage of this architecture is the modularity - you just include those libraries your script will call directly. And I don't want to lose this advantage.
I have just written a small script that shall be called instead of #INCLUDEing the libraries. This script will check if the library to be included is already loaded (using IntControl(77,103, 0, 0, 0)). If not, the library will be loaded using Call. It was not as easy as it sounds, because I wanted to keep the advantage of modularity and therefore this script will be called recursively from every loaded library (and I had to make sure that the variable values within this script will not be overwritten when it is being called recursively).
But it seems to load all libraries and this just takes about 1 second!!! :-)
I still have to test this solution in detail, but it seems very promising...
There are at least two ways around the issue.
We are working on a solution. Until something better comes along, I guess you will have to stick to 'Call'.
My script looks like this:
addextender... #include "d:\\wbscriptb.wbt" ...bunch of other code setting up the ... dialog box..getting an answer switch case x call("wbscriptb"."") break ..rest of codeI then compile (99g) and the main menu comes up ok, but when i get:
111 execution error. encrypted/encoded verification failed.Then when I click on that msg it actually brings up the file i '#include'd, without going through the dialog and asking me to make a selection.
Is there something magic about #includes that they can't all be at the beginning of the program and then let me call them as i need them?
What i envisioned was just having all the includes at the beginning, like assembler language, then having one big module result.
CALL's in a compiled EXE cannot run RAW exe files (they have to be encoded into WBC's first).
if i do this: #include "d:\..\sname.wbc"
will i be able to do this: call("sname.wbc","")
or did the part about only being able to gosub only apply if i am copying in a raw wbt?
There is a problem in the definition of "referenced".
Consider the #include statement to be "executable". It is a line of code and it WILL execute just like all other lines of code.
If you include a WBC file it is executed right then and there. You cannot call the WBC file later in your script and expect it to have anything to do with the #include'd file.
Took the MAIN.exe to another system to run. I'm getting a 217 error saying it can't process the include file UDF_1.wbt.
Now I thought that anything #include'd was sucked in at compile time and therefore did not have to be present at runtime. I checked the docs but can't find any mention of this being different for UDFs.
Any idea what's happening?
Somehow I think it did not get properly included.
What happens is that there can be two attempts to process a #include.
On the first attempt it tries to suck it in and make it part of the script. However if that fails for some reason (improperly coded #include ), then later, at execution time if it sees a #include it kind of tries again. The second time it needs the file.
The second pass is more forgiving than the first pass.
-----
#include "filename":
Maybe put double quotes around the file name.
Article ID: W14216
Filename: Include Statements - How They Work.txt
File Created: 2013:02:15:09:21:34
Last Updated: 2013:02:15:09:21:34