Return to Tech Tip Article Part I
Tech Tips -
Part II
UnForm
Using Text-Anchors for Relative Enhancements
Anchoring Demonstration
We've written an
anchoring sample rulefile to demonstrate the use of relative commands in
action.
If you
have the UnForm GUI Design Tool you can very easily view this sample in an
integrated environment, edit text anchor coordinates right inside the
rule file, and observe the graphic enhancements move around on the page.
Use this link view and save the full TechTip
rule file
Each
section of the rule file is displayed and discussed briefly further down in this
article.
Copy 1
Plain
This
is a sample of plain text coming into UnForm before any enhancements. The
TechTip rule file actually generates this text in a merged-in prepage code-block
and a sample text file is NOT needed. It is then output as copy 1 of the
document, with just the copy title in large bold text at the bottom of the page
added as an enhancement.
Copy 2,
with anchored enhancements
Copy 2 shows text-anchored fonts, boxes and text applied to the "Total" anchors.
In the demo each total label has a different anchor command since the number of
grid boxes and the boldness of the border lines for the box changes with the
indentation of the Total label. In Copy 2 only Total labels are enhanced, none
of the other text lines have any formatting applied.
Copy 3,
adding some embedded anchors
In
Copy 3, added to the anchored Total label enhancements from the previous copy,
there are additional enhancements which come from the use of embedded anchors.
The text above each of the first two Total sections is enhanced in a unique font
by embedding section top and bottom anchors in the text and then saving
section top and bottom row counts in a code-block variable so that the number of
rows to enhance can be provided in an expression.
Also
in Copy 3, section 3 is enhanced off the "Ln Item" text anchor at the top
left of the text block, with different fonts for alternating grid columns, a
separate font anchor for the Serial number line, the addition of a dingbat-font
image of a pointing-finger to the Serial number line, and an embedded anchor for
any line with a back-order quantity greater than zero which which prints a
dingbat-font image of a telephone.
Copy 3,
order-line section moved
In
this sample, the order-line section was moved over and down several columns and
rows using the cmove command, illustrating the same enhancements getting
applied with the anchor in a different position on the page.
Text-Anchor Tech Tip
Sample and Rule File
NewsTechTip
Ruleset
This is the base controlling
rule set for the anchoring demonstration. For this exercise
we chose to
break out some aspects of the rule set into
separate rulesets which are then merged into the
controlling ruleset via the merge command.
This illustrates a way to organize the logic of a
ruleset into separate components, especially in a
situation where multiple rulesets need to duplicate
the same logic. The "z_" prefix used for the
merge rulesets was just a naming convention so that
these rulesets would appear after the main
controlling ruleset in the GUI design tools ruleset
selection window. The [z_TextIn] ruleset
loads original raw text on the page, what usually is
coming into UnForm in the print stream, and the [z_Prepage]
ruleset has the prepage code-block logic for
embeeding anchors.
[NewsTechTip]
cols 80
rows 66
portrait
const RTCOL=80
const SHD=25
const FNT=univers
pcopies 3
# Anchor demo constants
# min 10 between anchors
# except where otherwise specified
const AN1=7 # anchor 1 row, min=6 for demo
const AN2=20 # anchor 2 row
# lv at least 18 betw 2 & 3 for demo
const AN3=40 # anchor 3 row
const AN4=55 # anchor 4 row, max=60 for demo
const WT1=1 # anchor 1 box line weight
const WT2=7 # anchor 1 box line weight
const WT3=12 # anchor 1 box line weight
const WT4=20 # anchor 1 box line weight
# create text on page for demo
merge "z_TextIn"
# do prepage to embed anchors, set col/row variables
const ANCHOR1="Ln Item" # anchor text
merge "z_Prepage"
if copy 1
text 1,66,{"Copy "+str(copy)+" plain"},courier,4
end if
if copy 2,3
text 1,66,{"Copy "+str(copy)},courier,4
font "Customer Total",0,0,20,1,FNT,14,bold
text "Customer Total",0,2,"size 14",FNT,14
box "Customer Total",20,-1,{RTCOL-22},4,WT1,irows 2::SHD 4,icols 10 20
30 40 50
font "SalesRep Total",0,0,20,1,FNT,18,italic
text "SalesRep Total",0,2,"size 18",FNT,18,italic
box "SalesRep Total",20,-1,{RTCOL-32},4,WT2,irows 2:WT2:SHD 4:WT2,icols
10:WT2 20:WT2 30:WT2 40:WT2 50:WT2
font "Territory Total",0,0,20,1,FNT,22
text "Territory Total",0,2,"size 22",FNT,22
box "Territory Total",20,-1,{RTCOL-42},4,WT3,irows 2:WT3:SHD 4:WT3,icols
10:WT3 20:WT3 30:WT3
font "Grand Total",0,0,20,1,FNT,26
text "Grand Total",0,2,"size 26",FNT,26
box "Grand Total",20,-1,{RTCOL-52},4,WT4,irows 2:WT4:SHD 4:WT4,icols
10:WT4 20:WT4 30:WT4
end if
if copy 3
font "^Top1",0,1,{btm1col},{(btm1row-top1row)-1},cgtimes,8,italic,center
erase "^Top1",0,0,5,1
erase "^Btm1",0,0,5,1
font "^Top2",0,1,{btm2col},{(btm2row-top2row)-1},univers,10,bold,right
erase "^Top2",0,0,5,1
erase "^Btm2",0,0,5,1
text "^Top4",10,2,"REPLACEMENT TEXT FOR SECTION 4",univers,18
erase "^Top4",0,0,{btm4col+5},{(btm4row-top4row)}
erase "^Btm4",0,0,5,1
# do section 3 'lines'
const FONTL=cgtimes,10
const FONTH=univers,10,italic
cmove 1,{top3row},RTCOL,{btm3row},2,{top3row}
# cmove 1,{top3row},RTCOL,{btm3row},11,{top3row+2}
box "Ln Item",-1,-1,70,{btm3row-top3row+1},1,irows 1.5::SHD,icols 5 15
26 34 42 50 58
const LROWS={btm3row-top3row-1}
text "Ln Item",1,-1.5,"Anchored Section 3 B - using fixed
positions",FNT,18,italic
font "Ln Item",0,0,2,1,FONTH,center
font "Ln Item",0,1,2,LROWS,FONTL,center
font "Ln Item",5,0,9,1,FONTH
font "Ln Item",5,1,9,LROWS,FONTL
font "Ln Item",15,0,10,1,FONTH
font "Ln Item",15,1,10,LROWS,FONTL
font "Ln Item",26,0,7,1,FONTH,right
font "Ln Item",26,1,7,LROWS,FONTL,right
font "Ln Item",34,0,7,1,FONTH,right
font "Ln Item",34,1,7,LROWS,FONTL,right
font "Ln Item",42,0,7,1,FONTH,right
font "Ln Item",42,1,7,LROWS,FONTL,right
font "Ln Item",50,0,7,1,FONTH,right
font "Ln Item",50,1,7,LROWS,FONTL,right
font "Ln Item",58,0,11,1,FONTH,right
font "Ln Item",58,1,11,LROWS,FONTL,right
# note: if section 3 changes rows this
# row or col range may need to change
font "Serial No@15,20,35,40",0,0,40,1,FONTH,10,italic
text "Serial No@15,20,35,40",-4,0.25,<42>,font 4141,symset 9J,14
text "}",2,0.25,<37>,font 4141,symset 9J,14
erase "}",0,0,1,1
end if
|
Notes to the main
TechTip ruleset
Copy 1 is
just the plain text with no enhancements to the
page, except for a copy number and copy description
in large mono-spaced courier font at the bottom.
Copy 2 has anchor-based enhancements for
the "Total" labels. The font, text and box commands
are all relative to the the specific Customer, SalesRep, Territory, or Grand Total labels. There's
a different font style and size, text label and
size, and box size for each total type. Note that
FNT, SHD, RTCOL, and WT1 through WT4 are
constants with values set in a previously merged
rule set.
Copy 3
uses anchors which were embedded in a prepage code-block, and also uses
code-block variables surrounded by { } to specify the column and row count
for each section's enhancement. The section 3 enhancement for the order-lines
are merged in from a separate ruleset.
The [z_Prepage]
ruleset is merged in before processing
enhancements, and contains the embedding of anchors
and setting of the column and row variables needed
for the embedded anchoring.
[z_Prepage]
# merge code
prepage {
# Embed some anchors for copy 3 enhancements
text$[3]="^Top1",text$[AN1-1]=fill(75)+"^Btm1"
text$[AN1+6]="^Top2",text$[AN2-1]=fill(75)+"^Btm2"
text$[AN3+6]="^Top4",text$[AN4-1]=fill(75)+"^Btm4"
anchortext$="Ln Item"
# reset variables from last page
top1col=0,top1row=0,btm1col=0,btm1row=0
top2col=0,top2row=0,btm2col=0,btm2row=0
top4col=0,top4row=0,btm4col=0,btm4row=0
top3col=0,top3row=0,btm3row=0
for i=1 to 66
txt$=pad(text$[i],80)
if top1col=0 top1col=pos("^Top1"=txt$); if top1col top1row=i
if btm1col=0 btm1col=pos("^Btm1"=txt$); if btm1col btm1row=i
if top2col=0 top2col=pos("^Top2"=txt$); if top2col top2row=i
if btm2col=0 btm2col=pos("^Btm2"=txt$); if btm2col btm2row=i
if top4col=0 top4col=pos("^Top4"=txt$); if top4col top4row=i
if btm4col=0 btm4col=pos("^Btm4"=txt$); if btm4col btm4row=i
# 'lines' section 3
if top3col=0 top3col=pos(anchortext$=txt$); if top3col top3row=i
if (top3col>0 and btm3row=0 and trim(txt$)="") btm3row=i
# flag back order for phone dingbat
if (top3row>0 and i<>top3row and btm3row=0 and num(txt$(41,7),err=next)<>0)
then text$[i](43,1)="}"
next i
}
|
The [z_TextIn]
ruleset is an "artificial" ruleset that just defines the raw text to place
on the page, and contains the prepage code-block to populate the page with the
raw text. The text$/u0/pv/pvx variable is the UnForm system variable that
contains an array of every raw text line on the page. The size of the array will
already have been initialized by UnForm to the value of rows at
the top of the ruleset. This ruleset uses constants also since it might be
repeating lines of text depending on the settings of the anchor text constants
previously mentioned.
[z_TextIn]
const TXIN1=" Section 1 at page top Serial No xx "
const TXIN2=" This is section 2 text under above "
const TXIN4=" This is section 4 text at bottom "
const TXIN3A ="Ln Item Desc OrQty ShQty BoQty Price Extension"
const TXIN3B1="1 110-1 Widget 1 1 1 0 1.00 1.00"
const TXIN3B2="2 110-2A Widget 2 2 2 0 2.00 4.00"
const TXIN3B3="3 110-3 Widget 3 3 1 2 3.00 3.00"
const TXIN3B4="4 110-4B Widget 4 4 4 0 4.00 16.00"
const TXIN3B5="5 110-5 Widget 5 5 4 1 5.00 20.00"
const TXIN3B6=" Serial No 89"
const TXIN3B7="6 110-6CD Widget 6 6 6 0 6.00 36.00"
const TXIN3B8="7 110-7 Widget 7 7 7 0 7.00 49.00"
prepage {
for row=4 to AN1-2;text$[row]=" TXIN1"+" TXIN1";next
row
text$[AN1] =fill(1) +"Customer Total"
for row=AN1+7 to AN2-2;text$[row]=" TXIN2"+" TXIN2";next
row
text$[AN2]=fill(11)+"SalesRep Total"
cnt=0
for row=AN2+7 to AN3-2
if cnt=0 text$[row]="TXIN3A"
if cnt=1 text$[row]="TXIN3B1"
if cnt=2 text$[row]="TXIN3B2"
if cnt=3 text$[row]="TXIN3B3"
if cnt=4 text$[row]="TXIN3B4"
if cnt=5 text$[row]="TXIN3B5"
if cnt=6 text$[row]=fill(15)+"TXIN3B6"
if cnt=7 text$[row]="TXIN3B7"
if cnt=8 text$[row]="TXIN3B8"
cnt=cnt+1
next row
text$[AN3]=fill(21)+"Territory Total"
for row=AN3+7 to AN4-2;text$[row]=" TXIN4"+" TXIN4";next
row
text$[AN4]=fill(31)+"Grand Total"
}
|
Return to Tech Tip Article Part I
|