SIMPLE4 – constants, color, expressions |
Top Previous Next |
This rule set demonstrates the use of constants, graphical shading, colors, and expressions to produce explanatory notes in the document. To produce this sample, use this command:
uf101c –i sample1.txt –f simple.rul –r simple4 –p pdf –o client:simple4.pdf
A title header prefixes all rule sets, which is just a unique name enclosed in brackets. [simple4] # to use this rule set, you need to FORCE the rule set with the -r option # or remark (#) out the detect command in the rule sets above. # # This rule set takes the rule set above and improves it by adding # constants, graphical shading, increases the resolution, # and adds explanatory text commands for cust # and ship to #. # # Also adds a copy for a packing slip with no prices.
dsn_sample "sample1.txt" detect 61,5,"~../../.. ......." # invoice date and # detect 9,11,"~......" # customer code detect 10,21,"~../../.. ......" # ord date and cust code
Constants are simple text names that are replaced by values later in the rule set. They can be used to simplify maintenance of the rule set, or to make it easier to read. In this example, a series of constants is defined using the const command, and you will find the names referenced throughout the balance of the rule set.
const MAXCOLS=80 # max cols to output const MAXRCOLS=79 # MAXCOLS-1 const LEFTCOL=.5 # use 1 if empty const RIGHTCOL=80.5 # use LEFTCOL for symmetry const MAXROWS=66 # max rows to output
cols MAXCOLS rows MAXROWS
# copies const CUSTOMER_COPY=1 const FILE_COPY=2 const PACK_COPY=3 pcopies 3
The dpi setting applies to laser output only, and instructs the printer to produce output at 600 dpi, providing a typically crisper, more professional look. In addition, the gs on command turns on graphical shading mode, so that shade regions and shaded text are rendered as graphical data rather than using pcl's internal, typically coarse, shade macros.
dpi 600 gs on # turn on graphical shading
# enhancement constants const HSHADE=30 const ISHADE=20 const DSHADE=10 const HFONT=univers,11 const IFONT=univers,italic,10 const DFONT=cgtimes,10 const DBFONT=DFONT,bold
# header section cbox LEFTCOL,.5,RIGHTCOL,{MAXROWS+.5},5 image 1,1,12,6,"sdsilogo.pcl" text 1,2,"Company Name",HFONT,14,bold,center,cols=MAXRCOLS text 1,3,"Company Address\nCompany City, St Zipcode\nCompany Phone",HFONT,12,bold,center,cols=MAXRCOLS text 1,6,"Web: www.myweb.com\nEmail: sales@myweb.com",HFONT,bold,center,cols=MAXRCOLS text 1,2,"INVOICE",HFONT,16,bold,right,cols=MAXRCOLS
# invoice # section cbox 67,4,RIGHTCOL,10,1,crows=6 8,ccols=74::ISHADE text 68,5,"Date",IFONT text 68,7,"Invoice",IFONT text 68,9,"Page #",IFONT # cut data from old position and place in new text 75,5,{cut(61,5,8,"")},DBFONT text 75,7,{cut(71,5,7,"")},DBFONT text 75,9,{cut(79,5,2,"")},DBFONT
The cbox command shown here uses constants defined above, plus shows the use of color options, which are supported by PDF and color laser output. In this example, the interior is colored in cyan, and the lines are colored in blue. Alternately, RGB hex triplets (such as 800000 for dark red) can be specified using the rgb, scolor rgb, or lcolor rgb options.
# bill to / ship to section cerase 1,11,MAXCOLS,11 # erase cust#,ship# used later in text commands cbox LEFTCOL,11,RIGHTCOL,18.5,5,cyan,lcolor=blue,ccols=7::ISHADE 43.5 50::ISHADE text 2,12,"Sold To",IFONT,center,cols=5 cfont 8,11,40,11,DBFONT,left cfont 8,12,40,15,DBFONT # sold to address
This text command shows an example of how to use an expression to construct a message using a combination of hard-coded text and information from the data stream. In this example, the phrase "Your customer code is" is concatenated with the data at column 9, row 11, for 6 characters, on each page, and the result is printed at column 9, row 18, using the specifications provided by the constant IFONT, defined earlier in the rule set.
text 8,18,{"Your customer code is "+get(9,11,6)+"."},IFONT
text 45,12,"Ship To",IFONT,center,cols=5 cfont 51,11,80,11,DBFONT,left text 51,12,{mcut(51,12,30,4,"","Y","Y")},DBFONT text 51,18,{"Your ship to code is "+get(55,11,6)+"."},IFONT
# ribbon section cbox LEFTCOL,18.5,RIGHTCOL,22.5,5,lcolor=blue,crows=20.5::ISHADE:cyan,ccols=9 18 25 65 # special internal grid in ribbon box cbox 29,18.5,65,21.5 cbox 42,18.5,56,21.5 text 1,19,"Order\nNumber",IFONT,center,cols=8 text 10,19,"Order\nDate",IFONT,center,cols=8 text 19,19,"Cust.\nNumber",IFONT,center,cols=6 text 26,19,"Sls\nPrs",IFONT,center,cols=3 text 30,19,"Purchase\nOrder No.",IFONT,center,cols=12 text 43,19,"\nShip Via",IFONT,center,cols=13 text 57,19,"Ship\nDate",IFONT,center,cols=8 text 66,19,"\nTerms",IFONT,center,cols=14
cfont 1,21,8,21,DBFONT,center # order # cfont 10,21,17,21,DBFONT,center # order date cfont 19,21,24,21,DBFONT,center # cust # cfont 26,21,28,21,DBFONT,left # sls prs code cfont 26,22,64,22,DBFONT,left # sls prs name cfont 30,21,41,21,DBFONT,center # po # cfont 43,21,55,21,DBFONT,center # ship via cfont 57,21,64,21,DBFONT,center # ship date cfont 66,21,80,22,DBFONT,center # terms
# detail section if copy PACK_COPY erase "~\.[0-9][0-9]@62,25,79,56",-6,0,11,1 endif cbox LEFTCOL,22.5,RIGHTCOL,56.5,5,crows=24.5::DSHADE,ccols=5 10 16 51 55 67 text 1,23,"Qty\nOrd",IFONT,right,cols=4 text 6,23,"Qty\nShip",IFONT,right,cols=4 text 11,23,"Qty\nBkord",IFONT,right,cols=4 text 17,23,"\nItem & Description",IFONT text 52,23,"\nU/M",IFONT,center,cols=3 text 56,23,"Unit\nPrice",IFONT,right,cols=11 text 68,23,"Extended\nPrice",IFONT,right,cols=12
cfont 1,25,4,56,DBFONT,right # qty ord cfont 6,25,9,56,DBFONT,right # qty shipped cfont 11,25,15,56,DBFONT,right # qty b/o cfont 17,25,50,56,DFONT,left # item # & desc cfont 52,25,54,56,DBFONT,center # u/m cfont 56,25,66,56,DBFONT,right # unit price cfont 68,25,79,56,DBFONT,right # extended
# memo section font " @1,25,4,56",17,0,60,1,DFONT,left
# watermark if copy CUSTOMER_COPY,FILE_COPY text 1,56,"INVOICE",DFONT,120,shade=DSHADE,center,cols=MAXCOLS,fit endif if copy PACK_COPY text 1,56,"PACK SLIP",DFONT,120,shade=DSHADE,center,cols=MAXCOLS,fit endif
# footer section cbox 57,57,RIGHTCOL,65,lcolor=red,crows=59 63,ccols=67::HSHADE text 58,58,"Sales Amt",HFONT cfont 58,60,66,60,HFONT,left text 58,61,"Sales Tax",HFONT text 58,62,"Freight",HFONT text 58,64.25,"TOTAL",HFONT,bold,14 cfont 68,58,79,65,DBFONT,right,14 # totals
text 2,58,"Customer code as 3 of 9 barcode",IFONT barcode 2,58.67,{get(9,11,6)},400,14.0,4
Note the use of constants to make this section easier to read.
# copy name section if copy CUSTOMER_COPY text 1,65.5,"Customer Copy",HFONT,12,bold,center,cols=MAXCOLS end if if copy FILE_COPY text 1,65.5,"Accounting Copy",HFONT,12,bold,center,cols=MAXCOLS end if if copy PACK_COPY text 1,65.5,"Packing Slip",HFONT,12,bold,center,cols=MAXCOLS end if
This text line demonstrates the use of multi-line text forced to fit within a certain number of columns. UnForm scans each of the two lines (delimited by the \n character sequence, or it could contain data with line-feed or carriage-return line-feed delimiters) to determine the width, beginning with the point size 12 specified in the command. The size is reduced until both lines will fit within the 20 columns specified with the cols option. Once the correct point size is determined, the lines are spaced normally for that height. For example, if the size required is 8.25 points, then the lines will be spaced 8.25 points apart. If spacing had been set to 1.5, then the lines would be spaced 12.33 points apart.
text 2,62,"This sample message text, which contains\nline breaks, is sized to fit in 20 columns.",cols 20,cgtimes,12,fit,spacing 1
|