FIX: Transform on String Greater Than 255 Crashes VFP 6.0 (190792)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q190792 SYMPTOMS
Microsoft Visual FoxPro causes an exception error when using the Transform() function
to transform a string greater than 255 characters.
RESOLUTION
The following workaround should work for strings of arbitrary length and
has being tested with "@!" picture.
Sample Code
CLEAR
m.string = REPLICATE("HelloWorld", 26)
? "Initial string length: ", LEN(m.string)
m.string = transgt255(m.string, "@!")
? "Return value from function: ", m.string
? "Length of returned string: ", LEN(m.string)
* Function TRANSGT255
* Purpose: Apply a string transformation to a string longer than 255
* characters passed: string to transform (lcText), transform string to
* apply (lcTransType).
* Returns: Transformed string (lcRetString).
FUNCTION transgt255
PARAMETERS lcText, lcTransType
* Define a string length safely smaller than 255, doesn't matter for
* these purposes.
#DEFINE MAX_LENGTH 253
liNumPasses = INT(LEN(lcText) / MAX_LENGTH)
liLastPass = MOD(LEN(lcText), MAX_LENGTH)
lcRetString = ""
FOR i = 1 TO liNumPasses
lcWorkString = SUBSTR(lcText, (i - 1) * MAX_LENGTH + 1, MAX_LENGTH)
lcRetString = lcRetString + ;
TRANSFORM(lcWorkString, (lcTransType))
NEXT
lcWorkString = RIGHT(lcText, liLastPass)
lcRetString = lcRetString + ;
TRANSFORM(lcWorkString, (lcTransType))
RETURN lcRetString
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Visual Studio 6.0 Service Pack 3.
For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base: 194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
Modification Type: | Minor | Last Reviewed: | 3/1/2005 |
---|
Keywords: | kbBug kbfix kbXBase KB190792 |
---|
|