Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows printing with RM/COBOL

Status
Not open for further replies.

vrmcobol

Programmer
Dec 1, 2005
1
PT
This is probably a stupid question but how can I print the same number of lines with the same number of characters in diferent printers ?

I´ve tried this small program but it didn't work. I think I'm making a mistake whem computing the font parameters but I can't find any good example in the RM/COBOL manuals.

Can anyone give me any sugestion, or show me some examples for this kind of problem ?

Thanks in advance and please sorry my very bad english....


Vitor

FILE-CONTROL.
*
SELECT IMP ASSIGN TO PRINTER "PRINTER?".
*
DATA DIVISION.
FILE SECTION.
*
*
FD IMP LABEL RECORD OMITTED.
*
01 RI PIC X(150).
*
WORKING-STORAGE SECTION.
*
01 det1.
05 linha pic 99b.
05 texto pic x(147) value
"12345678901234567890123456789012345678901234567890
- "12345678901234567890123456789012345678901234567890
- "12345678901234567890123456789012345678901234567".
*
01 mod1 pic 9(03).
*
COPY PRINTDLG.
*
COPY LOGFONT.
*
COPY DEVCAPS.
*
/
PROCEDURE DIVISION.
A-INICIO.
OPEN OUTPUT IMP.
CALL "P$CLEARDIALOG".
CALL "P$SETDIALOG" USING PRINTDIALOG.
CALL "P$GetDeviceCapabilities" USING
DEVICECAPABILITIES.
COMPUTE LF-Height ROUNDED =
(DC-PhysicalHeight) / 80.
COMPUTE LF-Width ROUNDED =
(DC-PhysicalWidth) / 170.
CALL "P$ClearFont".
CALL "P$SetFont" USING
LF-FACENAMEPARAM, "COURIER NEW"
LF-HEIGHTPARAM, LF-Height
LF-WIDTHPARAM, LF-WIDTH.

move 1 to mod1 linha.
write ri from det1 after 0.
soma-mod1.
add 1 to mod1.
if mod1 < 80
move mod1 to linha
write ri from det1 after 1
go soma-mod1.
stop run.
 
As it seems you are Portuguese if this is the case I would like you to email me at "cobol _at_ memosis.pt" with your problem.

Regardless of that it is not clear what is your problem. e.g. do you get no output, wrong output (and how wrong) or other problem?

I will try and place here a full working example of P$ functions (this if Tom doesn't do it first)

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks, Frederico! [bigsmile] Please provide examples when you have the time.

vrmcobol said:
How can I print the same number of lines with the same number of characters in diferent printers ?

Presumably, this will require you to adjust font size based upon printer capabilities and text width, etc.

One could take the longest line and call P$GetTextExtent, P$GetTExtMetrics, and P$SetFont to adjust the point size until the longest line fits into the capabilities of the printer. The sample Setting the Point Size for a Font should have some helpful information.

Please post back your solution, as other RM/COBOL users might find it helpful.

Tom Morrison
 
Tom or Frederico,
I can't remember if RM/COBOL currently supports the (optional in '85 Standard; required in '02 Standard) Report-Writer feature.

If so, wouldn't that provide the desired functionality?

Bill Klein
 
That is one of the modules RM does not support.

It does supply some internal functions (P$...) that allow for several things to be done, but some combinations still cause problems (not the case here), and others are very workable in order to give the desired results in ALL printers. This last is nothing of the ordinary, as it was always the problem with "manual" definitions of print output.

At the moment I have sent another version of the problem to Vitor, and will, for the time being, deal with this subject via email.

Results will be posted later.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Vitor,

Use this calculation to set a font to a specific point size. This is from the pexample.cbl program in the samples directory.

Code:
       Set-Default-Font.
      *
      ** Set Default Font Name and Height **
      *
           CALL "P$GetDeviceCapabilities" Using DC-LogicalPixelsYParam,
                                                DC-LogPixelsY.
           INITIALIZE LogicalFont.
           MOVE 12 TO Point-Size.
           MOVE "Courier New"  TO LF-FaceName.  *> Set Font Name to Courier New
           COMPUTE LF-Height Rounded = - ((Point-Size * Dc-LogPixelsY)
                                       / 72).   *> Set Point Size to 12
           SET LF-PitchIsFixed TO TRUE.
           SET LF-Italic, LF-UnderLine, LF-Strikeout To FALSE.
           CALL "P$SetFont" USING LogicalFont.

-Robert Heady
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top