Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-15-2010, 12:16 PM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
Macro with Special Characters

I have a script that needs to modfiy a setup project. Its updating the default install location.

The value I want to enter is the following:
[ProgramFilesFolder][Manufacturer]\\[ProductName]

I have doubled up the special characters when the value of the macro is set, but when I place the values back into the file its getting evaluated to many times. First when its set, then when I use a regex to place it back in the file. I have had to more than double up on the special characters. See attached file

Any advice?
Attached Files
File Type: zip clientsetup.zip (10.8 KB, 1138 views)
Reply With Quote
  #2  
Old 06-15-2010, 12:24 PM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
Watching the values of the characters as the script runs, the \ doesnt change throughout all the calls but the [ or the ] has to be doubled and doubled again.
Reply With Quote
  #3  
Old 06-16-2010, 05:28 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
[ and ] in Visual Build denote a script expression (see http://www.kinook.com/VisBuildPro/Ma...ecialchars.htm). [[ and ]] specify literal square bracket characters. The value of the TMP_DL_VD_PATH macro ([ProgramFilesFolder][Manufacturer]\[ProductName]\CHANGE) is being evaluated in multiple places, requiring a doubling for each evaluation:
1) When assigning the TMP_DL_VD_PATH macro value in the Subroutine Call step 'Modify Client Setup'
2) When expanding the %TMP_DL_VD_PATH% reference in the 'Modify Folder Section->Modify Search Results' subroutine step
3) When expanding the %TMP_SEARCH_RESULTS% reference in the Apply Modified Search step
Reply With Quote
  #4  
Old 06-17-2010, 07:45 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
But the part I am having an issue with is why is the [[ behaing this way but the \\ are not? I would expect as they were passed between values to not be evaulated becuase they are doubled as with the \\?
Reply With Quote
  #5  
Old 06-17-2010, 07:50 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
That is required by the regex engine (in both the Modify and Apply steps) to treat as a literal \ character.
http://zez.org/article/articleprint/11/
Reply With Quote
  #6  
Old 06-17-2010, 07:54 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
Right thats my point, if I only have to double the slashes once and it works through all these calls then why do I have to triple the amount of times doubling for the [[.

According to you statement about the three diffenent evaluations, that I would have to triple the [[ as well as the \\. Why do the regex litirals get evaluated diffently then the scipt literals?
Reply With Quote
  #7  
Old 06-17-2010, 08:13 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
It appears that the first regex replace does not require escaping?

You can prevent the first evaluation of [ ] by unchecking 'Expand macros in parameter values before calling subroutine' in the Subroutine Call step (but then you can't reference macros like %PROJDIR% in other parameters; another option would be to use the Set Macro action for the TMP_DL_VD_PATH macro [with 'Don't expand' checked]).

You can prevent the 2nd evaluation of [ ] by replacing

%TMP_DL_VD_PATH%

with

" & vbld_TempMacros()("TMP_DL_VD_PATH") & "
Reply With Quote
  #8  
Old 06-17-2010, 09:09 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
I found some interesting behavoir:

1. If I double the [ once so that the value of a macro is [[Program Files]] when assigning it to another macro it gets evaluated to [Program Files], which is what I expect.

2. But if I have an inital value in one macro [Program Files] and when I assigen it to another macro it still evaluates to [Program Files].

This is all before the value is writen to a file I was checking the temporary macro values as it progressed, is that supposted to happen or should it be evaluated in the second example when its assigned to another macro.
Reply With Quote
  #9  
Old 06-17-2010, 09:18 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
It depends on how you're assigning the value (for instance, within a VBScript variable assignment, special VBP chars aren't evaluated, but when expanding a reference like %MACRO_NAME% in a step field, they are). Attach your project.
Reply With Quote
  #10  
Old 06-17-2010, 09:27 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
There are two scripts both the same execpt for in the the 'Modify Folder Section->Modify Search Results' One has the first replace commented out and the other does not. But they both evaluate to the same result.

But if I use the % doesnt evealuate teh same way as the [ or the ].
Attached Files
File Type: zip clientsetup.zip (17.4 KB, 1109 views)
Reply With Quote
  #11  
Old 06-17-2010, 10:30 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
The %TMP_DL_VD_PATH% reference is expanded before the code is fed to the script engine and executed (and the macro value modified).
http://www.kinook.com/VisBuildPro/Ma...ecialchars.htm
Reply With Quote
  #12  
Old 06-17-2010, 10:36 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
But what about the other example were the code was commented and I get the same result?
Reply With Quote
  #13  
Old 06-17-2010, 10:45 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
The script code does not affect the expanded value of %TMP_DL_VD_PATH% that is fed to the script engine (since the value is expanded *before* the script code is executed).
Reply With Quote
  #14  
Old 06-17-2010, 11:36 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
So i understand this it will evaluate the macro's and escape characters but will not evaluate the script code untill it, in my example is writen to the file. that would explain why I can comment out the two lines of code and both would work, is that correct?
Reply With Quote
  #15  
Old 06-17-2010, 11:00 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
Close. When the Modify Search Results steps builds, the sequence is:
1) Recursively expand any macro references (i.e., %TMP_DL_VD_PATH%) and script expressions ([code]) in the script code field.
2) Execute the script code. The code modifies the TMP_DL_VD_PATH macro, but the macro reference above has already been replaced with the previous macro value.

The next step replaces text in the file with the contents of the macro value TMP_SEARCH_RESULTS.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 11:23 AM.


Copyright © 1999-2023 Kinook Software, Inc.