I have created a GUI program (to be compiled) that some of my users will be using to print par code labels. To do this, I need to create a file that contains WPL (Wasp Printer Language). Only a few small parts of this data will change depending on the options submitted, so I thought I would use a "template" text file that will be parsed, and some sort of "variable" syntax will be included so that a find & replace is performed, and the new resulting text file would have the "variables" replaced with the data to reflect what the user selected in the form.
I am picturing something akin to an HTML template file...
EXAMPLE: (This is just a demonstration. I will tackle exactly how the syntax will work before I focus too much time on the specifics of this syntax. I am going to use "$" vars, since that is easy for me to relate to and tell apart for this example.)
-----------BEFORE--------------
SIZE $mediaWidth, $mediaHeight
DENSITY 7
SPEED 4
DIRECTION 1
KILL "*"
CLS
BARCODE $locLeft,$locRight,"$type",196,1,0,2,4,$identifier
PRINT 1,$prtCnt
--------------------------------
$mediaWidth = 2.25
$mediaHeight = 1.25
$locLeft = 76
$locRight = 17
$type = EAN13+5
$identifier = 97816061102052500
$prtCnt = 22
(Template file is then parsed, and vars are replaced. The final version (below) is written to a temp file, where it is then sent to the printer as a raw message.
Please let me know if you need more information. I am happy to fill in the holes.
Thanks,
Chay D. Butler (New Leaf Distributing)
-----------AFTER--------------
SIZE 2.25, 1.25
DENSITY 7
SPEED 4
DIRECTION 1
KILL "*"
CLS
BARCODE 76,17,"EAN13+5",196,1,0,2,4,"97816061102052500"
PRINT 1,22