Page 1 of 1

Creating a text file

Posted: Wed Oct 12, 2011 5:28 pm
by Faiz
Hi

Can anyone help?
I need to generate a TXT file
Previously in my Clipper DOS program I could SET Printer to filename
This does not seem to be available in HMG

Re: Creating a text file

Posted: Wed Oct 12, 2011 6:12 pm
by tave2009
Español:
Hola,
El comando: Set Printer to <filename>
No esta disponible en la Librería HMG, pero si en Harbour

Ingles: (Google)
Hello,
The command: 'Set Printer to <filename>'
In the HMG library is unavailable. But if Harbour.

Slds.
Walter

Re: Creating a text file

Posted: Wed Oct 12, 2011 6:14 pm
by Rathinagiri
You can use

Code: Select all

set alternate to 'x.txt'
This works in HMG.

Re: Creating a text file

Posted: Wed Oct 12, 2011 9:11 pm
by Faiz
Set Alternate works

My thanks,
Never had the need to use this in Clipper

Re: Creating a text file

Posted: Sun Oct 16, 2011 9:19 am
by JALMAG
Este post creo que te vendrá muy bien.

This post will solve your doubts.

viewtopic.php?f=5&t=1192&p=8483&hilit=writefile#p8483

Re: Creating a text file

Posted: Sun Oct 16, 2011 11:43 am
by esgici
fread() / fwrite() ... etc are low-level functions and I'm always afraid LL approaches ;)

For building a text file programmatically my favorite way is something like this :

Code: Select all

cText := ''
...
<beginning of (probably necessarily) a loop ( FOR / WHILE ... ) >
   ...
   cLine := <somethings >

   cText += cLine + CRLF

<end of loop>

HB_MEMOWRIT( <output file name>, cText )
Regarding "viewing a text file", IMHO best way is EDITBOX; something like this:

Code: Select all

<NameOfEditboxControl>.value := MEMOREAD( <inputTextFileName> )
That's all 8-)


PS: Don't hesitate about 64 K limit, it left in DOS ;)

Regards / Saludos

--

Esgici

Re: Creating a text file

Posted: Sun Oct 16, 2011 12:35 pm
by Rathinagiri
Addendum to Esgici,

It is better to have the font of the editbox to be 'Courier New' so that the spacing will be equal between characters. Hmm. Good old days!

Re: Creating a text file

Posted: Sun Oct 16, 2011 12:51 pm
by esgici
rathinagiri wrote: It is better to have the font of the editbox to be 'Courier New' so that the spacing will be equal between characters. Hmm. Good old days!
Yes my friend :)

Or FixedSYS

In addition make background color to black and live a little nostalgia ;)

Regards

--

Esgici