cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Snoopstah
Level 7

CharReplace function

Is there a bug in CharReplace Function?

When I run the following code I get the value '10-10-2007' in the first MessageBox and then "10" in the second MessageBox.

Instead of the string replaced with null values where ever there are "-" characters, the string seems to be cut.

This is not simply due to the MessageBox function as it is propogated throughout the installer.

GetSystemInfo(DATE, nvDate, svDate);
MessageBox ("svDate = " + svDate, INFORMATION);

CharReplace(svDate, STRTOCHAR(':'), STRTOCHAR('\0'), 0);
MessageBox ("svDate = " + svDate, INFORMATION);


How else can I go about replacing "-" with a "" or null value?
Labels (1)
0 Kudos
(2) Replies
Holger_G
Level 10

The '\0' character indicates an End of Line and null characters have special values within strings.

How about extracting substrings like this:
GetSystemInfo(DATE, nvDate, svDate);
MessageBox ("svDate = " + svDate, INFORMATION);

listID = ListCreate (STRINGLIST);
StrGetTokens (listID, svDate, "-");
nResult = ListGetFirstString (listID, svString);
svDate = "";
while (nResult != END_OF_LIST)
svDate = svDate + svString;
nResult = ListGetNextString (listID, svString);
endwhile;

MessageBox ("svDate = " + svDate, INFORMATION);
0 Kudos
Snoopstah
Level 7

Great. Thankyou.
0 Kudos