DOCUMENT:Q186912 20-MAY-1999 [foxpro] TITLE :FIX: Error Using Trimcrlf Method of _stringlib Class PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:6.0 OPER/SYS: KEYWORDS:kbservicepack kbvfp600 kbvfp600bug kbVS600sp2 kbVS600SP1 kbVS600sp3fix ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== When using the Trimcrlf method of the _stringlib class, one of the following error messages appear: Variable 'CR' is not found _STRINGLIB1 ERROR: 12 Method: trimcrlf Line: 6 DO WHILE (LEFT(lcString,1)==CR OR LEFT(lcString,1)==LF -or- Variable 'LF' is not found _STRINGLIB1 ERROR: 12 Method: trimcrlf Line: 6 DO WHILE (LEFT(lcString,1)==CR OR LEFT(lcString,1)==LF CAUSE ===== This behavior occurs because the variables CR and LF have not been defined in the Trimcrlf method of the _stringlib class. RESOLUTION ========== The _stringlib class is contained in the _utility class library (_utility.vcx) located in the \ffc subdirectory of the Visual FoxPro installation directory. Open the _utility class library and select the _stringlib class. Select the Trimcrlf method and change the code to read as follows: LPARAMETERS tcstring,tltrimleft,tltrimright #DEFINE CR CHR(13) #DEFINE LF CHR(10) LOCAL lcstring lcstring=tcstring IF tltrimleft DO WHILE LEFT(lcstring,1)==CR OR LEFT(lcstring,1)==LF lcstring=LTRIM(SUBSTR(lcstring,2)) ENDDO ENDIF IF tltrimright DO WHILE RIGHT(lcstring,1)==CR OR RIGHT(lcstring,1)==LF lcstring=TRIM(LEFT(lcstring,LEN(lcstring)-1)) ENDDO ENDIF RETURN lcstring STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products 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: Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- 1. Create a program file named Testtrim.prg, using the following code: CLOSE ALL SET CLASSLIB TO HOME()+"FFC\_UTILITY.VCX" outilobject=CREATEOBJECT('array_form') outilobject.SHOW READ EVENTS DEFINE CLASS array_form AS FORM TOP = 0 LEFT = 0 HEIGHT = 180 WIDTH = 220 DOCREATE = .T. CAPTION = "_Utilities TRIM CRLF" NAME = "ARRAY_FORM" AUTOCENTER=.T. ADD OBJECT list1 AS LISTBOX WITH ; HEIGHT = 125, ; LEFT=05, ; TOP = 10, ; WIDTH = 100, ; ROWSOURCETYPE=5, ; ROWSOURCE="arraya" ADD OBJECT list2 AS LISTBOX WITH ; HEIGHT = 125, ; LEFT=115, ; TOP = 10, ; WIDTH = 100, ; ROWSOURCETYPE=5, ; ROWSOURCE="arrayb" ADD OBJECT command2 AS COMMANDBUTTON WITH ; LEFT=10, ; HEIGHT=25, ; CAPTION="\