WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Call Versus Include


There are some subtle differences between Call and #include:


Question:

I'm curious what differences there are betweene the Call and #Include in interpreted [not compiled] scripts. (i.e., that have been documented/known by the various WB experts over the years).

I can think of two:

  1. Call() is runtime, not interpret-time, so filenames are evaluated w.r.t. the current drive/directory at that point of execution, not at script launch time. For example, you can do: DirChange(DirScript())/Call("script","") and it will find the script in the same dir as the source code, regardless of where you are running the script from. As far as I know, there's no way to do this with #include.

  2. Since #include is textual, you could do a goto from within the #include'd script to a label in the parent script. As far as I know (haven't tested), you can't do this with Call() (with the standard caveat, of course, that you shouldn't want to...)
Are there any other artifacts of #include being strictly textual?

Answer:

Yes, that is pretty much it, the #include in the debugger cannot "reach out" of the #included file like a true #include can, but indeed, you should not do that anyway.

Ummm there is also that you can use %substitution% variables in Calls but not in #includes.

A corollary says you can do

#include %somefilenamevar%
in the WinBatch Studio debugged, not not in real Winbatch code. But you should not anyway.

In general, just because something works, does not make it recommended or a desirable programming technique. Indeed, there are horrible programming techniques that can be done that, well, work fine. Thankfully most people, when they find one, are sensible enough not to exploit it.


Article ID:   W16966
File Created: 2007:07:03:14:27:22
Last Updated: 2007:07:03:14:27:22