Kinook Software Forum

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

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-05-2005, 03:23 PM
pjaquiery pjaquiery is online now
Registered User
 
Join Date: 01-19-2003
Location: Dunedin, New Zealand
Posts: 114
Quoting problem or bug?

I'm using a JScript regex replace to provide a value in a step as:

['%str%'.replace (/L"([[^"]]+?)"/, '$1')]

which fails to match my test string L"wanted text". However:

['%str%'.replace (/L"(.+?)"/, '$1')]

matches as expected.

Is this a quoting problem that I've forgotten about, or is there something else going on here? A sample project is attached.
Attached Files
File Type: bld regexissue.bld (951 Bytes, 1274 views)
Reply With Quote
  #2  
Old 12-05-2005, 08:56 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
The behavior is by design. The order of processing of field values is:

Repeat 1a/b until no macro or script references remain:
1a) Expand macro references to the actual value. For instance %STR% -> L"wanted text" or %DOSCMD% -> %COMSPEC% /C

1b) Evaluate any script expressions (code between single bracket chars).

2) Convert any double bracket chars to single ([[ -> [ and ]] -> ]).

So at the point that the JScript expression is evaluated, the code that is fed to the script engine is

"'L"wanted text"'.replace(/L"([[^"]]+?)"/, '$1')"

The reason for processing in this order is to support nested script expressions and macros (script expressions and macros can expand to other scripts expressions and/or macros ad infinitum).

A couple alternatives:

1) Move the .replace code into a script function in Project or Global scripts and call it from the script expression.

2) Use a Run Script step instead of a Set Macro step (brackets aren't special in a Run Script step since the code field is already treated as script):

Application.Macros(vbldMacroTemporary).Add("Str", '%STR%'.replace(/L"([^"]+?)"/, '$1'));
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 04:53 PM.


Copyright © 1999-2023 Kinook Software, Inc.