home *** CD-ROM | disk | FTP | other *** search
- This useful hint outlines how to set up for just about any sort of labels.
-
- It can handle the situation where "half labels" appear at the top and bottom
- of the sheet of labels. It can also handle the case where the number of
- labels per sheet does not divide exactly into the number on lines per sheet,
- and of course standard tractor feed labels are also supported.
-
-
- 1) Create a function file, LABELS.FUN and add the following code to it.
-
- #define MAXLABELSPERPAGE 20 /* Maximun labels in the first column */
-
- int labelLines[MAXLABELSPERPAGE+1];
-
- void setupForLabels(void)
- /*
- A call to this procedure will n2eed to be added to a custom report skeleton.
- This is where all the label dimensions and spacing are determined.
- */
- {
- int i, j, gap, adjustBy, orphanLines;
- int linesPerLabel, linesPerSheet, labelsPerPage;
-
- num_across[1] = ival(GET_NUM_ACROSS);
- gap = space_across[1] - width_across[1];
- space_across[1] = ival(GET_WIDTH);
- width_across[1] = space_across[1] - gap;
- headerstruct[PGHDR] = ival(GET_TOP_MARGIN);
- headerstruct[PGFTR] = ival(GET_BOTTOM_MARGIN);
- labelsPerPage = ival(GET_NUM_LABELS);
-
- linesPerSheet = pagelength - headerstruct[PGHDR] - headerstruct[PGFTR];
- linesPerLabel = linesPerSheet / labelsPerPage;
- orphanLines = linesPerSheet % labelsPerPage;
- bandlinestruct[1].d = linesPerLabel;
-
- if (orphanLines <= (labelsPerPage/2))
- adjustBy = 1;
- else {
- adjustBy = -1;
- linesPerLabel++;
- orphanLines = labelsPerPage - orphanLines;
- }
-
- for (i=1; i<=MAXLABELSPERPAGE; i++) {
- if (i <= labelsPerPage)
- labelLines[i] = linesPerLabel;
- else
- labelLines[i] = 0;
- }
-
- if (orphanLines != 0) {
- bandlinestruct[1].d++;
- j = labelsPerPage / orphanLines;
- if (adjustBy > 0) {
- for (i=labelsPerPage; i >= (labelsPerPage-orphanLines+1); i--)
- labelLines[i-(i-1)*j] += adjustBy;
- }
- else {
- for (i=1; i<=orphanLines; i++)
- labelLines[i+(i-1)*j] += adjustBy;
- }
- }
- }
-
- bool labelLineOK(int labelLineNo)
- /*
- This function is passed a label line number, and using the global page line
- number counter, "lineno", determines if the label being printed can print
- on the line passed (based on hte number of lines per label established by
- the calculations in setupForLabels).
- */
- {
- int i, lno;
-
- i = 1; lno = lineno - headerstruct[PGHDR];
- while ((lno > labelLines[i]) && (i < MAXLABELSPERPAGE)) {
- lno -= labelLines[i];
- i++;
- }
- return(labelLineNo == lno);
- }
-
-
- 2) Create a custom report skeleton. This is necessary because you need to
- insert a call to the "setupForLabels()" function into the
- "initializeReport()" function in the standard report skeleton. The reason
- the function call must be inserted at this point (rather than using a
- compute field on the filter for example), is that it must be done after
- the report's "allocate" routine has been run. This because of the
- internal variables that are altered by "setupForLabels".
-
- Copy the standard report skeleton to a skeleton for labels
-
- COPY DBCREP.SKL LABELS.SKL
-
- Now edit LABELS.SKL and at the begininig of the "initializeReport()"
- function add the line "setupForLabels();"
-
- void initializeReport(void)
- {
- ...
-
- setupForLabels(); /* <-- Insert this line */
- clrscr();
- screenSave = deltas;
- deltas = 0;
- okStatus = True;
- ...
-
-
- 3) The third step is to design a report filter, LABELREP.DS. Make sure you
- use exactly the same the filter variable names that have already used in
- the code for "setupForLabels()".
-
- The filter needs to prompt the user for :--
-
- number of lines per sheet of labels - GET_NUM_LINES
- number of lines in any "half label" at the top - GET_TOP_MARGIN
- number of lines in any "half label" at the bottom - GET_BOTTOM_MARGIN
- number of labels in the first column of the sheet - GET_NUM_LABELS
- number of labels across the page - GET_NUM_ACROSS
- total width of each label in characters - GET_WIDTH
-
- The filter should also have a compute field to set the report page length
- to what ever the user has specified in "GET_NUM_LINES". That is the
- "Compute Expression" should be : pagelength = ival(GET_NUM_LINES).
-
- You may also want to use other filter fields like selecting (and setting),
- the output device, and setting up variables to specify the range of labels
- that are to be printed.
-
-
- 4) When designing the report specify the filter screen (LABELREP.DS),
- mentioned in step 3 (use Filter/Specify).
-
- Make sure you add the function file name, "LABELS.FUN" to the list of
- include files for the report (use Universal/Include Files).
-
- When you design the labels they should be in band one as the code in
- "setupForLabels()" assumes this (references to num_across[1],
- space_across[1], width_across[1] and bandlinestruct[1].d).
-
- You should design the labels with one or two blank lines before you start
- placing the fields. This is because there may be a need to cater for
- labels that are not of a standard length. For example, if you purchase
- "8 up" laser labels on A4 (70 line) paper then some simple arithmetic
- leads to the discovery that you will need 8.75 lines per label!! The
- "setupForLabels()" function caters for this by giving some labels one
- more line that others. This is why is it not advisable to print any
- data on the first line of the label.
-
- You need to select "Labels/Number Across" and should specify the maximum
- number of labels across the page that you permit on the filter screen,
- (that is, if your validation for GET_NUM_ACROSS is "!{} <= 5" then you
- should specify 5 labels across in the report (note that you may first need
- to select "Universal/Page/Width" to increase the page width to accomadate
- the label dimensions you desire). You will also probably want to use the
- "Labels/Width", "Labels/Seperation" and "Labels/Orientation" items.
-
- You may also want to utilise the "Labels/Pack" facility. If you do so
- then the first blank line or two, (mentioned above), of your label should
- have a "." or "-" at the first position. This will stop the "Pack"
- algorithm moving these line(s) to the bottom of the label.
-
- After the lines where data is printed on the label you will need to add
- a number of blank lines, this is to cater for labels of different lengths,
- so add enough lines to cater for the maximum length label you think your
- program might have to deal with. For each blank line select "Line
- Condidtion" and use the "labelLineOK(line)" (from the LABELS.FUN file) as
- the condition. The "line" passed to "labelLineOK()" is the name of an
- internal variable in the report skeleton in the function where the call
- to "labelLineOK()" will be generated.
-
- The last situation that needs to be dealt with is when the label sheet has
- part of a label at the top and/or bottom of the sheet. For example "7 up"
- laser labels on A4 paper (70 lines), are usually all 9 lines per label.
- This means that there are 7 full labels with 7 lines over. The 7 extra
- lines are usually put at the top and bottom of the page. DataBoss will
- handle these as the page header and page footer.
-
- Add as many blank lines to both the "Page Header" and "Page Footer" as
- you think your program may need to deal with (worst case). Each blank
- line must have a "Line Condition" attached so that when you don't want
- headers and footers the blank lines can be suppressed. The line condition
- for a blank line in the header is :--
-
- headerstruct[PGHDR] >= line /* see above for explanation of line */
-
- The line condition for a blank line in the footer is :--
-
- headerstruct[PGFTR] >= line /* see above for explanation of line */
-
-
- 5) The final step is to generate the label printing report using the custom
- LABELS.SKL skeleton file, (just change the skeleton name on the report
- GENERATE form), and then compile and test your program.
-
- NOTE : Just because a sheet of labels has a half label at the top and
- bottom of the sheet does not necessarily mean that you need to
- specify a top and bottom margin when printing labels.
-
- The reason is that the whole point of adding the half labels was
- that laser printers could not print near the edge of the page,
- (often you will find that they can only print on 64 lines). This
- means that even though the piece of paper has 70 lines on it as
- far as the laser printer is concerned it only has 64. You don't
- need to specify a top and bottom margin because they are implicit
- to the printers physical capability.
-
- NOTE : This problem, the laser printers inability to print on all lines,
- usually means that it is not possible to print on some label
- stationary when using the standard printer setup of 6 lines per
- inch. Keep this in mind when purchasing your labels!!
-