Module cWmlReport.pkg
1Use cWebReport.pkg
2Use WmlEncode.pkg // global WmlLEncode Function
3Use WmlFormat_mixin.pkg // WML helper mixin and functions
4Use WmlWrite_mixin.pkg // " "
5
6{ ClassLibrary=WebApp }
7{ HelpTopic=cWmlreport }
8Class cWMLReport is a cWebReport
9
10 Procedure Construct_Object
11 Forward Send Construct_Object
12 // these should be set in object
13 Property Integer piWmlMaxLength 0 // Maximum suggested length for output. if 0, no limit
14 Property Integer piItemsPerCard 0 // Number items allowed per card. if 0, no limit
15 // system maintained
16 { Visibility=Private }
17 Property Integer piCardCount // current item within card
18 { Visibility=Private }
19 Property Integer piCardNum // current card number
20 { Visibility=Private }
21 Property Integer pbNextCard // break is a next card condition
22 { Visibility=Private }
23 Property Integer pbNextDeck // break is a next deck condition
24
25 Property Integer piWmlLength // current length of WML output at start of new record
26 End_Procedure
27
28 // helper wml tag functions
29 Import_Class_Protocol WmlFormat_Mixin
30 Import_Class_Protocol WmlWrite_Mixin
31
32 // augment to keep track of WML output length
33 Procedure WriteWml string sVal
34 integer iLen
35 Move (length(trim(sVal))) to ilen
36 set piWmlLength to (piWmlLength(self)+iLen)
37 //showln "wmllen " (piWmlLength(self))
38 send WriteHtml sVal
39 End_procedure
40
41 // augment to check if maximum length is exceeded
42 { NoDoc=True }
43 Function HaltReport integer iBreakLevel Returns integer
44 integer bHalt iMax
45 Forward get HaltReport iBreakLevel to bHalt
46 Get piWmlMaxlength to iMax
47 If (not(bHalt) and iMax>0 and piWmlLength(self)>iMax) move 1 to bHalt
48 if bHalt Set pbNextDeck to true
49 function_return bHalt
50 End_function
51
52 // The breakpoint function must return the value to be tested for a break
53 { Visibility=Private }
54 Function BreakCard returns String
55 integer iCount iNum iItems
56 set pbNextCard to False
57 get piCardNum to iNum
58 get piItemsPerCard to iItems
59 If iItems Begin
60 get piCardCount to iCount
61 If (iCount>=iItems) Begin
62 Increment iNum
63 Set piCardNum to iNum
64 Move 0 to iCount
65 Set pbNextCard to True
66 end
67 set piCardCount to (iCount+1)
68 //showln "card count " iCount
69 End
70 Function_Return iNum //each time this changes, a break occurs
71 End_Function
72
73 { Visibility=Private }
74 Function Setup_Report Returns Integer
75 integer iRet
76 Set piCardNum to 0
77 Set piCardCount to 0
78 Set piWmlLength to 0
79 Set pbNextDeck to False
80 Set pbNextCard to False
81 Forward Get Setup_report to iRet
82 Function_return iRet
83 End_Function
84
85 // if there is a card item limit, define the card item check breakpoint
86 { MethodType=Event NoDoc=True }
87 Procedure OnInitBreakpoints
88 integer iItems
89 get piItemsPerCard to iItems
90 If iItems ;
91 Send RegisterBreakpoint get_BreakCard // Function Break must be defined
92 Forward Send OnInitBreakPoints
93 End_Procedure
94
95 // function for creating WML links. Note that a content value and a title must be passed.
96 { Obsolete=True }
97 Function AddWmlRecordLink string sValue string sTitle Returns String
98 string sRefName sUrl sRec sSep
99 Get psHRefName to sRefName
100 If (sRefName<>"") Begin
101 If (right(sRefName,1)="?") ; // in WML ? is valid and means, link to self.
102 Move "" to sSep // if href ends in ?, we already have the separator
103 else ; // else, if no ? it is first parm (use ?), else it is nth param (use &)
104 Move (If(pos("?",sRefName),"&","?")) to sSep // wml wants & for &
105 Get Current_record of (server(self)) to sRec
106 Move (sRefName-sSep-"RecId="-sRec ) to sUrl
107 Get WmlLink sUrl sValue sTitle to sValue
108 end
109 //
110 Function_Return sValue
111 End_Function
112
113 // function for creating WML links. Note that a content value and a title must be passed.
114 Function AddWmlRowIdLink string sValue string sTitle Returns String
115 string sRefName sUrl sRowId sSep
116 RowId riRowId
117 Get psHRefName to sRefName
118 If (sRefName<>"") Begin
119 If (right(sRefName,1)="?") ; // in WML ? is valid and means, link to self.
120 Move "" to sSep // if href ends in ?, we already have the separator
121 else ; // else, if no ? it is first parm (use ?), else it is nth param (use &)
122 Move (If(pos("?",sRefName),"&","?")) to sSep // wml wants & for &
123 Get CurrentRowId of (server(self)) to riRowId
124 Move (SerializeRowId(riRowId)) to sRowId
125 Move (sRefName-sSep-"RowId="- sRowId ) to sUrl
126 Get WmlLink sUrl sValue sTitle to sValue
127 end
128 //
129 Function_Return sValue
130 End_Function
131
132
133
134End_Class
135
136
137