Article ID: 190792
Article Last Modified on 3/1/2005
APPLIES TO
- Microsoft Visual FoxPro 6.0 Professional Edition
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
STATUS
Microsoft 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:
MORE INFORMATION
Steps to Reproduce Behavior
- Create a .prg file.
Place the following code in the .prg file:
lcText=REPLICATE("HelloWorld",26) ? LEN(lcText) ? TRANSFORM(lcText,"@!")
- Save and run the .prg file.
NOTE: Visual FoxPro 6.0 experiences an exception error and terminates. When changing the value of 26 to 25 in the Replicate() function, the preceding code runs correctly without any error.
The error message displayed is partially dependent on the file that the code is contained within. Assuming that the preceding code is in a program named Test.prg and the program is located in the C:\FoxData directory, the error message would be as follows:
Keywords: kbbug kbfix kbxbase KB190792