Help : Regarding Reports & Printing using FWH

Help : Regarding Reports & Printing using FWH

Postby anserkk » Sat Oct 18, 2008 11:36 am

Dear Freinds,

Most of the users of my app use DOT Matrix printers connected to their local LPT port and few of them are using network printers (DOT Matrix) mapped to their local LPT port (Net use LPT1 \\PcName\PrintShareName)

For printing they use computer paper stationaries with size 10x12 inch or 10*15" inch papers and not A4.

My application create reports on a text file and once the report is created on a text file, I give choice to user either to
1) View the report on screen (using a Text file browser)
2) Print the report ( If this opted then the already created text file is copied to the LPT port using the command copy file xxx.txt to LPT1, which prints the report in a much faster way unlike printing from windows in graphics mode)
3) Save the report (Txt) in a user specified folder for future reference.

I use to write my clipper app using the following method

Code: Select all  Expand view
Set Printer to "Report.Txt"
Set Device to Printer
SetPrc(00,00)
Set Console Off

Use Account Index Account

@prow()+1,00 say "Company Name"
@prow()+1,00 say Padc("Account Heads",80)
@prow()+1,00 say "/---------------------------------------------\"
@prow()+1,00 say "|  Ac Head                       | Op.Balance |"
@prow()+1,00 say "|-----------------------------|---------------|"

Sele Account
Go Top
Do while !eof()
       If prow() > 65
             @prow()+1,00 say "\-------------------------------------/"
             EJECT
             @prow()+1,00 say "Company Name"
             @prow()+1,00 say Padc("Account Heads",80)
             @prow()+1,00 say "/---------------------------------------------\"
             @prow()+1,00 say "|  Ac Head                       | Op.Balance |"
             @prow()+1,00 say "|-----------------------------|---------------|"
       Endif

       @prow()+1,00 say "| "+AC_NAME+" | "+str(OP_BALANCE,9,2)+" |"
       Sele AcMaster
       Skip
Enddo
@prow()+1,00 say "\-------------------------------------/"
@prow()+100 say "End of Report"
SetPrc(00,00)
Set Printer to
Set Device to Screen
Set Console On
RptOptions()    // This function gives the choice to the user either to view or print or to save the text file for future ref.


Trying to accomplish similiar task using FWH I wrote code in FWH as given below.

I know that the method used by me is very old and FWH will have much more powerful techniques which can be done in a much better way.

I need your view on this, keeping in mind the following

1) an option for the user to either dump to LPT port for those who need fast printing.
2) Preview of the report
2) Save the report in Text format, excel etc.

How can the same be accomplished using FWH in a much better way.

I also noticed that Prev32.Dll should be there for the Report preview to work.

As a beginner I tried to create a report using FWH, I don't know whether this is the right way or not.

The font is appearing too small. I don't know what is thosr parameters 0,-12 while defining font Define Font oFont "Font Name " Size 0, 13

My FWH code

Code: Select all  Expand view
*---------------------------------------------------*
Function AcPrn()
*---------------------------------------------------*
local oPrn, oFont, oPen
Local nRowStep, nColStep
Local nRecNo
Local nRow := 0, nCol := 0

Sele AcMaster_ACM
nRecNo:=RecNo()


PRINT oPrn NAME "Account Heads" PREVIEW
   if Empty( oPrn:hDC )
      MsgStop("No printers Installed")
      Return nil          // Printer was not installed or ready
   endif
   DEFINE FONT oFont NAME "Courier New" SIZE 0, -12
*   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn
*   DEFINE FONT oFont NAME "Arial" SIZE 0, -10 BOLD OF oPrn

   nRowStep = oPrn:nVertRes() / 65   // We want 65 rows
   nColStep = oPrn:nHorzRes() / 80   // We want 80 cols


