|
#1
|
|||
|
|||
Conditional Text Search
Is there a function built into Visual Build Pro that will perform a text search on a file and based on the results, allow me to make a conditional decision?
If not, any recommendations or has someone done something similar? Thanks, Mark |
#2
|
|||
|
|||
The attached sample shows one way to achieve this.
|
#3
|
|||
|
|||
Grettings!
I tried to combine the posted sample with a process files action (essentially, I am looking for the string "Client.dll" in a set of txt files), but am running into a syntax error. Here is the conditional build rule: [InStr(vbld_FSO().OpenTextFile(%PROCFILES_FULLPATH% ).ReadAll(), "Client.dll") > 0] and here is the output: Building global subroutine step 'get all csproj files'... Loading a list of matching files... Processing file 1 of 34: n:\netsource\buildlist114.txt Building global subroutine step 'Write File'... Error expanding macros in property condexpr: <Error at Line 1, Column 32 (Expected ')') Code: InStr(vbld_FSO().OpenTextFile(n:\netsource\buildli st114.txt).ReadAll(), "Client.dll") > 0> Build ended. I threw some single quotes around %PROCFILES_FULLPATH% but that caused: Building global subroutine step 'get all txt files'... Loading a list of matching files... Processing file 1 of 34: n:\netsource\buildlist114.txt Building global subroutine step 'Write File'... Error expanding macros in property condexpr: <Error at Line 1, Column 31 (Syntax error) Code: InStr(vbld_FSO().OpenTextFile('n:\netsource\buildl ist114.txt').ReadAll(), "Client.dll") > 0> Build ended. Any ideas? |
#4
|
|||
|
|||
Try using double quotes rather than single to delimit the string.
|
#5
|
|||
|
|||
I thank you for the quick response;
[InStr(vbld_FSO().OpenTextFile("%PROCFILES_FULLPATH %").ReadAll(), "Client.dll") > 0] was indeed all that I needed. I had tried that initally, but had been thrown when I saw the output Step 'Write File' build rule evaluates false: [InStr(LCase(vbld_FSO().OpenTextFile("%PROCFILES_FU LLPATH%").ReadAll())... as I thought the %PROCFILES_FULLPATH% was being evaluated literally as a string, but this was not the case. Works like a charm now, thanks again! --jdavidi |
#6
|
|||
|
|||
The value is shown without macros/script expanded to provide more debug info. Otherwise it would only show the result of evaluation (i.e., "evaluates false: False" or "evaluates true: True").
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|