View Full Version : How to retrieve and parse current directory?
jeffnc
09-07-2007, 09:34 AM
Basically what I'd like to do is retrieve part of the current directory name. For example, if the directory (that the Visual Build Pro .bld file exists in) is
C:\whatever\dir 1234 abcd
what I'd like to get is "1234". So first, I need a way to retrieve the dir name and then I need a way to parse it. Thanks.
kinook
09-07-2007, 10:02 AM
[vbld_FSO.GetBaseName("%PROJDIR%")]
will give you the directory name of the current .bld file.
It's not clear exactly how you want to parse the value (first item found after a space, first set of digits, etc.). To retrieve the first value between spaces, use
[Split(vbld_FSO.GetBaseName("%PROJDIR%"))(1)]
The code above assumes VBScript is set as the default script language.
jeffnc
09-07-2007, 10:23 AM
OK thanks. So 2 more questions.
What step type would I create to put your code in?
For parsing, it looks like it can be this simple.
blah blah blah 1.2.3.4
I want 1.2.3.4, so it could be as simple as getting the last "token", or whatever comes after the last space.
kinook
09-07-2007, 10:37 AM
Originally posted by jeffnc
What step type would I create to put your code in?
It depends on what you want to do with the parsed value. You might just use the expression inline in the field(s) that need it. Or you could assign it to a macro (via a Set Macro step or by using the expression as the value of a macro) and use the macro as needed.
For parsing, it looks like it can be this simple.
blah blah blah 1.2.3.4
I want 1.2.3.4, so it could be as simple as getting the last "token", or whatever comes after the last space.
[Mid("%PROJDIR%", InStrRev("%PROJDIR%", " ")+1)]
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.