*   DEFINE PEN oPen WIDTH  2                        OF oPrn
   oPrn:SetPage(9)  // A4
   oPrn:SetPortrait() //Vertical

   PAGE
      
      nRow:=0; nCol:=0
      oPrn:Say(nRow,nCol,"/-------------------------------\",oFont)
      nRow += nRowStep         
      
      nCol:=0
      oPrn:Say(nRow,nCol,"| AcName                        |",oFont)
      nRow += nRowStep         
      
      nCol:=0
      oPrn:Say(nRow,nCol,"|-------------------------------|",oFont)
      nRow += nRowStep         
      
      
      Sele AcMaster_ACM
      Go Top
      Do While !eof()
      
         if nRow > oPrn:nVertRes() -5
            nCol:=0
            oPrn:Say(nRow,nCol,"\-------------------------------/",oFont)
             ENDPAGE
            PAGE
               nRow:=0; nCol:=0
               oPrn:Say(nRow,nCol,"/-------------------------------\",oFont)
               nRow += nRowStep         
               
               nCol:=0
               oPrn:Say(nRow,nCol,"| AcName                        |",oFont)
               nRow += nRowStep         
               
               nCol:=0
               oPrn:Say(nRow,nCol,"|-------------------------------|",oFont)
               nRow += nRowStep         

         Endif
      
         nCol:=0
         oPrn:Say(nRow,nCol,"| "+NAME+" |",oFont)
         nRow += nRowStep         
         
         Select AcMaster_ACM
         Skip        
      Enddo
   ENDPAGE
ENDPRINT      
   
     
oFont:End()      // Destroy the font object
Sele AcMaster_ACM
Goto nRecNo
Return nil


Any help will be appreciated

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Help : Regarding Reports & Printing using FWH

Postby Enrico Maria Giordano » Sat Oct 18, 2008 11:56 am

anserkk wrote:DEFINE FONT oFont NAME "Courier New" SIZE 0, -12


Here you probably forgot "OF oPrn".

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8332
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby anserkk » Mon Oct 20, 2008 5:14 am

Dear EMG

Here you probably forgot "OF oPrn".


Font OF oPrn solved the problem

Thanks & Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Mon Oct 20, 2008 5:57 am

Can any body explain the usage of SIZE while defining a font

For Eg: DEFINE FONT oFont NAME "Courier New" SIZE 0, -12

What is the first parameter and 2nd parameter
Sometime negetive numbers are used in the second parameter 0, -12
sometimes SIZe 8,12

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Mon Oct 20, 2008 8:03 am

Any hint on setting custom page size

For eg: oPrn:SetPage(9) // A4 paper #Define DMPAPER_A4 9

Most of my application users work on DOT Matrix printers

I want to set the page size to be 10x12 inch size and another one 10x15" inch ( size of a standard computer stationery paper here)

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Enrico Maria Giordano » Mon Oct 20, 2008 8:07 am

anserkk wrote:Can any body explain the usage of SIZE while defining a font

For Eg: DEFINE FONT oFont NAME "Courier New" SIZE 0, -12

What is the first parameter and 2nd parameter
Sometime negetive numbers are used in the second parameter 0, -12
sometimes SIZe 8,12

Regards

Anser


8, 12 means a font with 8 points width and 12 points height while 0, -12 means a font with 12 points height and appropriate width, if I remember correctly.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8332
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby anserkk » Mon Oct 20, 2008 8:09 am

Thankyou EMG

8, 12 means a font with 8 points width and 12 points height while 0, -12 means a font with 12 points height and appropriate width


Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Roger Seiler » Mon Oct 20, 2008 1:19 pm

Here is an excerpt of the explanation in FiveWin's fwprog.hlp help file (in FWH\MANUAL). In that help file, the following text is found in the section titled "Fivewin Report Engine" (within the section titled "Printing")...

USING FONTS:

You can use any font you want with your reports. This is the way you use them:

First you have to define them with the command DEFINE FONT oFont ....


DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD

The size (width,height) specs. use different units of measure when printed versus displayed on screen. On screen, the units are pixels, but when printed, the units are font "points". Thus, for printed text, we only use the second size specification (height) to give the point size, leaving the "width" as "0". The point size is given as a negative number, i.e. "10 point" is "-10". Remember that point size for proportionally spaced type is different than "pitch," which is the term often used for non-proportionally spaced "typewriter" type like Courier.

Point size refers to letter height, whereas pitch refers to the number of equal-spaced letters printed per inch. Regular "pica" sized typewriter type is 10 pitch - 10 letters per inch. But represented in point size, this is 12 point -- very confusing because the smaller "elite" typewriter type is 12 pitch - 12 letters per inch, which is 9 point. (With "pitch," the bigger the number, the smaller the font -- just the opposite of how "point" size works.)

Now to add to the confusion, remember that in this Report Engine, we let FiveWin know that we're working with point size instead of pixels by using negative numbers for points (and we must use points instead of pitch for equal-spaced fonts like Courier). In this case, the "-" sign isn't mathematical -- it doesn't mean (as math rules would suggest) that your point size gets smaller as the integer gets bigger. Just the reverse. The bigger the integer, the bigger the point size.

- Roger
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Postby anserkk » Tue Oct 21, 2008 4:44 am

Hello Mr.Roger,

Thank you for the information. My vision on the usage of Fonts on Screen and Printer is getting more clear now.

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Tue Oct 21, 2008 4:45 am

Any hint on setting custom page size

For eg: oPrn:SetPage(9) // A4 paper #Define DMPAPER_A4 9

Most of my application users work on DOT Matrix printers

I want to set the page size to be 10 inch width and 12 inch lenghth size and another one 15 Inch width 12 inch length ( size of a standard computer stationery paper here)

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby James Bott » Tue Oct 21, 2008 6:43 am

oPrn:setSize( nWidth, nHeight) where the parameters are in tenths of a millimeter.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby hua » Tue Oct 21, 2008 12:30 pm

Be aware that if you print usinng the printer class or the report engine you'll be printing in graphic mode not text mode. If your user are used to the speed of printing in text mode they might complain as printing in graphics mode is slower.

If you want to print in text mode have a look at tdosprn class.
hua
 
Posts: 1039
Joined: Fri Oct 28, 2005 2:27 am

Postby anserkk » Tue Oct 21, 2008 12:36 pm

Dear Hua,

Thankyou for the information about TDosPrn class

For certain reports (not all) My requirements are

1) DOS mode Printing ( not in Graphics mode, so that more speed in printing )
2) Preview of the Report
3) Provision to save the report as Text file. ( Would live to have saving in other formats like Excel or OpenOffice )



Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Tue Oct 21, 2008 12:48 pm

Thankyou Mr.James,

Code: Select all  Expand view
oPrn:setSize( nWidth, nHeight) where the parameters are in tenths of a millimeter.


Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 24 guests