As I indicated in the subject line, I've found a work-around that is not particularly inconvenient. However, I do wonder why the situation is happening in the first place. So I will illustrate with an annotated "dump" of a complete TCC session:
This is a much cut-down version of the "real" function which has some error handling and "special case" functionality which I've "stripped out" for demonstration purposes. As can be seen I am defining a rather simple function "ReplaceChar" that replaces the character in the string supplied as parameter one to the function by the string supplied as parameter three to the function at the position specified by parameter two to the function. (I will note here that the "position" is 1-based as opposed to 0-based as is true of many of Rex's built-in functions.)
The first example, which is a little bit "odd" but not at all a problem because it can easily be "worked around" (by putting the third parameter in double quotes):
The second example showing that the previously-mentioned "work around" does, in fact work:
The third example, where the previously-mentioned "work around" absolutely did not work (at all):
As you can easily see in the above, the "D" was eliminated but absolutely no spaces were inserted in the character string at its former position.
And finally, the one that "worked" (by surrounding parameter three with back-quotes):
The question is "Why is that needed?" or maybe "Why dosn't the third example work?".
Code:
Fri Dec 2, 2011 12:59:12p
ISO8601 plugin v1.1.1 loaded.
SafeChars plugin v1.5.7 loaded.
TCC 12.11.76 Windows 7 [Version 6.1.7601]
Copyright 2011 Rex Conn & JP Software Inc. All Rights Reserved
Registered to Daniel Mathews
[Z:\]Function ReplaceChar=`%@Left[%@Dec[%2],%@UnQuote[%1]]%@UnQuote[%3]%@Right[-%2,
%@UnQuote[%1]]`
The first example, which is a little bit "odd" but not at all a problem because it can easily be "worked around" (by putting the third parameter in double quotes):
Code:
[Z:\]Echo %@ReplaceChar[ABCDEF,4,This Will Replace the Fourth Character]
ABCThisEF
Code:
[Z:\]Echo %@ReplaceChar[ABCDEF,4,"This Will Replace the Fourth Character"]
ABCThis Will Replace the Fourth CharacterEF
Code:
[Z:\]Echo %@ReplaceChar[ABCDEF,4," "]
ABCEF
And finally, the one that "worked" (by surrounding parameter three with back-quotes):
Code:
[Z:\]Echo %@ReplaceChar[ABCDEF,4,` `]
ABC EF