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