print to txt file
Moderator: Rathinagiri
- fouednoomen
- Posts: 188
- Joined: Sun Oct 14, 2012 8:33 am
- DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
- Location: Tunisia
print to txt file
Dear All ,
How can i print to txt file
Regards
How can i print to txt file
Regards
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: print to txt file
Mostly I use this simple coding:
or this
Serge
Code: Select all
SET PRINTER TO C:\WINKAS\CREDBF.TXT
SET PRINTER ON
SET CONSOLE OFF
? PROCNAME()
...
SET PRINTER TO
SET PRINTER OFF
SET CONSOLE ON
Code: Select all
cTRACE := cFOLDER + "\TRACE" + cDATE + '.HTML'
// IF .NOT. FILE(cTRACE)
hTRACE := FCREATE(cTRACE)
FWRITE(hTRACE, '<html>' + pCRLF )
FWRITE(hTRACE, '<head>' + pCRLF )
FWRITE(hTRACE, '<body>' + pCRLF )
....
//ENDIF
FCLOSE(hTRACE)
There's nothing you can do that can't be done...
- fouednoomen
- Posts: 188
- Joined: Sun Oct 14, 2012 8:33 am
- DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
- Location: Tunisia
Re: print to txt file
Hi serge ,
Many thanks for your prompt replay
i don't understanding your second solution , please more details
Regards
Many thanks for your prompt replay
i don't understanding your second solution , please more details
Regards
- fouednoomen
- Posts: 188
- Joined: Sun Oct 14, 2012 8:33 am
- DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
- Location: Tunisia
Re: print to txt file
the first solution doesn't work well, he create the file but it's empty
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: print to txt file
First solution:
every ? will output something:
? date()
? time()
cVar := 'test'
? cVar
Second:
every FWRITE will output something.
Try this
And see what file is created
Serge
every ? will output something:
? date()
? time()
cVar := 'test'
? cVar
Second:
every FWRITE will output something.
Try this
Code: Select all
cTRACE := 'test.txt'
hTRACE := FCREATE(cTRACE)
FWRITE(hTRACE, 'line 1' + CRLF )
FWRITE(hTRACE, 'line 2' + CRLF )
FWRITE(hTRACE, 'line 3' + CRLF )
FCLOSE(hTRACE)
Serge
There's nothing you can do that can't be done...
- mustafa
- Posts: 1158
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: print to txt file
Hi
Have if it can serve you?
It's a dirty code it's just to see how it generates .txt file
Regards
Mustafa
Have if it can serve you?
It's a dirty code it's just to see how it generates .txt file
Code: Select all
#include <hmg.ch>
*---------------------------------------------------*
Function Main
*---------------------------------------------------*
PRIVATE cNombre
cNombre := "Factura.txt"
*-------------------------------------------------------------*
SET PRINTER ON
SET PRINTER TO &cNombre
SET CONSOLE OFF
SET CENTURY ON
SET DATE FRENCH
SET DATE FORMAT TO 'dd/mm/yyyy'
SET DECIMALS TO 2
@ PROW(),PCOL()
? space(35)+ " F A C T U R A "
? REPLICATE(" ",79)
? space(10)+"NOMBR"
? space(10)+"DIRECCIO"
? space(10)+ "CODIG" +space(13)+ "POBLACIO"
? space(10)+ "PROVI"
? SPACE(5) + REPLICATE("_",80)
? SPACE(80)
? SPACE(10)+"Factura: " + " Fecha: "+ DTOC(date() )
?
?
?
?
?
? space(51)+"Suma € "
?? " "
?? RTRIM( "1.000" )
?? " "
? space(51)+"I.V.A. 21 % "
?? " "
?? RTRIM( " 34" )
?? " "
? space(51)+"Total € "
?? " "
?? RTRIM( "1.O34" )
?? " "
?? " "
?? " "
? space(80)
*----------------------------------------------------*
SET PRINTER OFF
SET CONSOLE ON
Return
Mustafa
- mustafa
- Posts: 1158
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: print to txt file
Same Sample with DBF
Regards
Mustafa
Regards
Mustafa
- Attachments
-
- Sample.zip
- (7.68 KiB) Downloaded 158 times
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: print to txt file
fouednoomen,
ça marche?
Serge
ça marche?
Serge
There's nothing you can do that can't be done...
Re: print to txt file
Hi,
how about:
set alternate to "file.txt"
set alternate on
Robert
how about:
set alternate to "file.txt"
set alternate on
Robert
Re: print to txt file
2018 sample before I retired therefore the copying from server (not unc notation) :
Code: Select all
#include "hmg.ch"
PROCEDURE Main
local cLine
set navigation extended
//request HB_CODEPAGE_DE850
request HB_CODEPAGE_DEWIN
//request HB_CODEPAGE_DEISO
//set( _SET_CODEPAGE, "DE850" )
set( _SET_CODEPAGE, "DEWIN" )
//set( _SET_CODEPAGE, "DEISO" )
******************************************************************
//copying files from server to local workstation
//copy file s:\as5win\daten1\askunde.dbf to (cPath+"\askunde.dbf")
//copy file s:\as5win\daten1\asbran.dbf to (cPath+"\asbran.dbf")
use bbkunde exclusive
zap
append from askunde for inaktiv<>"J" .or. !empty(exknr) &&bbkunde is filled with actual data from server
//delete for empty(exknr) &&garbage records ;-)
Pack
***************************************************
use branche exclusive && same procedure for branche
zap
append from asbran for kode="SV"
close all
set alternate to (cPath+"\KDS.txt")
set alternate on
****************************************************
DEFINE WINDOW Servisa ;
AT 120,120 ;
WIDTH 800 ;
HEIGHT 800 ;
ON INIT weiter() ;
FONTNAME 'ARIAL' FONTSIZE 12;
TITLE "Servisa Daten" ;
MAIN
END WINDOW
Servisa.center
ACTIVATE WINDOW Servisa
RETURN NIL
********************************************************************+
procedure weiter
use branche alias branche new codepage("DE850")
use bbkunde alias kunde new codepage("DE850")
index on knr to knr
//set console off
select branche
go top
do while !eof()
select kunde
seek branche->knr
if !empty(kunde->exknr)
druck()
endif
select branche
skip
enddo
set console on
set alternate off
set alternate to
MsgInfo('ENDE')
servisa.release
RETURN
************************************************************+
procedure druck
// output to "kds.txt" (csv file)
cLine=alltrim(kunde->exknr)+";"+alltrim(kunde->name1)+";"+alltrim(kunde->str)+";"+alltrim(kunde->lkz);
+";"+alltrim(kunde->plz)+";"+alltrim(kunde->ort)+";"+alltrim(kunde->name2)+";"+";"
? cLine
return
Last edited by ROBROS on Thu May 14, 2020 8:09 pm, edited 2 times in total.