Report item width and height

Hi,

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?

SETTARGET(REPORT)
W = ?AgentName{PROP:Width}
SETTARGET()

or

W = Report$?AgentName{PROP:Width}

Your control on the report should NOT have a width defined in the AT(x,y, width). I’d put TRN on both controls.

Carl,

It doesn’t seem to work, I made a simple app:

PROGRAM

MAP
END

AgentName STRING(20)
LicenseNo STRING(10)

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

CODE

OPEN(Report)

AgentName = 'David Beckham'
stop(Report$?AgentName{PROP:Width})
PRINT(RPT:Detail)

AgentName = 'Steven G.'
stop(Report$?AgentName{PROP:Width})
PRINT(RPT:Detail)

CLOSE(Report)

Both stops return 3 which I believe is not the width of the control.

I looked up my code and what works for me is NOT using a picture string.

Below and Attached my Report Tester:
ClaHubRptTest.clw (3.0 KB)

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)

Screenshot 2020-10-29 110725

1 Like

Thanks Carl, you helped a lot.

I added this as a new file “Width_ReportTest” to my GIST with my Report Test Framework.

1 Like

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

Thanks Carl? I think the first solution looks better as the second one duplicates the assignment. I will try with text box height and width later.

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.