|
#1
|
|||
|
|||
Odd JScript behaviour
If I use
["/samplestring/".replace (/[[\\\/]]$/, "")] as the Value: for a Set Macro step the macro is set to /samplestring/ and is also shown in the mouseover tool tip with shift down. If I use the immediate pane in the Script Editor to evaluate: "/samplestring/".replace (/[\\\/]$/, "") I get: /samplestring What am I missing here? Update: replace (/(\\|\/)$/, "") works around the problem Last edited by pjaquiery; 01-23-2006 at 06:44 PM. |
#2
|
|||
|
|||
The first result is due to how macros and script are processed in a field values (see http://www.kinook.com/Forum/showthre...?threadid=1383). When evaluated (in the build or with Shift down over a field), the by-design behavior applies to the expression containing nested literals [[...]].
But when code is evaluated in the Immediate window, this extra processing is not performed (the value entered is treated as the script code to evaluate and no additional processing of nested script expressions or literal [[ ]] is performed). |
#3
|
|||
|
|||
I keep getting bitten by this don't I?
Is it possible (and sensible) to detect the context where this happens and generate a warning? |
#4
|
|||
|
|||
There's no easy way to do that without potentially breaking other existing projects. It is doing the wrong thing in your situation, but it's possible for the result to be correct in other scenarios. For compatibility, the evaluation still needs to return the value it currently does (and not an error message instead). You could run all your .bld files through the attached project to identify problem field values (I apologize for using *spit* VBScript for the sample :^).
|
|
|