![]() |
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 |
1 Attachment(s)
The attached sample shows one way to achieve this.
|
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: 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: Build ended. Any ideas? |
Try using double quotes rather than single to delimit the string.
|
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_FULLPATH%").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 |
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").
|
All times are GMT -5. The time now is 02:37 AM. |
Copyright © 1999-2023 Kinook Software, Inc.