Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to avoid error for undefined var with TEXTMERGE?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00633782
Message ID:
00633800
Views:
23
This message has been marked as the solution to the initial question of the thread.
>Hello,
>
>I have a program that reads a html file (using FILETOSTR) and I am processing it with the TEXTMERGE command in order to replace things like
<<lname>>
with the content of the variable lname. My problem is that, if there is an error in the file, specifically the lname variable is not defined, the TEXTMERGE gives an error. Is there a way to make it work like the TEXT...ENDTEXT command that just put nothing in the replacement in this case but don't produce any error?
>
>
AFAIK, no, but you can check for undeclared variables an declare them before you run TEXTMERGE()
ldDate = DATE()
lcStr = " Today is <<ldDate>> <<lcTime>>"
lnCnt = 1
lcVarName = Strextract(lcStr, "<<", ">>", lnCnt)
DO WHILE NOT Empty(lcVarNAme)
	IF Type(lcVarNAme) = "U"
		LOCAL (lcVarNAme)
		STORE "<<" + lcVarName + ">>" TO (lcVarNAme)
	ENDIF
	lnCnt =lnCnt + 1
	lcVarName = Strextract(lcStr, "<<", ">>", lnCnt)
ENDDO
? Textmerge(lcStr)
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform