I have a report band with 2 variable string controls named AgentName (font 16) and LicenseNo (font 12) in which I would like to print the LicenseNo right after AgentName. How can I get the width of AgentName when value is assigned so that I can adjust the XPos of LicenseNo?
Report REPORT,AT(1000,2000,6250,7688),FONT(âArialâ,10,FONT:regular,CHARSET:ANSI), |
PRE(RPT),PAPER(PAPER:A4),THOUS
Detail DETAIL,AT(0,0),USE(?Detail)
STRING(@s20),AT(333,167),USE(AgentName),FONT(,16)
STRING(@s20),AT(3417,250),USE(LicenseNo),FONT(,10)
END
END
AgentName STRING(20)
LicenseNo STRING(10)
!>>>--Define your Report with ,PREVIEW(PreviewQ) attribute
Report REPORT,AT(1000,2000,6250,7688),FONT('Arial',10),PRE(RPT),PAPER(PAPER:A4),THOUS!,PREVIEW(PreviewQ)
HEADER,AT(1000,500),USE(?HEADER1)
STRING('Heading'),AT(333,219),USE(?STRING1)
END
Detail DETAIL,AT(0,0,6250,594),USE(?Detail)
STRING('AgentNameText'),AT(333,167),USE(?AgentNameText),FONT(,16)
STRING(@s10),AT(3417,250),USE(LicenseNo),FONT(,10)
END
END
CODE
!--Create Report
OPEN(Report)
REPORT{PROP:Preview}=PreviewQ
!>>>--Add your code to produce the report
LOOP T#=1 TO 3
CASE T#
OF 1 ; AgentName = 'David Beckham'
OF 2 ; AgentName = 'Steven G.'
OF 3 ; AgentName = 'William T. MaxHoney, Jr.'
END
LicenseNo=RANDOM(1234,99999999)
SETTARGET(Report)
?AgentNameText{PROP:NoWidth}=True
?AgentNameText{PROP:Text}=AgentName
?LicenseNo{PROP:XPos} = ?AgentNameText{PROP:XPos} + ?AgentNameText{PROP:Width} + 100
PRINT(RPT:Detail)
END
!--Report done, prepare it for preview
ENDPAGE(Report)
! CLOSE(Report) loses files
!--Preview the report
DO ReportPreviewRtn
CLOSE(Report)
Another way to do this is to have a separate DETAIL with the STRING(âxxâ) controls just used to measure the length, then adjust the STRING(@picture) controls. That way the Measure controls are not affected by changes to the printed controls.
Detail DETAIL,AT(0,0,6250,594),USE(?Detail)
STRING(@s20),AT(333,167),USE(AgentName),FONT(,16)
STRING(@s10),AT(3417,250),USE(LicenseNo),FONT(,10)
END
MeasureDetail DETAIL,AT(0,0,6250,594),USE(?MeasureDetail)
STRING('MeasureText16'),AT(333,167),USE(?Measure16),FONT(,16)
END
SETTARGET(Report)
?Measure16{PROP:NoWidth}=True !Not needed since Measure16 has no defined Width
?Measure16{PROP:Text}=AgentName
?LicenseNo{PROP:XPos} = ?AgentName{PROP:XPos} + ?Measure16{PROP:Width} + 100
Is there a template that can help with scaling a font down on particular report fields on a record-by-record basis?
Perhaps a template that could list all the controls from the REPORT definition and then let you pick which fields need to allow font scaling? For reports that use manually printed detail lines there would need to be a way to call the scaling code before issuing the PRINT statement.
I donât know if thereâs a template. You should ask in DiscussSV Reports.
I suppose it would make good sense as a Control template because to measure you need a Detail with a hidden STRING(?MeasureString) control. You donât want that Detail to print.
The first step would be to make a function to do the work. Probably with the below signature:
ReportFitFontSize Procedsure(REPORT ReportRef, |
LONG FitThisStringFEQ, LONG MeasureStringFEQ, |
SHORT NormalFontSize, SHORT MaxFontSizeReduction=3)
There are a bunch of other details to make it work. Like the FitString will get its Normal Font Size changed so you will need to retain the original in the template or maybe at runtime in a user property.
If you are going to work on this start a new thread here and link to this one.
Iâve solved this problem in PostScript. PS is interesting as you can change the Transformation Matrix so only the Width is changed. I.e. you have 10 point font in Height but the width is 8 point. It looks squeezed but does not stand out as smaller due to being the normal height. Bit sure if Windows can do that to a Font, or if it can do 1/2 point sizes.
Carl,
Is the âDiscussSV Reportsâ that you are referring to the âSoftvelocity.clarion.reportsâ Newsgroup on
âdiscuss.softvelocity.comâ ? There doesnât seem to be very much recent activity there.