Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CHR(13) and EXECSCRIPT() error
Message
From
19/09/2005 08:01:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/09/2005 07:36:41
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01050807
Message ID:
01050813
Views:
11
>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

Gordon,
lcFldList	= "cText, mText"
lcFldVal1	= '"Text"'
lcFldVal2	= '"Line 1" + CHR(13) + "Line 2"'
lcTbl		= "c:\temp\test"

lcInsertStr	= "INSERT INTO " + lcTbl ;
	+ " (" + lcFldList + [) VALUES(] + lcFldVal1 + [,] + lcFldVal2 + [)]
However an insert into doesn't need an execscript to prevent a macro subsitution. It's an overkill IMHO.

insert into (m.lcTbl) (&lcFieldList) values (m.Val1, m.Val2 ...)
is even better.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform