BUG: Transform on String Greater Than 255 Crashes VFP 6.0ID: Q190792
|
Visual FoxPro causes an exception error when using the Transform() function to transform a string greater than 255 characters.
The following workaround should work for strings of arbitrary length and has being tested with "@!" picture.
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
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
lcText=REPLICATE("HelloWorld",26) ? LEN(lcText) ? TRANSFORM(lcText,"@!")
Fatal error: Exception code = C0000005 Called from - test line 3 {C:\FoxData\test.prg}
Additional query words: kbVFp600bug kbXBase kbvfp600
Keywords :
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 28, 1999