print to txt file
Posted: Tue May 12, 2020 4:00 pm
Dear All ,
How can i print to txt file
Regards
How can i print to txt file
Regards
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://www.hmgforum.com/
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)
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)
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
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