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.