Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text merging doubled when returned from function,how to
Message
From
07/05/2004 04:00:35
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00901756
Message ID:
00901847
Views:
10
>Hi, All,
>
>I have two functions:
>
>*merging
>function getlettercaption
> lparameters lpnscript_id
> local lcreturn
> use scriptfile in 0 order script_id shared
> if indexseek(m.lpnscript_id,.t.,'scriptfile','script_id') ;
> then
>  m.lcreturn = textmerge(alltrim(scriptfile.mg_script))
> else
>  m.lcreturn =[]
> endif
> use in scriptfile
> return m.lcreturn
>endfunc &&getlettercaption
>
>* get default caption
>
>function getdefaultcaption
> use sysfile in 0 shared
> local m.lcreturn
> m.lcreturn = getlettercaption(sysfile.dft_cap)
> use in sysfile
> return m.lcreturn
>endfunc &&getdefaultcaption
>
>
>Then I have a prg which calls function getdefaultcaption() like as follows:
>
>set textmerge on
>LOCAL lcfile
>m.lcfile = SYS(2015)+".txt"
>_text = FCREATE(m.lcfile)
>SET TEXTMERGE ON
>TEXT noshow
>*some code
><<getdefaultcaption()>>
>*some more code
>ENDTEXT
>
>
>The end result was that I get two lines of letter caption instead of one, for example,
>I get:
>
>LLL Company
>2324 Main St.
>Main City, CA 90000
>
>Dear Mr. John Doe,
>
>LLL Company
>2324 Main St.
>Main City, CA 90000
>
>Dear Mr. John Doe,
>
>
>Instead of just:
>
>LLL Company
>2324 Main St.
>Main City, CA 90000
>
>Dear Mr. John Doe,
>
>Does anybody know why this is happening? How should I fix this?
>Any help will appreciated!
>
>TIA,
>
>Dawa

Check _text in help. When you direct outout to a file all subsequent text commands go to that file. You're using :
textmerge(alltrim(scriptfile.mg_script))
in GetLetterCaption() and calling it from within text...endtext dubling the output.
Instead of creating output to a file you might simply collect all to memvar and StrToFile() at once.

Text to m.lcLetter textmerge noshow
...
endtext
StrToFile(m.lcLetter, filename)

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