Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text merging doubled when returned from function,how to
Message
 
To
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:
00901964
Views:
14
Cetin,

Thank you very much for the tip. That's exactly what I am doing.

Actually, as I tried different things to solve the problem, discovered that if I change the export to a memory variable then the problem goes away. So I have already changed the code so the output would be directed to a memory variable rather than the file. You are right. StrToFile is definitely more concise than multiple lines of fcreate,fclose etc..

I really appreciate it.

Dawa

>>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
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Previous
Reply
Map
View

Click here to load this message in the networking platform