Skip to content

Instantly share code, notes, and snippets.

@CarlTBarnes
Last active June 27, 2021 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlTBarnes/29f78a2ca43813e83489dc62a4d5e0c0 to your computer and use it in GitHub Desktop.
Save CarlTBarnes/29f78a2ca43813e83489dc62a4d5e0c0 to your computer and use it in GitHub Desktop.
Report Test Scratch Program
!Report Test Framework by Carl Barnes from https://gist.github.com/CarlTBarnes
!Using ABC Report Previewer instead of my simple previewer
!
!This tested Report${PROP:FontXxx} broken by 11.1
!
!-----------------------------------------------------------------------------
!Try various REPORT specs and PROP Settings quicky in this little Win32 project that has its own simple Previewer.
!If you want to report a bug this can be used to create a small example
!
!1. Create a new Win32 Project and paste this code.
!1a. Must add Project Defines: _ABCLinkMode_=>1;_ABCDllMode_=>0
!2. Add the Variables used on the REPORT - at #2 below
!3. Add Your REPORT and DETAIL's - at #3 below
!4. Add your PRINT() code and PROP code - at #4 below
!5. Run and Test, adjust code, repeat
!-----------------------------------------------------------------------------
PROGRAM !Report Test Framework - ABC Preview - by Carl Barnes
INCLUDE('ABREPORT.INC'),ONCE !Must have Defines: _ABCLinkMode_=>1;_ABCDllMode_=>0
MAP
DB(STRING DebugText) !Debug Output
DBClear() !Empty debug buffer
MODULE('WinAPI')
OutputDebugString(*cstring Msg),PASCAL,RAW,DLL(1),NAME('OutputDebugStringA')
END
END
!--The Stuff needed for Preview
PreviewQ QUEUE(PreviewQueue),PRE(PreQ)
END
!#2. >>>--Define your test data
String1 STRING('string1 string1')
String2 STRING('string2 string2')
!#3. >>>--Define your Report
Report REPORT,AT(1000,2000,6000,7000),FONT('Arial',10),PRE(RPT),THOUS
HEADER,AT(1000,1000,6000,1000),USE(?HEADER1)
STRING('Report Test Prop Font changes'),AT(208,94),USE(?Title),TRN,FONT(,,,FONT:bold)
END
Detail1 DETAIL,AT(0,0,6000,1146),USE(?Detail1)
STRING('What Test'),AT(167,10,,146),USE(?WhatTest),TRN,FONT(,8)
STRING(@s40),AT(167,292),USE(String1)
STRING(@s40),AT(2990,292,2729),USE(String2)
STRING('These changed to Times 16 by PROP'),AT(2990,10,1229,146),USE(?Fyi),TRN,FONT(,8)
STRING('I am Original in Arial 10'),AT(167,615),USE(?PropTestOrig)
STRING('Prop Font changed to Times 16?'),AT(2990,615,2729),USE(?PropTestChange)
LINE,AT(177,958,5490,0),USE(?LINE1)
END
FOOTER,AT(1000,9000,6000,1000),USE(?unnamed)
END
FORM,AT(1000,1000,6000,9000),USE(?FORM1)
END
END
TestHow BYTE
CODE
!--Create Report
OPEN(Report)
REPORT{PROP:Preview}=PreviewQ
Report$?Title{PROP:Text}=Report$?Title{PROP:Text} &' - Build ' & System{PROP:LibVersion,3}
!#4. >>>--Add your code to produce the report
Report$?WhatTest{PROP:Text}='Test #1 with Report$?FEQ{{PROP}' !Works
Report$?String2{PROP:Right}=1 !works
Report$?String2{PROP:FontSize}=16 !fails
Report$?String2{PROP:FontName}='Times New Roman' !fails
Report$?String2{PROP:FontStyle}=FONT:Bold + FONT:italic !fails
Report$?PropTestChange{PROP:FontSize}=16
Report$?PropTestChange{PROP:FontName}='Times New Roman'
PRINT(Rpt:Detail1)
SETTARGET(Report) !works
?WhatTest{PROP:Text}='Test #2 SetTarget(Report) ; ?FEQ{{PROP}'
?String2{PROP:Center}=1 !Try Center, works
?String2{PROP:FontSize}=16
?String2{PROP:FontName}='Times New Roman'
?String2{PROP:FontStyle}=FONT:Regular + FONT:italic
?PropTestChange{PROP:FontSize}=16
?PropTestChange{PROP:FontName}='Times New Roman'
SETTARGET()
PRINT(Rpt:Detail1)
!--Report done, prepare it for preview
ENDPAGE(Report)
! CLOSE(Report) loses files
!--Preview the report
DO ReportPreviewRtn
CLOSE(Report)
!----------------- Open Preview Window and Display --------------------------
ReportPreviewRtn ROUTINE
DATA
Previewer PrintPreviewClass !ABC Previewer requires INCLUDE('ABREPORT.INC'),ONCE
CODE ! and Defines: _ABCLinkMode_=>1;_ABCDllMode_=>0
Previewer.Init(PreviewQ)
Previewer.Maximize= true
Previewer.AllowUserZoom= true
IF Previewer.Display(100)
Report{ prop:FlushPreview}= true
END
Previewer.Kill()
EXIT
!----------------------------------------
DB PROCEDURE(STRING xMessage)
Prfx EQUATE('RptTest: ') !All output gets this
sz CSTRING(SIZE(Prfx)+SIZE(xMessage)+3),AUTO
CODE
sz = Prfx & CLIP(xMessage) & '<13,10>'
OutputDebugString( sz )
RETURN
DBClear PROCEDURE()
DVClr CSTRING('DBGVIEWCLEAR') !Message to Clear the buffer. Must UPPER and first i.e. without a Prefix
CODE
OutputDebugString(DVClr)
RETURN
!Report Test Framework by Carl Barnes from https://gist.github.com/CarlTBarnes https://git.io/JtP6r
!-----------------------------------------------------------------------------
!Try various REPORT specs and PROP Settings quicky in this little Win32 project that has its own simple Previewer.
!If you want to report a bug this can be used to create a small example
!
!1. Create a new Win32 Project and paste this code.
!2. Add the Variables used on the REPORT - at #2 below
!3. Add Your REPORT and DETAIL's - at #3 below
!4. Add your PRINT() code and PROP code - at #4 below
!5. Run and Test, adjust code, repeat
!-----------------------------------------------------------------------------
PROGRAM !Report Test Framework by Carl Barnes
INCLUDE('PRNPROP.CLW')
MAP
DB(STRING DebugText) !Debug Output
DBClear() !Empty debug buffer
MODULE('WinAPI')
OutputDebugString(*cstring Msg),PASCAL,RAW,DLL(1),NAME('OutputDebugStringA')
END
END
!--The Stuff needed for Preview
PreviewQ QUEUE,PRE(PreQ)
FileName STRING(260)
END
!#2. >>>--Define your test data
String1 STRING('string1')
String2 STRING(20)
String3 STRING('string3')
String4 STRING('string4')
!#3. >>>--Define your Report
Report REPORT,AT(1000,2000,6000,7000),FONT('Arial',10),PRE(RPT),THOUS
HEADER,AT(1000,1000,6000,1000),USE(?HEADER1)
STRING('Report Test for SKIP'),AT(208,94),USE(?STRING1),TRN,FONT(,,,FONT:bold)
END
DetailSKip DETAIL,AT(0,0),USE(?DetailSKip)
STRING('Detail with SKIP'),AT(83,10,1229,146),USE(?STRING2),TRN,FONT(,8)
STRING(@s40),AT(167,146),USE(String1,, ?String1:2),SKIP
STRING(@s40),AT(167,344),USE(String2,, ?String2:2),SKIP
STRING(@s40),AT(167,542),USE(String3),SKIP
STRING(@s40),AT(167,750),USE(String4),SKIP
STRING(@s40),AT(3167,146),USE(String1,, ?String1:3),SKIP
STRING(@s40),AT(3167,344),USE(String2,, ?String2:3),SKIP
STRING(@s40),AT(3167,542),USE(String3,, ?String3:2),SKIP
STRING(@s40),AT(3167,750),USE(String4,, ?String4:2),SKIP
END
DetailNOSKip DETAIL,AT(0,0),USE(?DetailNOSKip)
STRING('Detail NO SKIP'),AT(83,10,1229,146),USE(?STRING5),TRN,FONT(,8)
STRING(@s40),AT(167,146),USE(String1,, ?String1:4)
STRING(@s40),AT(167,344),USE(String2,, ?String2:4)
STRING(@s40),AT(167,542),USE(String3,, ?String3:3)
STRING(@s40),AT(167,750),USE(String4,, ?String4:3)
END
FOOTER,AT(1000,9000,6000,1000),USE(?unnamed)
END
FORM,AT(1000,1000,6000,9000),USE(?FORM1)
END
END
CODE
!--Create Report
OPEN(Report)
REPORT{PROP:Preview}=PreviewQ
!#4. >>>--Add your code to produce the report
PRINT(Rpt:DetailSKip)
PRINT(Rpt:DetailNOSKip)
!--Report done, prepare it for preview
ENDPAGE(Report)
! CLOSE(Report) loses files
!--Preview the report
DO ReportPreviewRtn
CLOSE(Report)
!----------------- Open Preview Window and display --------------------------
ReportPreviewRtn ROUTINE
DATA
PrintIt Bool
PreviewWindow WINDOW('Preview'),AT(,,495,332),FONT('Microsoft Sans Serif',8,,FONT:regular),SYSTEM,MAX,RESIZE,CENTER
LIST,AT(1,2,317,11),USE(?List:PreviewQ),VSCROLL,FONT(,10,,),DROP(10),FROM(PreviewQ)
BUTTON('&Print'),AT(332,1,41,11),USE(?PrintBtn)
IMAGE,AT(1,15),USE(?Image1),FULL,HVSCROLL
END
CODE
OPEN(PreviewWindow)
?List:PreviewQ{PROP:Selected}=1
?PrintBtn{PROP:Tip} = 'Print to ' & printer{PROPPRINT:Device}
ACCEPT
IF ACCEPTED()=?List:PreviewQ OR EVENT()=Event:OpenWindow
GET(PreviewQ,CHOICE(?List:PreviewQ))
?Image1{PROP:Text}=PreviewQ
DISPLAY
ELSIF ACCEPTED() = ?PrintBtn
PrintIt=True
BREAK
END
END
CLOSE(PreviewWindow)
IF PrintIt THEN REPORT{PROP:FlushPreview}=True.
exit
!----------------------------------------
DB PROCEDURE(STRING xMessage)
Prfx EQUATE('RptTest: ') !All output gets this
sz CSTRING(SIZE(Prfx)+SIZE(xMessage)+3),AUTO
CODE
sz = Prfx & CLIP(xMessage) & '<13,10>'
OutputDebugString( sz )
RETURN
DBClear PROCEDURE()
DVClr CSTRING('DBGVIEWCLEAR') !Message to Clear the buffer. Must UPPER and first i.e. without a Prefix
CODE
OutputDebugString(DVClr)
RETURN
!Test created for https://clarionhub.com/t/report-item-width-and-height/3629
! 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?
!
!How to measure STRING #1 on Report to position STRING #2 right after it
!Answer: Must not use a Picture STRING(@s20).
! Must use STRING('xxx') and PROP:Text to assign value then can get PROP:Width
!
!Report Test Framework by Carl Barnes from https://gist.github.com/CarlTBarnes
!-----------------------------------------------------------------------------
!Try various REPORT specs and PROP Settings quicky in this little Win32 project that has its own simple Previewer.
!If you want to report a bug this can be used to create a small example
!
!1. Create a new Win32 Project and paste this code.
!2. Add the Variables used on the REPORT - at #2 below
!3. Add Your REPORT and DETAIL's - at #3 below
!4. Add your PRINT() code and PROP code - at #4 below
!5. Run and Test, adjust code, repeat
!-----------------------------------------------------------------------------
PROGRAM !Report Test Framework by Carl Barnes
INCLUDE('PRNPROP.CLW')
MAP
DB(STRING DebugText) !Debug Output
DBClear() !Empty debug buffer
MODULE('WinAPI')
OutputDebugString(*cstring Msg),PASCAL,RAW,DLL(1),NAME('OutputDebugStringA')
END
END
!--The Stuff needed for Preview
PreviewQ QUEUE,PRE(PreQ)
FileName STRING(260)
END
!#2. >>>--Define your test data
AgentName STRING(30)
LicenseNo STRING(10)
!#3. >>>--Define your Report
Report REPORT,AT(1000,1000,6250,7688),FONT('Arial',10),PRE(RPT),PAPER(PAPER:A4),THOUS!,PREVIEW(PreviewQ)
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
!#4. >>>--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 !Just incase a width was defined in AT() on report
?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)
!----------------- Open Preview Window and display --------------------------
ReportPreviewRtn ROUTINE
DATA
PrintIt Bool
PreviewWindow WINDOW('Preview'),AT(,,495,332),FONT('Microsoft Sans Serif',8,,FONT:regular),SYSTEM,MAX,RESIZE,CENTER
LIST,AT(1,2,317,11),USE(?List:PreviewQ),VSCROLL,FONT(,10,,),DROP(10),FROM(PreviewQ)
BUTTON('&Print'),AT(332,1,41,11),USE(?PrintBtn)
IMAGE,AT(1,15),USE(?Image1),FULL,HVSCROLL
END
CODE
OPEN(PreviewWindow)
?List:PreviewQ{PROP:Selected}=1
?PrintBtn{PROP:Tip} = 'Print to ' & printer{PROPPRINT:Device}
ACCEPT
IF ACCEPTED()=?List:PreviewQ OR EVENT()=Event:OpenWindow
GET(PreviewQ,CHOICE(?List:PreviewQ))
?Image1{PROP:Text}=PreviewQ
DISPLAY
ELSIF ACCEPTED() = ?PrintBtn
PrintIt=True
BREAK
END
END
CLOSE(PreviewWindow)
IF PrintIt THEN REPORT{PROP:FlushPreview}=True.
exit
!----------------------------------------
DB PROCEDURE(STRING xMessage)
Prfx EQUATE('RptTest: ') !All output gets this
sz CSTRING(SIZE(Prfx)+SIZE(xMessage)+3),AUTO
CODE
sz = Prfx & CLIP(xMessage) & '<13,10>'
OutputDebugString( sz )
RETURN
DBClear PROCEDURE()
DVClr CSTRING('DBGVIEWCLEAR') !Message to Clear the buffer. Must UPPER and first i.e. without a Prefix
CODE
OutputDebugString(DVClr)
RETURN
!Existing report had poor logic to split Text accross multiple lines
!Simple way is to have a Split Band with a TEXT control with RESIZE
!The Split Band is Not Printed. Its use to read wrapped lines using Prop:Line
!This code may be from an older Rpt Test Frame work
PROGRAM !Report Test Framework
MAP
MODULE('Windows')
OutputDebugString(*CSTRING),PASCAL,RAW,NAME('OutputDebugStringA')
END
DB(STRING DBString)
END
!--The Stuff needed for Preview
PreviewQ QUEUE,PRE(PreQ)
FileName STRING(260)
END
!>>>--Define your test data
String1 STRING('string1')
String2 STRING(20) !empty
String3 STRING('string3')
String4 STRING('string4')
Test500 STRING('LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT. NDUM VIDERETUR, HAEC SUMMA IN ILLIS ESSE, SI IN NOBIS ESSENT SALTEM MEDIOCRIA; VERUM ITA SE RES HABET, UT EGO, QUI NEQUE USU SATIS ' &|
'ET INGENIO PARUM POSSUM, CUM PATRONO DISERTISSIMO COMPARER QUINCTIUS CUI TENUES OPES, NULLAE FACULTATES, EXIGUAE AMICORUM COPIAE SUNT, CUM ADVERSARIO GRATIOSISSIMO CONTENDAT. ILLUD QUOQUE ' &|
'NOBIS ACCEDIT INCOMMODUM, QUOD M. IUNIUS, QUI HANC CAUSAM ALIQUOTIENS APUD TE EGIT, HOMO ET IN ALIIS CAUSIS EXERCITATUS ET .' ) ! Length = 500
VenHdg:Name STRING('VENDOR TEST NAME')
MailingAddress STRING('Mailing Address Mailing Address Mailing Address')
VenCk:CkNo LONG(12345)
VenCk:CkDate LONG(80000)
StubDataGroup GROUP,PRE(STUB)
Desc STRING(120)
AcctNo STRING(35)
Amt DECIMAL(10,2)
END
Desc2Measure STRING(120*5)
LineNo LONG
!>>>--Define your Report with ,PREVIEW(PreviewQ) attribute
Report REPORT('Checks'),AT(0,0,8500,11000),FONT('Arial',8,,FONT:regular,CHARSET:ANSI),PRE(RPT), |
PAPER(PAPER:LETTER),THOUS
DetailHello DETAIL,AT(0,0),USE(?DetailHello)
STRING('Below are lines split'),AT(83,10),USE(?STRING1)
END
BottomStub DETAIL,AT(500,0,8500,1000),USE(?BottomStub)
BOX,AT(0,188,7500,180),USE(?Box2b),COLOR(COLOR:Black),FILL(COLOR:Silver),LINEWIDTH(1)
STRING(@s80),AT(0,10,3300),USE(VenHdg:Name,, ?VenHdg:Name:3)
STRING('CHECK NO.:'),AT(3417,10),USE(?StubCkNoLit:3),TRN
STRING(@n_6),AT(4063,10),USE(VenCk:CkNo,, ?VenCk:CkNo:4),RIGHT(1)
STRING(@d02),AT(4625,10),USE(VenCk:CkDate,, ?VenCk:CkDate:4)
STRING('INVOICE NO. & DESCRIPTION'),AT(21,198),USE(?DescLit:3),TRN
STRING('ACCOUNT NUMBER'),AT(5594,198),USE(?AcctNoLit:3),TRN
STRING('AMOUNT'),AT(7010,198),USE(?AmtLit:3),TRN
STRING(@s150),AT(0,354,7500,167),USE(MailingAddress)
STRING(@s200),AT(21,500,6650,167),USE(STUB:Desc),TRN,LEFT
STRING(@s35),AT(4604,500,2083),USE(STUB:AcctNo),TRN,RIGHT
STRING(@n-15.2b),AT(6604,500,948),USE(STUB:Amt),TRN,RIGHT
END
DetailText1 DETAIL,AT(500,0,8500,167),USE(?DetailText1)
STRING(@s200),AT(21,0,6650,167),USE(STUB:Desc,, ?STUB:Desc:2),TRN,LEFT
STRING(@s35),AT(4604,0,2083),USE(STUB:AcctNo,, ?STUB:AcctNo:2),TRN,RIGHT
STRING(@n-15.2b),AT(6604,0,948),USE(STUB:Amt,, ?STUB:Amt:2),TRN,RIGHT
END
DetailText DETAIL,AT(500,0,8500),USE(?DetailText)
TEXT,AT(500,162,4615),USE(Test500),RESIZE
STRING('12-45-789012-4-6789-123-56'),AT(4604,5,2083),USE(?PlaceHolder:AcctNo),TRN,RIGHT
STRING('NNNNNNNNNNNNNNNNNNNNNNNNNN'),AT(4604,5+167,2083),USE(?PlaceHolder:AcctNo2),TRN,RIGHT
STRING('99999999999999999999999999'),AT(4604,5+322,2083),USE(?PlaceHolder:AcctNo3),TRN,RIGHT
STRING(@n-15.2b),AT(6604,5,948),USE(?PlaceHolder:Amt),TRN,RIGHT
END
END
CODE
!--Create Report
OPEN(Report)
Report{PROP:Preview}=PreviewQ
Stub:Desc = '5011837 DYSLEXIA CONFERENCE 3/3/21 E.AHRENS, A.BOOTH P.O. # E0638'
Stub:AcctNo = '12-45-789012-4-6789-123-56'
Stub:Amt = 112345
!>>>--Add your code to produce the report
PRINT(Rpt:BottomStub)
PRINT(Rpt:DetailHello)
SETTARGET(Report)
LOOP LineNo=1 TO ?Test500{PROP:LineCount}
STUB:Desc = ?Test500{PROP:Line,LineNo}
STUB:AcctNo=LineNo &'-'& LineNo &'-'& LineNo &'-'& LineNo &'-'& LineNo
STUB:Amt=LineNo * 100
PRINT(Rpt:DetailText1)
END
SETTARGET()
!--Report done, prepare it for preview
ENDPAGE(Report)
! CLOSE(Report) loses files
!--Preview the report
DO ReportPreviewRtn
CLOSE(Report)
!----------------- Open Preview Window and display --------------------------
ReportPreviewRtn ROUTINE
DATA
PreviewWindow WINDOW('Preview'),AT(,,595,332),FONT('MS Sans Serif',8,,FONT:regular),SYSTEM,MAX,RESIZE
LIST,AT(1,2,245,11),USE(?List:PreviewQ),DROP(10),FROM(PreviewQ),VScroll,FONT(,10),CENTER
IMAGE,AT(1,15),USE(?Image1),FULL ,hvscroll
END
CODE
OPEN(PreviewWindow)
?List:PreviewQ{PROP:Selected}=1
ACCEPT
IF ACCEPTED()=?List:PreviewQ OR EVENT()=Event:OpenWindow
GET(PreviewQ,CHOICE(?List:PreviewQ))
?Image1{PROP:Text}=PreviewQ
DISPLAY
END
END
CLOSE(PreviewWindow)
!----------------------------------------
DB PROCEDURE(STRING DBString)
DBC CSTRING(256)
CODE
DBC = CLIP(DBString)
OutputDebugString(DBC)
RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment