View Full Version : Conditional Text Search
mvermeulen
08-27-2004, 08:46 AM
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
kinook
08-27-2004, 11:46 AM
The attached sample shows one way to achieve this.
jdavidi
01-14-2005, 05:38 PM
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?
kinook
01-14-2005, 06:20 PM
Try using double quotes rather than single to delimit the string.
jdavidi
01-18-2005, 06:11 PM
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
kinook
01-18-2005, 06:15 PM
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").
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.