home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-24 | 24.3 KB | 1,129 lines |
- //
- // Module Name: LABEL.COD
- // Description: Define label program structure.
- //
-
- Label (.lbg) Program Template
- -----------------------------
- Version 5.0
- Copyright (c) 1993,1994 Borland International, Inc.
-
- {include "label.def";
- include "builtin.def";
-
- if getenv("dtl_debug") then
- debug(2)
- breakpoint( pick_debug )
- endif
-
- var bnl_formname, // Name of BNL file to newframe if argument() has value
- arg_list;
-
- arg_list = argument()
- if arg_list != "" then
- bnl_formname = token( ",", arg_list, 1 )
- if !newframe( bnl_formname ) then
- return -1;
- endif
- endif
- //
- // Enum string constants for international translation
- //
- enum wrong_class = "Can't use LABEL.GEN on non-label objects. ",
- label_empty = "Label design was empty. ",
- more_samples = "Do you want more samples? (Y/N)",
- warn_pdriver =
- "Warning: labels may not vertically align since printer driver does not fully support laser labels.",
- error_plength = "Page length needs to be longer."
- ;
- //
- if FRAME_CLASS != label then
- pause(wrong_class + any_key);
- return 0;
- endif
-
- //---------------------------
- // Declare working variables
- //---------------------------
- var lblname, // Name of label file program
- lblpath, // Path to write label file
- default_drive, // dBASE default drive
- crlf, // line feed
- line, // Line counter for outputing number of "?'s"
- isfirst, // Logical work variable
- mrows, // Number of rows that the label uses
- mcolumns, // Number of columns in label
- lbl_vspace, // Lines between labels
- lbl_wide, // Label width
- lbl_hspace, // Number of spaces between labels
- lbl_offset, // Label left offset
- lbl_widow, // Determine whether a label will fit on a page
- lbl_lazer, // Are we using lazerjet labels??
- lbl_textlen, // Total page text length consumed by lazer labels
- lbl_top, // Label top margin
- numflds, // Number of fields used in label
- style, // Style attribute assigned to the field/text
- current_column, // Current column number
- first_combine, // text or field is first in the chain of combined data
- combine, // combine fields flag
- new_line, // is the next field on a new line
- i, j, x, temp, ni, // temporary usage variables
- first_item, // relative element number when repeating columns
- item_number, // current item number
- count, // number of text and field items
- last_row,
- temp_row,
- current_row,
- previous_row,
- blank_line,
- printed_lines,
- previous_element,
- number_of_blankable_lines,
- current_element,
- response,
- long_line, // calculated expression possibly exceeds line
- left_delimiter,
- right_delimiter,
- delimit_flag
- ;
- //-------------------------------------------------
- // Assign starting values to some of the variables
- //-------------------------------------------------
- crlf = chr(10);
- current_element=2;
- item_number = isfirst = mcolumns = first_combine = new_line = 1;
- count = line = mrows = numflds = current_column = combine = long_line = 0;
- lbl_vspace = nul2zero(LABEL_VSPACE);
- lbl_wide = LABEL_WIDE;
- lbl_hspace = nul2zero(LABEL_HSPACE);
- lbl_offset = nul2zero(LABEL_LMARG);
- lbl_lazer = lbl_textlen = lbl_top = 0;
- lbl_widow = 1;
- if LABEL_ROWS > 0 then
- lbl_lazer = 1;
- lbl_textlen = LABEL_ROWS * (LABEL_TALL+LABEL_VSPACE) - 1;
- endif
-
- blank_line = 1;
- current_row = 0;
- previous_row = -1;
- printed_lines = 0;
- previous_element = 0;
- number_of_blankable_lines=0;
- left_delimiter="\""
- right_delimiter="\""
- delimit_flag=0;
-
- foreach ELEMENT ecursor
- if COUNTC(ecursor) > 1 && !eoc(ecursor) then
- temp_row = previous_row = current_row = nul2zero(ROW_POSITN);
- do while !eoc(ecursor)
- if ROW_POSITN > previous_row then
- number_of_blankable_lines=number_of_blankable_lines+blank_line;
- blank_line=1;
- previous_element=0;
- previous_row=ROW_POSITN;
- ++printed_lines;
- endif
- if blank_line then
- if FLD_VALUE_TYPE == 78 then
- if not AT("Z",FLD_PICFUN) then
- blank_line=0;
- endif
- else
- if TEXT_ITEM && !previous_element then
- blank_line=0;
- endif
- if ELEMENT_TYPE == @FLD_ELEMENT && FLD_VALUE_TYPE != 67 then
- blank_line=0;
- endif
- endif
- endif
- if ELEMENT_TYPE == @FLD_ELEMENT && FLD_VALUE_TYPE == 67 ||
- (FLD_VALUE_TYPE == 78 && AT("Z",FLD_PICFUN)) then
- previous_element=1;
- else
- previous_element=0;
- endif
- ++ecursor;
- enddo
- number_of_blankable_lines=number_of_blankable_lines+blank_line;
- ++printed_lines;
- --ecursor;
- previous_row=ROW_POSITN+1;
- last_row=ROW_POSITN;
- endif
- next
- blank_line=0;
-
- default_drive = STRSET(_defdrive);
- lblname = FRAME_PATH + NAME;
- lblpath = FRAME_PATH;
- if not FILEOK(lblname) then
- if FILEDRIVE(NAME) || !default_drive then
- lblname=NAME;
- if FILEDRIVE(NAME) then
- lblpath=FILEDRIVE(NAME)+":"+FILEPATH(NAME);
- else
- lblpath=FILEPATH(NAME);
- endif
- else
- lblname=default_drive + ":" + NAME;
- lblpath=default_drive + ":";
- endif
- endif
-
- if not CREATE(lblname+".LBG") then;
- PAUSE(fileroot(lblname)+".LBG"+read_only+any_key);
- return 0;
- endif
- }
- * Program............: {cap_first(fileroot(lblname))}.LBG
- * Date...............: {ltrim(substr(date(),1,8))}
- * Version............: dBASE 5.0, Label
- *
- * Label Specifics:
- * Wide : {lbl_wide}
- * Tall : {label_tall}
- * Indentation : {nul2zero(label_lmarg)}
- * Number across : {label_nup}
- * Space between : {lbl_hspace}
- * Lines between : {lbl_vspace}
- {if lbl_lazer then}
- * Rows per page : {label_rows}
- {endif}
- * Blankable lines : {number_of_blankable_lines}
- * Print formatted : {printed_lines}
- *
- PARAMETER ll_sample
- *-- Set printer variables for this procedure only
- PRIVATE _peject, _wrap,ln_lines
- {if lbl_lazer then}
- PRIVATE _pscode,ln_tmargin,_plength,ln_toffset,ll_success,ln_rows
- PRIVATE ll_toprint,ll_temp
-
- ll_toprint = .F.
- ln_tmargin = 0
-
- IF SET("PRINTER")="ON"
- IF _plength < {lbl_textlen}
- DO lbl_error WITH "{error_plength}"
- RETURN
- ENDIF
-
- ll_toprint = .T.
- ln_tmargin = (_plength - {lbl_textlen})/2
-
- ln_toffset = ln_tmargin * 240
- ll_success = ESCAPE("QUERY","TMARGIN",ln_toffset)
-
- IF .NOT. ll_success && no guarantees at what they'll look like
- DO lbl_error WITH "{warn_pdriver}",.T.
- ln_toffset = 0
- ELSE
- * IF ISBLANK(GETENV("PSCODEFIRST"))
- * _pscode = lc_pscode + _pscode
- * ELSE
- * _pscode = _pscode + lc_pscode
- * ENDIF
- _plength = {lbl_textlen}
- ENDIF
-
- ENDIF
- {endif}
-
- *-- Test for End of file
- IF EOF()
- RETURN
- ENDIF
-
- IF SET("TALK")="ON"
- SET TALK OFF
- gc_talk="ON"
- ELSE
- gc_talk="OFF"
- ENDIF
- gc_space = SET("SPACE")
- SET SPACE OFF
- gc_time=TIME() && system time for predefined field
- gd_date=DATE() && system date " " " "
- gl_fandl=.F. && first and last record flag
- gl_prntflg=.T. && Continue printing flag
- gn_column=1
- gn_element=0
- gn_line=1
- gn_memowid=SET("MEMOWIDTH")
- {if lbl_lazer then}
- ln_rows=0
- {endif}
- ln_lines = {label_tall+lbl_vspace}
- SET MEMOWIDTH TO 254
- gn_page=_pageno && capture page number for multiple copies
- _plineno=0
- _wrap = .F.
-
- *-- Setup Environment
- ON ESCAPE DO Prnabort
- {if lbl_lazer then}
- IF ll_toprint
- ON PAGE AT LINE _plength-1 EJECT PAGE
- ENDIF
- {endif}
-
- {numflds=FRAME_NUM_OF_FIELDS;}
- {if LABEL_NUP > 1 then}
- *-- Initialize array(s) for {LABEL_NUP} across labels
- DECLARE isfound[{LABEL_NUP-1}]
- { if numflds then}
- DECLARE tmp4lbl[{LABEL_NUP-1},{numflds}]
- { endif}
- {endif}
- {//if number_of_blankable_lines then}
- DECLARE gn_line2[{label_nup}]
- {//endif}
-
- PRINTJOB
- {if lbl_lazer then}
- IF ll_toprint
- ll_temp = ESCAPE("PSIZE",_psize)
- ll_temp = _pwait .AND. ESCAPE("PFEED","MANUAL")
- ll_temp = ESCAPE("VMI",240)
- ll_temp = ESCAPE("TMARGIN",ln_toffset)
- ENDIF
- {endif}
-
- {x=0;}
- {foreach FLD_ELEMENT k}
- //
- // only if there is a fieldname assigned to the calculated field
- //
- {if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
- { if !x then}
- *-- Initialize calculated variables.
- { endif}
- {lower(FLD_FIELDNAME)}=\
- {case FLD_VALUE_TYPE of}
- {68: // Date }CTOD(SPACE(8))
- {70: // Float }FLOAT(0)
- {76: // Logical}.F.
- {78: // Numeric}INT(0)
- {otherwise:}""
- {endcase}
- { ++x;}
- {endif}
- {next k;}
-
- *-- set page number for multiple copies
- _pageno=gn_page
-
- IF ll_sample
- DO Sample
- IF LASTKEY() = 27
- RETURN
- ENDIF
- ENDIF
-
- DO WHILE FOUND() .AND. .NOT. EOF() .AND. gl_prntflg
- {LMARG(4);}
- {if LABEL_NUP > 1 then}
- {isfirst=1;}
- {x=1;}
- STORE .F. TO \
- {init_array:}
- {if isfirst then}
- { isfirst=0;}
- {else}
- ,\
- {endif}
- isfound[{x}]\
- {++x;}
- {if x < LABEL_NUP then goto init_array endif}
-
- {x=0;}
- {i=1;}
- {arcopy:}
- { if x then}
- IF FOUND() .AND. .NOT. EOF()
- { LMARG(7);}
- { endif}
- { calcflds();}
- //
- {foreach FLD_ELEMENT i}
- tmp4lbl[{x+1},{i}]=\
- {case FLD_FIELDTYPE of}
- {Tabl_data:}
- { if FLD_VALUE_TYPE == 77 then}
- MLINE({cap_first(FLD_FIELDNAME)},1)
- { else}
- { cap_first(FLD_FIELDNAME)}
-
- { endif}
- {Calc_data:}
- { if FLD_FIELDNAME then}
- { lower(FLD_FIELDNAME)}
-
- { else}
- { foreach FLD_EXPRESSION exp in i}
- { FLD_EXPRESSION}\
- { next}
-
- { endif}
- {Pred_data:}
- { case FLD_PREDEFINE of}
- { 0: // Date}
- gd_date
- { 1: // Time}
- gc_time
- { 2: // Recno}
- RECNO()
- { 3: // Pageno}
- _pageno
- { endcase}
- {endcase}
- {next i;}
- //
- { if x then}
- isfound[{x}]=.T.
- { endif}
- CONTINUE
- { if x then}
- { LMARG(4);}
- ENDIF
- { endif}
- { ++x;}
- { if x < LABEL_NUP-1 then
- goto arcopy;
- endif
- }
- IF FOUND() .AND. .NOT. EOF()
- {LMARG(7);}
- {calcflds();}
- isfound[{x}]=.T.
- {LMARG(4);}
- ENDIF
- {else}
- {calcflds();}
- {endif}
-
- {x=0;
- do while x < temp_row}
- ?
- { ++x;
- enddo
- }
- gn_line={nul2zero(temp_row)}
- *-- Check for blank lines
- DO Chk4null WITH {nul2zero(temp_row)}, {last_row+1}, {(last_row-temp_row+1)*label_nup}
-
- {if lbl_lazer then}
- IF ll_toprint
- ln_rows = ln_rows + 1
- IF ln_rows = {LABEL_ROWS}
- ln_rows = 0
- ln_lines = {label_tall+lbl_vspace-1}
- ELSE
- ln_lines = {label_tall+lbl_vspace}
- ENDIF
- ENDIF
- {endif}
- DO WHILE gn_line < ln_lines
- ?
- gn_line=gn_line+1
- ENDDO
- CONTINUE
- {LMARG(1);}
- ENDDO
-
- {if lbl_lazer then}
- ON PAGE
- {endif}
-
- IF .NOT. gl_prntflg
- SET MEMOWIDTH TO gn_memowid
- SET SPACE &gc_space.
- SET TALK &gc_talk.
- ON ESCAPE
- RETURN
- ENDIF
-
- ENDPRINTJOB
-
- {if lbl_lazer then}
- IF _plineno # 0
- EJECT PAGE
- ll_temp = _pwait .AND. ESCAPE("PFEED","")
- ENDIF
- {endif}
- SET MEMOWIDTH TO gn_memowid
- SET SPACE &gc_space.
- SET TALK &gc_talk.
- ON ESCAPE
- RETURN
- * EOP: {cap_first(fileroot(lblname))}.LBG
-
- {if lbl_lazer then}
-
- PROCEDURE lbl_error
- PARAMETER pc_errstr,pl_quickwait
-
- PRIVATE lc_print,lc_console,lc_alter
-
- lc_print = SET("PRINT")
- lc_console = SET("CONSOLE")
- lc_alter = SET("ALTERNATE")
-
- SET PRINT OFF
- SET ALTERNATE OFF
- SET CONSOLE ON
-
- DEFINE WINDOW gw_label FROM 7,15 TO 13,64 DOUBLE
- ACTIVATE WINDOW gw_label
- ? pc_errstr AT 1 FUNCTION "V47"
- ?
- ? "{any_key}" AT 1 PICTURE REPLICATE("X",47) FUNCTION "I"
- x=INKEY(IIF(pl_quickwait,4,0))
- DEACTIVATE WINDOW gw_label
- RELEASE WINDOW gw_label
-
- SET CONSOLE &lc_console
- SET ALTERNATE &lc_alter
- SET PRINT &lc_print
-
- RETURN
- *EOP: lbl_error
-
- {endif}
-
- PROCEDURE Prnabort
- gl_prntflg=.F.
- RETURN
- * EOP: Prnabort
-
- //
- // Main loop (inner loop to handles fields on each line by # of columns)
- //
- {foreach ELEMENT k}
- { if ELEMENT_TYPE == @Band_Element then}
- { ++k; ++item_number;}
- { if eoc(k) then}
- { exit;}
- { endif}
- { temp_row=ROW_POSITN;}
- { endif}
- { ++count;}
- { LMARG(1);}
- { blank_line=0;}
- //
- {
- if number_of_blankable_lines then
-
- long_line=0;
- blank_line=1;
- current_element=COUNTC(k);
- previous_element=0;
- previous_row=ROW_POSITN;
-
- do while !eoc(k);
- if ROW_POSITN > previous_row then
- exit
- endif
- if blank_line then
- if FLD_VALUE_TYPE == 78 then
- if not AT("Z",FLD_PICFUN) then
- blank_line=0;
- endif
- else
- if TEXT_ITEM && !previous_element then
- blank_line=0;
- endif
- if ELEMENT_TYPE == @FLD_ELEMENT && FLD_VALUE_TYPE != 67 then
- blank_line=0;
- endif
- endif
- endif
- if !blank_line then
- exit
- endif
- if ELEMENT_TYPE == @FLD_ELEMENT && FLD_VALUE_TYPE == 67 ||
- (FLD_VALUE_TYPE == 78 && AT("Z",FLD_PICFUN)) then
- previous_element=1;
- else
- previous_element=0;
- endif
- ++k;
- enddo
- if eoc(k) then
- --k;
- endif
-
- do while COUNTC(k) > current_element;
- --k;
- enddo
-
- endif}
- //
- //---------------------
- // Process blank lines
- //---------------------
- { line=temp_row+1;}
- { do while line < ROW_POSITN}
- { x=1;}
- { do while x <= LABEL_NUP}
- FUNCTION ___{line}{x}
- ll_output=.T.
- RETURN .F.
-
- { ++x;}
- { enddo}
- { ++line;}
- { enddo}
- //--------------------
- // End of blank lines
- //--------------------
- //
- { mrows = 0;}
- { first_item = item_number;}
- { line = temp_row;}
- //
- { repeat:}
- //
- { if new_line then}
- FUNCTION ___{nul2zero(ROW_POSITN)}{mrows+1}
- lc_ret=.F.
- { if mrows then}
- *-- Column {mrows+1}
- IF isfound[{mrows}]
- {LMARG(4);}
- { endif}
- { if blank_line then}
- { if mrows then}
- { conditional_if_for_blank_line(k,7);}
- { else}
- { conditional_if_for_blank_line(k,4);}
- { endif}
- { else}
- ll_output=.T.
- { endif}
- ?? \
- { else}
- { if long_line then}
- ?? \
- { long_line=0;}
- { else}
- ,\
- { endif}
- { endif}
- //
- {ni=0;}
- { case ELEMENT_TYPE of}
- //
- { @Text_Element:}
- //
- {x=Col_Positn;}
- {i=LEN(TEXT_ITEM);}
- {if i == 237 then}
- { foreach TEXT_ITEM fcursor in k}
- { if ni then}
- { i=i+LEN(TEXT_ITEM);}
- { temp=TEXT_ITEM;}
- { endif}
- { ++ni;}
- { next}
- {endif}
- {current_column=x+i;}
- //
- { @FLD_ELEMENT:}
- //
- {x=Col_Positn;}
- {i=FLD_REPWIDTH;}
- {if i > 237 then}
- { foreach FLD_TEMPLATE fcursor in k}
- { if ni then}
- { temp=FLD_TEMPLATE;}
- { endif}
- { ++ni;}
- { next}
- {endif}
- {current_column=x+i;}
- //
- { endcase}
- //
- // is the next element on the same line
- //
- { line=ROW_POSITN;}
- { ++k;}
- { if (not EOC(k)) && line == ROW_POSITN then}
- { new_line=0;}
- //
- // is the next element flush with previous element
- //
- { if current_column == Col_Positn then}
- { combine=1;}
- { else}
- { combine=0;}
- { endif}
- { else}
- { new_line=1;}
- { endif}
- { --k;}
- //-----------------------------------------------
- // Determine what type of data we are processing
- //-----------------------------------------------
- { case ELEMENT_TYPE of}
- //
- { @Text_Element:}
- //
- {if blank_line then}
- IIF( .NOT. ISBLANK( \
- { --k;}
- { if FLD_VALUE_TYPE == 78 then}
- TRANSFORM(\
- { endif}
- { if mrows+1 < LABEL_NUP then}
- tmp4lbl[{mrows+1},{mcolumns-1}] \
- { else}
- { putfld(k);}
- { endif}
- { if FLD_VALUE_TYPE == 78 then}
- ,"@{FLD_PICFUN}")\
- { endif}
- { ++k;}
- ),\
- { long_line=1;
- endif}
- //
- {if substr(TEXT_ITEM,1,1) == "\"" then
- left_delimiter = "["
- right_delimiter = "]"
- delimit_flag = 1;
- endif}
- {if i > 70 then}
- ;
- { seperate(TEXT_ITEM);}
- { if ni then}
- + {left_delimiter}{temp}{right_delimiter};
- { endif}
- {else}
- {left_delimiter}{TEXT_ITEM}{right_delimiter} \
- {endif}
- //
- {if blank_line then}
- ,"" ) \
- {endif}
- //
- {if delimit_flag then
- left_delimiter="\""
- right_delimiter="\""
- delimit_flag=0;
- endif}
- { @FLD_ELEMENT:}
- //
- { if mrows+1 < LABEL_NUP then}
- tmp4lbl[{mrows+1},{mcolumns}] \
- { else}
- { putfld(k);}
- { endif}
- { ++mcolumns;}
- { endcase}
- //
- { if ELEMENT_TYPE == @FLD_ELEMENT && ok_template(k) then}
- //
- { if !FLD_FIELDTYPE || FLD_FIELDTYPE == Calc_data ||
- (FLD_FIELDTYPE == Pred_data && FLD_PREDEFINE > 1) then}
- //
- { if FLD_VALUE_TYPE == 67 then
- j=FLD_TEMPLATE+temp;
- if FLD_LENGTH == FLD_REPWIDTH && j == REPLICATE("X",FLD_LENGTH) then
- j="";
- endif
- else
- j="1";
- endif}
- //
- { if (FLD_PICFUN || j) then}
- PICTURE \
- { endif}
- //
- { if FLD_PICFUN then}
- "@{FLD_PICFUN}\
- { if j then}
- \
- { else}
- " \
- { endif}
- { endif}
- //
- { if j then}
- { if i > 70 then}
- { if FLD_PICFUN then}
- "+;
- { else}
- ;
- { endif}
- { seperate(FLD_TEMPLATE);}
- { if ni then}
- + "{temp}";
- { endif}
- { else}
- { if !FLD_PICFUN then}
- "\
- { endif}
- {FLD_TEMPLATE}" \
- { endif}
- { endif}
- { endif}
- //
- { endif}
- //
- { if FLD_STYLE then}
- { style=getstyle(FLD_STYLE);}
- STYLE "{style}" \
- { endif}
- { if first_combine then}
- AT {Col_Positn+lbl_offset+(mrows*(lbl_wide+lbl_hspace))} \
- { if combine then}
- { first_combine=0;}
- { endif}
- { else}
- { if not combine then first_combine=1; endif}
- { endif}
- //
- // position to next element
- //
- { temp_row=ROW_POSITN;}
- { ++k; ++item_number;}
- //
- { if !new_line || (!EOC(k) && temp_row == ROW_POSITN) then
- if !new_line then}
- { if long_line then}
-
- { else}
- ;
- { endif}
- { else}
-
- { long_line=0;}
- { endif
- if !EOC(k) then
- goto repeat;
- endif}
- { else}
- { long_line=0;}
- { endif}
- //
- { combine=0;}
- { first_combine=1;}
- //
- { if LABEL_NUP-1 > mrows then}
-
- { if blank_line && mrows then}
- { LMARG(4);}
- { else}
- { LMARG(1);}
- { endif}
- { if blank_line then}
- { if temp_row != last_row then}
- ELSE
- lc_ret=.T.
- { endif}
- ENDIF
- { endif}
- { if mrows then}
- { LMARG(1);}
- ENDIF
- { endif}
- RETURN lc_ret
-
- { ++mrows;}
- { do while item_number > first_item}
- { --k; --item_number;}
- { if ELEMENT_TYPE == @FLD_ELEMENT then}
- { --mcolumns;}
- { endif}
- { enddo}
- { new_line=1;}
- { goto repeat;}
- { else}
-
- { if mrows then}
- { LMARG(4);}
- { else}
- { LMARG(1);}
- { endif}
- { if blank_line then}
- { if temp_row != last_row then}
- ELSE
- lc_ret=.T.
- { endif}
- ENDIF
- { endif}
- { if mrows then}
- { LMARG(1);}
- ENDIF
- { endif}
- RETURN lc_ret
-
- { mrows=0;}
- { --k; --item_number;}
- { endif}
- //
- {next k;
-
- // check for empty label form
- if !count then
- }
-
- PROCEDURE Chk4null
- PARAMETERS ln_line, ln_lastrow, ln_element
- RETURN
- *-- EOP: Chk4null
-
- {else}
-
- PROCEDURE Chk4null
- *-- Parameters:
- *
- *-- 1) line number on the design surface
- *-- 2) maximum number of printable lines
- *-- 3) parameter 2 times number of labels across
- *
- PARAMETERS ln_line, ln_lastrow, ln_element
-
- gn_element=0
- {
- x=1;
- do while x <= label_nup}
- gn_line2[{x}]=ln_line
- { ++x;
- enddo}
- lc_temp=SPACE(7)
- ll_output=.F.
- DO WHILE gn_element < ln_element
- gn_column=1
- ll_output=.F.
- DO WHILE gn_column <= {label_nup}
- IF gn_line2[gn_column] < ln_lastrow
- lc_temp=LTRIM(STR(gn_line2[gn_column]))+LTRIM(STR(gn_column))
- DO WHILE ___&lc_temp.()
- gn_element=gn_element+1
- gn_line2[gn_column]=gn_line2[gn_column]+1
- lc_temp=LTRIM(STR(gn_line2[gn_column]))+LTRIM(STR(gn_column))
- ENDDO
- gn_element=gn_element+1
- gn_line2[gn_column]=gn_line2[gn_column]+1
- ENDIF
- gn_column=gn_column+1
- ENDDO
- IF ll_output
- ?
- gn_line=gn_line+1
- ENDIF
- ENDDO
- RETURN
- *-- EOP: Chk4null
- {endif // label form empty check}
-
- PROCEDURE Sample
- PRIVATE x,y,choice
- DEFINE WINDOW w4sample FROM 15,20 TO 17,60 DOUBLE
- choice="Y"
- x=0
- DO WHILE choice = "Y"
- y=0
- DO WHILE y < {LABEL_TALL}
- x=0
- DO WHILE x < {LABEL_NUP}
- {if lbl_offset then}
- IF x = 0
- ?? "" AT {lbl_offset}
- ENDIF
- {endif}
- ?? REPLICATE("X",{LABEL_WIDE})\
- {if LABEL_HSPACE then}
- +SPACE({LABEL_HSPACE})
- {else}
-
- {endif}
- x=x+1
- ENDDO
- ?
- y=y+1
- ENDDO
- {if LABEL_VSPACE then}
- x=0
- DO WHILE x < {LABEL_VSPACE}
- ?
- x=x+1
- ENDDO
- {endif}
- ACTIVATE WINDOW w4sample
- @ 0,3 SAY "{more_samples}";
- GET choice PICTURE "!" VALID choice $ "NY"
- READ
- DEACTIVATE WINDOW w4sample
- IF LASTKEY() = 27
- EXIT
- ENDIF
- ENDDO
- RELEASE WINDOW w4sample
- RETURN
- * EOP: Sample
-
- {return 0;}
- //--------------------------------
- // End of main template procedure
- // User defined function follows
- //--------------------------------
- {
- define getstyle(mstyle);
- var outstyle;
- outstyle="";
- if Bold & mstyle then outstyle=outstyle+"B"; endif
- if Italic & mstyle then outstyle=outstyle+"I"; endif
- if Underline & mstyle then outstyle=outstyle+"U"; endif
- if Superscript & mstyle then outstyle=outstyle+"R"; endif
- if Subscript & mstyle then outstyle=outstyle+"L"; endif
- if User_Font & mstyle then
- if 1 & mstyle then outstyle=outstyle+"1"; endif
- if 2 & mstyle then outstyle=outstyle+"2"; endif
- if 4 & mstyle then outstyle=outstyle+"3"; endif
- if 8 & mstyle then outstyle=outstyle+"4"; endif
- if 16 & mstyle then outstyle=outstyle+"5"; endif
- endif
- return outstyle;
- enddef;
-
- define ok_template(cur)
- if cur.FLD_TEMPLATE && !(chr(cur.FLD_VALUE_TYPE) == "D" ||
- chr(cur.FLD_VALUE_TYPE) == "G" ||
- chr(cur.FLD_VALUE_TYPE) == "B"
- ) then
- return 1;
- else
- return 0;
- endif
- enddef
-
- }
- {define putfld(cursor);
- var value,value2;
- value=cursor.FLD_FIELDTYPE;}
- { if mrows+1 < LABEL_NUP then}
- tmp4lbl[{mrows+1},{mcolumns}] \
- { else}
- {case value of}
- {Tabl_data:}
- { if cursor.FLD_VALUE_TYPE == 77 then}
- MLINE({cap_first(cursor.FLD_FIELDNAME)},1)\
- { else}
- { cap_first(cursor.FLD_FIELDNAME)}\
- { endif}
- {Calc_data:}
- { if cursor.FLD_FIELDNAME then}
- { lower(cursor.FLD_FIELDNAME)}\
- { else}
- { foreach FLD_EXPRESSION exp in cursor}
- { FLD_EXPRESSION}\
- { next}
- ;
- { long_line=1;}
- { endif}
- {Pred_data:}
- { value2=cursor.FLD_PREDEFINE;}
- { case value2 of}
- { 0: // Date}
- gd_date\
- { 1: // Time}
- gc_time\
- { 2: // Recno}
- RECNO()\
- { 3: // Pageno}
- _pageno\
- { endcase}
- {endcase}
- \
- { endif}
- {return;
- enddef;
- }
- {
- define conditional_if_for_blank_line(cursor2, page_offset);
- var field_flag, current_row;
- }
- *-- Test for blank line
- IF .NOT. ISBLANK( \
- {
- current_element=COUNTC(cursor2);
- current_row=cursor2.ROW_POSITN;
- do while !eoc(cursor2) && cursor2.ROW_POSITN == current_row}
- { if cursor2.ELEMENT_TYPE == @FLD_ELEMENT then
- if field_flag then}+ \
- { else
- field_flag=1;
- endif
- endif
- if cursor2.FLD_VALUE_TYPE == 78 then}
- TRANSFORM(\
- { putfld(cursor2);}
- ,"\
- { if cursor2.FLD_PICFUN then}
- @{cursor2.FLD_PICFUN} \
- { endif}
- {cursor2.FLD_TEMPLATE}") \
- {//
- else
- if cursor2.ELEMENT_TYPE == @FLD_ELEMENT then
- putfld(cursor2);
- endif
- endif
- if cursor2.ELEMENT_TYPE == @FLD_ELEMENT then
- ++mcolumns;
- endif
- ++cursor2;
- enddo
- do while eoc(cursor2) || COUNTC(cursor2) > current_element;
- --cursor2;
- if cursor2.ELEMENT_TYPE == @FLD_ELEMENT then
- --mcolumns;
- endif
- enddo}
- )
- {LMARG(page_offset);}
- ll_output=.T.
- { return;
- enddef
- }
- {define calcflds();}
- {foreach FLD_ELEMENT k}
- { if FLD_FIELDNAME && FLD_FIELDTYPE == Calc_data then}
- {lower(FLD_FIELDNAME)}=\
- {foreach FLD_EXPRESSION j in k}
- {FLD_EXPRESSION}
- {next}
-
- { endif}
- {next k;}
- {return;}
- {enddef}
- {
- define seperate(string);
- var x,y,length;
- x=1;
- length=LEN(string);
- moreleft:
- if x < length then
- if x != 1 then}
- + \
- { endif
- if x+70 <= length then y=70; else y=length-x+1; endif}
- "{SUBSTR(string,x,y)}";
- { x=x+70;
- goto moreleft;
- endif
- return;
- enddef
- }
-
-
- // EOP: LABEL.COD
-