>Help, I’m trying to add a record using macro substitution. All works fine until I place a carriage return to the data being saved. Now it falls over with “syntax error” when using EXECSCRIPT() or “command contains unrecognized phrase/keyword” when using macro substitution. Can anyone help resolve this problem, please. I show below code that has the problem.
>
>VFP9; XP Prof
>
>IF !FILE('c:\temp\test.dbf')
>CREATE TABLE c:\temp\test (nVal I autoinc, cText C(30), mText M)
>ENDIF && FILE('c:\temp\test.dbf')
>
>lcFldList = "cText, mText"
>lcFldVal1 = "Text"
>lcFldVal2 = "Line 1" + CHR(13) + "Line 2"
>lcTbl = "c:\temp\test"
>
>lcInsertStr = "INSERT INTO " + lcTbl ;
> + " (" + lcFldList + [) VALUES("] + lcFldVal1 + [","] + lcFldVal2 + [")]
>?lcInsertStr
>
>TRY
>*!* &lcInsertStr
>EXECSCRIPT(lcInsertStr)
>CATCH TO loErr
>MESSAGEBOX("lcInsertStr failed" + CRLF + lcInsertStr + CRLF + loErr.message, 0, "Info")
>ENDTRY
>
>TIA
>Gordon
You cannot put a CHR(13) into a literal string.
Uses a binary:
lcFldVal2 = "Line 1" + 0hD + "Line 2"
Why to use a EXECSCRIPT for this simple task ?
Direct syntax is more efficient:
fieldName1 = "cText"
fieldName1 = "mText"
INSERT INTO (lcTbl) ((fieldName1),(m.fieldName2) VALUES (lcFldVal1,lcFldVal2)