Page 1 of 1

Keeping LOG

Posted: Wed Oct 02, 2013 9:40 am
by esgici
Hi All

Code debugging is un-ignorable need for every programmer and DEBUG facility of Clipper / Harbour / HMG is very handy; with a little drawback :
it's highly complex due to its features and not easy to learn and use.

For a little purpose, a little Msgxxx functions ( especially MsgDebug() of our genius Dr. Soto ) will be enough in many time, under many circumstances; remembering WAIT and ALERT() of console mode.

And we have a little problem too in this method : if required 'repetitive' calls ( such as into a loop ) of that Msg function, requiring repetitive answers may be annoying.

In this condition we need a "log" file to records repeating values.

My preference ( IMHO the easiest way to build a text file ) is using and ALTERNATE file.

Pseudo code :

Code: Select all

   build an empty log file
   
   begin loop
     .
     .
     .
     use "?" or QUOT() to write the log file
     .
     .
   end loop
   
   close log file and show content
Here two little and simple procedure to Open / Close and show log file



I hope will be useful.

Happy HMG'ing :D

Re: Keeping LOG

Posted: Wed Oct 02, 2013 9:48 am
by bpd2000
Thank you Esgici

Re: Keeping LOG

Posted: Wed Oct 02, 2013 11:52 am
by Rathinagiri
Nice example Esgici.

I create many text files (for report printing in old dot matrix printers) in a HMG application using set alternate. In that case, will this logic work?

Re: Keeping LOG

Posted: Wed Oct 02, 2013 3:55 pm
by esgici
Thanks Rathi
Rathinagiri wrote:I create many text files (for report printing in old dot matrix printers) in a HMG application using set alternate. In that case, will this logic work?
Sure; this is for building (text) file only, printing is other side of subject ;)

Simply you may need some little modification on 'defaulting parameters" points: you may want no defaulting file name parameter and produce an error message such as "no file name specified" or anything else. Or your default target file name will be different, FE "report.txt" instead of PROCNAME( 1 ) + ".LOG"

IMHO important point is : since '?' and QOUT() are for console, in GUI mode has no effect. Bu this not means "this command / function doesn't work on GUI mode"; instead, as seen in the example, they are working and makes their job successfully :arrow:

Best regards and Happy HMG'ing :D

Re: Keeping LOG

Posted: Wed Oct 02, 2013 4:12 pm
by Rathinagiri
I mean I am already using 'set alternate' in my existing HMG application for other text file creation. In that case both this log file and that text file will work separately?

Re: Keeping LOG

Posted: Wed Oct 02, 2013 5:55 pm
by serge_girard
Esgici,

What I use/do is following:

Code: Select all

SET PRINTER TO C:\folder\debug.TXT  
SET PRINTER ON 
SET CONSOLE OFF

<your loop>
? what_ever
....
...

SET PRINTER TO   
SET PRINTER OFF 
SET CONSOLE ON
The file C:\folder\debug.TXT is open in my editor for viewing.

Greetings, Serge

Re: Keeping LOG

Posted: Wed Oct 02, 2013 7:18 pm
by esgici
Rathinagiri wrote:I mean I am already using 'set alternate' in my existing HMG application for other text file creation. In that case both this log file and that text file will work separately?
As far as I know no :(

Because there isn't a way to change target of '?' / QOUT() to this or that media / file.

Nevertheless we have other ways to write something to separate files.

I will work to build a sample for this.

Happy HMG'ing :D

Re: Keeping LOG

Posted: Wed Oct 02, 2013 7:38 pm
by esgici
serge_girard wrote: What I use/do is following:
Yes, this way too is legal and possible.

Please look at here.

Happy HMG'ing :D

Re: Keeping LOG

Posted: Sat Oct 05, 2013 11:09 pm
by esgici
Hi All
esgici wrote:...
Nevertheless we have other ways to write something to separate files.

I will work to build a sample for this.
As promised :
Screen shoot
Screen shoot
TestWTMTFSFT.jpg (9.75 KiB) Viewed 6463 times
WTMTFSFT.zip
Source and sample data file
(5.24 KiB) Downloaded 346 times
Look at ReadMe file for detailed info.

Happy HMG'ing :D