| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. Getting the name/path of the running script #1579 Posted by: 2003-01-31 01:53:38 Last edited by: Jeff Glatt 2007-07-13 00:20:28 (Total edited 1 time) | I want to get the path name of my main script (ie, the startup directory). PARSE SOURCE can be used to get the full name of my main script (and then I can break off the path).
Should there not be an . at the end of a PARSE instruction if parsing something into more than one var? (I notice you do not use this in your example). | 2. Re: Getting the name/path of the running script #1580 Posted by: Jeff Glatt 2003-01-31 05:43:16 Last edited by: Jeff Glatt 2007-07-13 00:24:16 (Total edited 1 time) | You normally don't need to know where your script is located. (When you call a child script, Reginald normally searches the same directory as the parent script. So you shouldn't have to worry about script paths). So, I don't know why you're trying to determine this location.
If you just want to know your script's "default directory", you can use the DIRECTORY() built-in function right at the start of your main script (before you call any function that could possibly change the directory, such as REXX GUI's file dialog).mystartdir = DIRECTORY() In this way, if the user creates a shortcut to the RPC-created EXE, and he enters a different "Start in" directory in the shortcut's properties, you'll pick that up. You want to be able to honor the user's setting for the "default directory" (and note that it could be different than the path to the EXE/script itself, not that this should matter.
As far as using a dot at the end of PARSE SOURCE, you should not do this. You want to grab all of the remaining characters in the last token which is the program name. This is very important if you have a script name that has spaces in it, which is allowed under Windows.
Consider if you have your script in the directory "C:Program FilesMyDirMyScript"
Now if you do:PARSE SOURCE .. scriptname Then scriptname will be assigned all of "C:\Program Files\MyDirMyScript".
But consider if you add an extra placeholder (ie, dot) at the end, like so:PARSE SOURCE .. scriptname . Now, the script's name gets broken off at the first space, and the remaining characters get tossed away. Your scriptname variable is now "C:\Program" and the " Files\MyDirMyScript" part gets tossed away because it is really the fourth token now, and your fourth item after PARSE SOURCE is that extra placeholder.
So never use an extra placeholder at the end of PARSE SOURCE. (Reginald's script launcher trims trailing spaces off of a script's name anyway, so you don't need to try to toss those away).
But for other uses of PARSE, if you really need to trim off any extra, trailing spaces or text, then yes, you should use an extra dot at the end. | Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|