Get path to .wbt script file?

Started by ltwert, March 30, 2015, 03:19:09 PM

Previous topic - Next topic

ltwert

I have searched the forums and tech support areas, but have not found anything about what I would believe is an obvious question:

Is there a way to get the path to the currently executing .wbt file? 

Or if it is compiled, to get the path to the .exe file?

Thanks...

JTaylor


td

DirScript is, of course, documented in the WIL Consolidated Help file.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

DirScript() returns a directory, which is not exactly the same thing as the path to the .WBT.

Surely, we are overlooking IC(1004) here, are we not?

kdmoyers

Agreed,
IntControl(1004,0,0,0,0) is what I use
The mind is everything; What you think, you become.

td

Quote from: snowsnowsnow on April 02, 2015, 03:33:21 PM
DirScript() returns a directory, which is not exactly the same thing as the path to the .WBT.

Surely, we are overlooking IC(1004) here, are we not?

In computing the term 'path' can be used to indicate either the directory (folder in MSFT speak) location of a file (absolute or relative) or a full file system location which includes a file root name and any extension. DirScript returns the former and IntControl 1004 returns the latter.

Basically, DirScript  removes the necessity of calling FilePath  on the returned result from IntControl 1004 .

The OP's post could easily be interpreted as indicating the need for either return result.  Since the OP never responded to the Jim's original reply, perhaps DirScript provided the desired result. Or perhaps the OP notices the reference to IntControl 1004 in the documentation for  DirScript and used that instead.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

Yes, you are right.  Either interpretation is possible.

I just assume, based on my own experience, that wanting the full filename, not the directory, is the more common request.

Personally, I think if it was the directory that was being sought, the request would have been worded differently.

But that's just me...

stanl

Quote from: snowsnowsnow on April 03, 2015, 10:30:32 AM
Personally, I think if it was the directory that was being sought, the request would have been worded differently.

lol.  Reminds one of Stackoverflow.

snowsnowsnow

I don't know what that means.

(But then again, I've never used "Stack Overflow")

ltwert

DirScript is what I was looking for, and IntControl(1004 is also interesting for the future.

Thanks everyone!

DAG_P6

Quote from: ltwert on April 13, 2015, 09:21:56 AM
DirScript is what I was looking for, and IntControl(1004 is also interesting for the future.

Since it returns the whole path, I prefer IntControl(1004, because once call gets a string from which the path and the program name are easily extracted.
David A. Gray
You are more important than any technology.

td

When you need the script's full path with file name and extension call IntControl 1004.  When you need the script's path call DirScript. There is no reason to prefer one over the other because there is no advantage to parsing the path component from the IntControl 1004 return value yourself instead of calling DirScript.

The only time where it might be better to use IntControl 1004 for the path is a case where you need to pass both script name and path information to another script or executable. Even in that case, the advantage of using IntControl 1004's would depend on how you passed the info.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

I usually save both in my startup code, so that I have the program name for use in the message box caption, and the path for finding satellite files.
David A. Gray
You are more important than any technology.

td

Then you can use both DirScript and IntControl 1004.  With Dirscript you can use the path without having to worry about variable scope or alternatively having to reparse.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

That's why I've started establishing pointers to them. Nevertheless, for small routines that I want to keep lean and mean, I use dirscript.
David A. Gray
You are more important than any technology.

td

WinBatch pointers are expensive and add complexity to a script. There are reasons for using them but, IMHO, when you have a function like DirScript, this isn't one of them.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

Quote from: td on May 02, 2015, 09:02:34 AM
WinBatch pointers are expensive and add complexity to a script. There are reasons for using them but, IMHO, when you have a function like DirScript, this isn't one of them.

Since I suspected as much, I've gone back and forth mentally about that. Thanks for confirming my guess.
David A. Gray
You are more important than any technology.