Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Odd JScript behaviour (https://www.kinook.com/Forum/showthread.php?t=1490)

pjaquiery 01-23-2006 05:27 PM

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

kinook 01-24-2006 10:39 AM

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).

pjaquiery 01-24-2006 01:46 PM

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?

kinook 01-24-2006 02:52 PM

1 Attachment(s)
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 :^).


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


Copyright © 1999-2023 Kinook Software, Inc.