home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / lbl_anom.zip / LABEL.COD < prev    next >
Text File  |  1989-01-23  |  23KB  |  1,043 lines

  1. //
  2. // Module Name: LABEL.COD
  3. // Description: Define Application menus and program structure.
  4. //
  5.  
  6. Label (.lbg) Program Template
  7. -----------------------------
  8. Version 1.0
  9. Ashton-Tate (c) 1987
  10.  
  11. {include "label.def";
  12.  include "builtin.def";
  13.  //
  14.  // Enum string constants for international translation
  15.  // 
  16.  enum wrong_class = "Can't use LABEL.GEN on non-label objects.  ",
  17.       label_empty = "Label design was empty.  ",
  18.      more_samples = "Do you want more samples? (Y/N)",
  19.      gen_request  = "Generation request cancelled.  ",
  20.   temp_file_error =
  21. "File $$$LAB.TMP already exists.  Possible file lock collision.  Retry? ";
  22.  //
  23.  if frame_class != label then
  24.    pause(wrong_class + any_key);
  25.    return 0;
  26.  endif
  27.  
  28.  //---------------------------
  29.  // Declare working variables
  30.  //---------------------------
  31.  var lblname,       // Name of label file program
  32.      lblpath,       // Path to write label file
  33.      default_drive, // dBASE default drive
  34.      crlf,          // line feed
  35.      line,          // Line counter for outputing number of "?'s"
  36.      isfirst,       // Logical work variable
  37.      mrows,         // Number of rows that the label uses
  38.      mcolumns,      // Number of columns in label
  39.      lbl_vspace,    // Number of characters between labels 
  40.      lbl_wide,      // Label width
  41.      lbl_hspace,    // How tall the label is
  42.      numflds,       // Number of fields used in label
  43.      style,         // Style attribute assigned to the field/text
  44.     current_column, // Current column number
  45.      first_combine, // text or field is first in the chain of combined data
  46.      combine,       // combine fields flag
  47.      new_line,      // is the next field on a new line
  48.  i, j, x, temp, ni, // temporary usage variables
  49.      first_item,    // relative element number when repeating columns
  50.      item_number,   // current item number
  51.      count,         // number of text and field items
  52.    current_row,
  53.   previous_row,
  54.     next_row,
  55.    blank_line,
  56.   printed_lines,
  57. previous_set_was_blank,
  58. number_of_blankable_lines,
  59.  current_element,
  60.     response,
  61.    long_line        // calculated expression possibly exceeds line
  62. ;
  63.  //-------------------------------------------------
  64.  // Assign starting values to some of the variables
  65.  //-------------------------------------------------
  66.  crlf = chr(10);
  67.  current_element=2;
  68.  item_number = isfirst = mcolumns = first_combine = new_line = next_row = 1;
  69.  count = line = mrows = numflds = current_column = combine = long_line = 0;
  70.  lbl_vspace = nul2zero(LABEL_VSPACE);
  71.  lbl_wide = LABEL_WIDE;
  72.  lbl_hspace = nul2zero(LABEL_HSPACE);
  73.  
  74.  blank_line = 1;
  75.  current_row = 0;
  76.  previous_row = -1;
  77.  printed_lines = 0;
  78.  number_of_blankable_lines=0;
  79.  
  80.  foreach ELEMENT ecursor
  81.    if COUNTC(ecursor) > 1 && !eoc(ecursor) then
  82.      previous_row = current_row = Row_Positn;
  83.      do while !eoc(ecursor)
  84.        if Row_Positn > previous_row then
  85.          number_of_blankable_lines=number_of_blankable_lines+blank_line;
  86.          blank_line=1;
  87.          previous_row=Row_Positn;
  88.          ++printed_lines;
  89.        endif
  90.        if blank_line then
  91.          if FLD_VALUE_TYPE == 78 then
  92.            if not AT("Z",FLD_PICFUN) then
  93.              blank_line=0;
  94.            endif
  95.          else
  96.            if Text_Item then
  97.              blank_line=0;
  98.            endif
  99.            if FLD_VALUE_TYPE != 67 then
  100.              blank_line=0;
  101.            endif
  102.          endif
  103.        endif
  104.        ++ecursor;
  105.      enddo
  106.      number_of_blankable_lines=number_of_blankable_lines+blank_line;
  107.      ++printed_lines;
  108.      --ecursor;
  109.      previous_row=Row_Positn+1;
  110.    endif
  111.  next
  112.  blank_line=0;
  113.  
  114.  default_drive = STRSET(_defdrive);
  115.  lblname = FRAME_PATH + NAME;
  116.  lblpath = FRAME_PATH;
  117.  if not FILEOK(lblname) then
  118.    if FILEDRIVE(NAME) || !default_drive then
  119.      lblname=NAME;
  120.      if FILEDRIVE(NAME) then
  121.        lblpath=FILEDRIVE(NAME)+":"+FILEPATH(NAME);
  122.      else
  123.        lblpath=FILEPATH(NAME);
  124.      endif
  125.    else
  126.      lblname=default_drive + ":" + NAME;
  127.      lblpath=default_drive + ":";
  128.    endif
  129.  endif
  130.  
  131.  if number_of_blankable_lines then
  132.    response="Y";
  133.    do while FILEEXIST(lblpath+"$$$LAB.TMP") && upper(response) == "Y";
  134.      response=ASKUSER(temp_file_error,"Y",1);
  135.    enddo
  136.    if upper(response) == "Y" then
  137.      if not CREATE(lblpath+"$$$LAB.TMP") then;
  138.        PAUSE("$$$LAB.TMP"+".LBG"+read_only+any_key);
  139.        response="N";
  140.      endif
  141.    endif
  142.    if upper(response) != "Y" then
  143.      PAUSE(gen_request+any_key);
  144.      return 0;
  145.    endif
  146.  endif
  147.  
  148.  if not CREATE(lblname+".LBG") then;
  149.    PAUSE(fileroot(lblname)+".LBG"+read_only+any_key);
  150.    return 0;
  151.  endif
  152. }
  153. * Program............: {lblname}.LBG
  154. * Date...............: {LTRIM(SUBSTR(DATE(),1,8))}
  155. * Version............: dBASE IV, Label {FRAME_VER}
  156. *
  157. * Label Specifics:
  158. *   Wide - {lbl_wide}
  159. *   Tall - {label_tall}
  160. *   Indentation - {nul2zero(label_lmarg)}
  161. *   Number across - {label_nup}
  162. *   Space between - {lbl_hspace}
  163. *   Lines between - {lbl_vspace}
  164. *   Blankable lines - {number_of_blankable_lines}
  165. *   Print formatted - {printed_lines}
  166. *
  167. PARAMETER ll_sample
  168. *-- Set printer variables for this procedure only
  169. PRIVATE _peject, _ploffset, _wrap
  170.  
  171. *-- Test for End of file
  172. IF EOF()
  173.    RETURN
  174. ENDIF
  175.  
  176. IF SET("TALK")="ON"
  177.    SET TALK OFF
  178.    gc_talk="ON"
  179. ELSE
  180.    gc_talk="OFF"
  181. ENDIF
  182. gc_space = SET("SPACE")
  183. SET SPACE OFF
  184. gc_time=TIME()      && system time for predefined field
  185. gd_date=DATE()      && system date  "    "    "     "
  186. gl_fandl=.F.        && first and last record flag
  187. gl_prntflg=.T.      && Continue printing flag
  188. gn_column=1
  189. gn_element=0
  190. gn_line=1
  191. gn_memowid=SET("MEMOWIDTH")
  192. SET MEMOWIDTH TO 254
  193. gn_page=_pageno     && capture page number for multiple copies
  194. _plineno=0
  195. {if LABEL_LMARG then}
  196. _ploffset = _ploffset + {LABEL_LMARG}
  197. {endif}
  198. _wrap = .F.
  199.  
  200. IF ll_sample
  201.    DO Sample
  202.    IF LASTKEY() = 27
  203.       RETURN
  204.    ENDIF
  205. ENDIF
  206.  
  207. *-- Setup Environment
  208. ON ESCAPE DO prnabort
  209.  
  210. {numflds=FRAME_NUM_OF_FIELDS;}
  211. {if LABEL_NUP > 1 && numflds then}
  212. *-- Initialize array(s) for {LABEL_NUP} across labels
  213. DECLARE isfound[{LABEL_NUP-1}]
  214. DECLARE tmp4lbl[{LABEL_NUP-1},{numflds}]
  215. {endif}
  216. {if number_of_blankable_lines then}
  217. DECLARE gn_line2[{label_nup}]
  218. {endif}
  219.  
  220. PRINTJOB
  221.  
  222. {x=0;}
  223. {foreach FLD_ELEMENT k}
  224. //
  225. // only if there is a fieldname assigned to the calculated field
  226. //
  227. {if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
  228. {  if !x then}
  229. *-- Initialize calculated variables.
  230. {  endif}
  231. {FLD_FIELDNAME}=\
  232. {case FLD_VALUE_TYPE of}
  233. {68: // Date   }CTOD(SPACE(8))
  234. {70: // Float  }FLOAT(0)
  235. {76: // Logical}.F.
  236. {78: // Numeric}INT(0)
  237. {otherwise:}""
  238. {endcase}
  239. {  ++x;}
  240. {endif}
  241. {next k;}
  242.  
  243. *-- set page number for multiple copies
  244. _pageno=gn_page
  245.  
  246. DO WHILE FOUND() .AND. .NOT. EOF() .AND. gl_prntflg
  247. {LMARG(4);}
  248. {if LABEL_NUP > 1 and numflds then}
  249. {isfirst=1;}
  250. {x=1;}
  251. STORE .F. TO \
  252. {init_array:}
  253. {if isfirst then}
  254. {  isfirst=0;}
  255. {else}
  256. ,\
  257. {endif}
  258. isfound[{x}]\
  259. {++x;}
  260. {if x < LABEL_NUP then goto init_array endif}
  261.  
  262. {x=0;}
  263. {i=1;}
  264. {arcopy:}
  265. {  if x then}
  266. IF FOUND() .AND. .NOT. EOF()
  267. {    LMARG(7);}
  268. {  endif}
  269. {  calcflds();}
  270. //
  271. {foreach FLD_ELEMENT i}
  272. tmp4lbl[{x+1},{i}]=\
  273. {case FLD_FIELDTYPE of}
  274. {Tabl_data:}
  275. {  if FLD_VALUE_TYPE == 77 then}
  276. MLINE({FLD_FIELDNAME},1)
  277. {  else}
  278. {    FLD_FIELDNAME}
  279.  
  280. {  endif}
  281. {Calc_data:}
  282. {  if FLD_FIELDNAME then}
  283. {    FLD_FIELDNAME}
  284.  
  285. {  else}
  286. {    foreach FLD_EXPRESSION exp in i}
  287. {      FLD_EXPRESSION}\
  288. {    next}
  289.  
  290. {  endif}
  291. {Pred_data:}
  292. {  case FLD_PREDEFINE of}
  293. {  0: // Date}
  294. gd_date
  295. {  1: // Time}
  296. gc_time
  297. {  2: // Recno}
  298. RECNO()
  299. {  3: // Pageno}
  300. _pageno
  301. {  endcase}
  302. {endcase}
  303. {next i;}
  304. //
  305. {  if x then}
  306. isfound[{x}]=.T.
  307. {  endif}
  308. CONTINUE
  309. {  if x then}
  310. {    LMARG(4);}
  311. ENDIF
  312. {  endif}
  313. {  ++x;}
  314. {  if x < LABEL_NUP-1 then
  315.      goto arcopy;
  316.    endif
  317. }
  318. IF FOUND() .AND. .NOT. EOF()
  319. {LMARG(7);}
  320. {calcflds();}
  321. isfound[{x}]=.T.
  322. {LMARG(4);}
  323. ENDIF
  324. {else}
  325. {calcflds();}
  326. {endif}
  327. //
  328. {if number_of_blankable_lines then}
  329. gn_line=\
  330. {  if previous_row - number_of_blankable_lines > 0 then
  331.      previous_row - number_of_blankable_lines}
  332.  
  333. {  else}
  334. 0
  335. {  endif
  336.  endif
  337.  blank_line=0;
  338.  printed_lines=0;
  339.  previous_set_was_blank=0;}
  340. //
  341. // Main loop (inner loop to handles fields on each line by # of columns)
  342. //
  343. {foreach ELEMENT k}
  344. {  if ELEMENT_TYPE == @Band_Element then}
  345. {    ++k; ++item_number;}
  346. {    if eoc(k) then}
  347. {      exit;}
  348. {    endif}
  349. {  endif}
  350. {  ++count;}
  351. {  LMARG(4);}
  352. //
  353. {  check4_blank_line:
  354.  
  355.    if !blank_line then
  356.  
  357.      blank_line=1;
  358.      current_element=COUNTC(k);
  359.      previous_row=Row_Positn;
  360.      previous_set_was_blank=0;
  361.      printed_lines=0;
  362.  
  363.      do while !eoc(k);
  364.        if Row_Positn > previous_row then
  365.          ++printed_lines;
  366.          previous_set_was_blank=previous_set_was_blank+blank_line;
  367.          if Row_Positn > previous_row+1 then
  368.            blank_line=0;
  369.          else
  370.            blank_line=1;
  371.            previous_row=Row_Positn;
  372.          endif
  373.        endif
  374.        if blank_line then
  375.          if FLD_VALUE_TYPE == 78 then
  376.            if not AT("Z",FLD_PICFUN) then
  377.              blank_line=0;
  378.            endif
  379.          else
  380.            if Text_Item then
  381.              blank_line=0;
  382.            endif
  383.            if FLD_VALUE_TYPE != 67 then
  384.              blank_line=0;
  385.            endif
  386.          endif
  387.        endif
  388.        if !blank_line then
  389.          exit
  390.        endif
  391.        ++k;
  392.      enddo
  393.      if eoc(k) then
  394.        --k;
  395.        ++printed_lines;
  396.        if blank_line then
  397.          previous_set_was_blank=previous_set_was_blank+blank_line;
  398.          previous_row=Row_Positn;
  399.        endif
  400.      endif
  401.  
  402.      do while COUNTC(k) > current_element;
  403.        --k;
  404.      enddo
  405.  
  406.      if previous_set_was_blank then
  407.        blank_line=previous_set_was_blank;
  408.      else
  409.        blank_line=0;
  410.        printed_lines=0;
  411.      endif
  412.    else}
  413. {    if blank_line then
  414.        --blank_line;
  415.      endif}
  416. {    if label_nup > 1 then}
  417. {LMARG(4);}
  418. {    else}
  419. {LMARG(1);}
  420. {    endif}
  421. {    if blank_line then}
  422. ELSE
  423.    lc_ret=.T.
  424. {    endif}
  425. {    if label_nup > 1 then}
  426. ENDIF
  427. {    endif}
  428. {LMARG(1);}
  429. ENDIF
  430.  
  431. RETURN lc_ret
  432.  
  433. {    if blank_line > 0 then}
  434. FUNCTION ___{nul2zero(Row_Positn)}1
  435. lc_ret=.F.
  436.  
  437. {      if label_nup > 1 && mrows then
  438.          conditional_if_for_blank_line(k, 7);
  439.        else
  440.          conditional_if_for_blank_line(k, 4);
  441.        endif
  442.      endif
  443.      if !blank_line then
  444.        ++line;
  445.        LMARG(4);
  446.        APPEND(lblname+".LBG");
  447.      endif
  448.    endif
  449. }
  450. //---------------------
  451. // Process blank lines
  452. //---------------------
  453. {  nextline:}
  454. {  if line < Row_Positn then}
  455. {    if !blank_line || blank_line == printed_lines then}
  456. ?
  457. {    endif}
  458. {    ++line; goto nextline;}
  459. {  endif}
  460. //--------------------
  461. // End of blank lines
  462. //--------------------
  463. {  if previous_set_was_blank && !blank_line then goto check4_blank_line endif
  464.    if previous_set_was_blank && blank_line && blank_line==printed_lines then}
  465.  
  466. *-- Check for blank lines
  467. DO chk4null WITH {line}, {printed_lines}, {printed_lines*label_nup}
  468.  
  469. {    APPEND(lblpath+"$$$LAB.TMP");}
  470. {LMARG(1);}
  471. *
  472. *-- The next\
  473. {if printed_lines*label_nup > 1 then}
  474.  {printed_lines*label_nup}\
  475. {endif}
  476.  function file\
  477. {if number_of_blankable_lines > 1 then}s{endif} are for blank line checking
  478.  
  479. FUNCTION ___{line}1
  480. lc_ret=.F.
  481.  
  482. {    conditional_if_for_blank_line(k, 4);}
  483. {  endif}
  484. //
  485. {  mrows = 0;}
  486. {  first_item = item_number;}
  487. //
  488. {  repeat:}
  489. //
  490. {  if new_line then}
  491. {    if !mrows then}
  492. {      if !blank_line then}
  493. {LMARG(4);}
  494. {      endif}
  495. {    else}
  496. {      if blank_line then}
  497. {        if mrows < label_nup then}
  498. {          if mrows > 1 then LMARG(4); else LMARG(1); endif}
  499. {          if blank_line > 1 then}
  500. ELSE
  501.    lc_ret=.T.
  502. {          endif}
  503. ENDIF
  504. {        endif}
  505. {        if mrows > 1 then}
  506. {LMARG(1);}
  507. ENDIF
  508. {        endif}
  509.  
  510. RETURN lc_ret
  511.  
  512. FUNCTION ___{nul2zero(Row_Positn)}{mrows+1}
  513. lc_ret=.F.
  514.  
  515. {        if mrows then}
  516. *-- Column {mrows+1}
  517. IF isfound[{mrows}]
  518. {LMARG(4);}
  519. {        endif}
  520. {        if mrows then}
  521. {          conditional_if_for_blank_line(k,7);}
  522. {        else}
  523. {          conditional_if_for_blank_line(k,4);}
  524. {        endif}
  525. {      endif}
  526. {    endif}
  527. {    if LABEL_NUP > 1 && first_item == item_number then}
  528. {      if !blank_line then}
  529. *-- Column {mrows+1}
  530. {        if mrows then}
  531. IF isfound[{mrows}]
  532. {          if !blank_line then}
  533. {LMARG(7);}
  534. {          endif}
  535. {        endif}
  536. {      endif}
  537. {    endif}
  538. {    if first_combine then}
  539. _pcolno = {Col_Positn+(mrows*(lbl_wide+lbl_hspace))}
  540. {    endif}
  541. ?? \
  542. {  else}
  543. {    if long_line then}
  544. ?? \
  545. {      long_line=0;}
  546. {    else}
  547. ,\
  548. {    endif}
  549. {  endif}
  550. //
  551. {ni=0;}
  552. {  case ELEMENT_TYPE of}
  553. //
  554. {  @Text_Element:}
  555. //
  556. {x=Col_Positn;}
  557. {i=LEN(Text_Item);}
  558. {if i == 237 then}
  559. {  foreach Text_Item fcursor in k}
  560. {    if ni then}
  561. {      i=i+LEN(Text_Item);}
  562. {      temp=Text_Item;}
  563. {    endif}
  564. {    ++ni;}
  565. {  next}
  566. {endif}
  567. {current_column=x+i;}
  568. //
  569. {  @Fld_Element:}
  570. //
  571. {x=Col_Positn;}
  572. {i=FLD_REPWIDTH;}
  573. {if i > 237 then}
  574. {  foreach FLD_TEMPLATE fcursor in k}
  575. {    if ni then}
  576. {      temp=FLD_TEMPLATE;}
  577. {    endif}
  578. {    ++ni;}
  579. {  next}
  580. {endif}
  581. {current_column=x+i;}
  582. //
  583. {  endcase}
  584. //
  585. // is the next element on the same line
  586. //
  587. {  ++k;}
  588. {  if (not EOC(k)) && line == Row_Positn then}
  589. {    new_line=0;}
  590. //
  591. // is the next element flush with previous element
  592. //
  593. {    if current_column == Col_Positn then}
  594. {      combine=1;}
  595. {    else}
  596. {      combine=0;}
  597. {    endif}
  598. {  else}
  599. {    new_line=1;}
  600. {    next_row=Row_Positn;}
  601. {  endif}
  602. {  --k;}
  603. //-----------------------------------------------
  604. // Determine what type of data we are processing
  605. //-----------------------------------------------
  606. {  case ELEMENT_TYPE of}
  607. //
  608. {  @Text_Element:}
  609. //
  610. {if i > 70 then}
  611. ;
  612. {  seperate(Text_Item);}
  613. {  if ni then}
  614. + "{temp}";
  615. {  endif}
  616. {else}
  617. "{Text_Item}" \
  618. {endif}
  619. //
  620. {  @Fld_Element:}
  621. //
  622. {    if mrows+1 < LABEL_NUP then}
  623. tmp4lbl[{mrows+1},{mcolumns}] \
  624. {    else}
  625. {      putfld(k);}
  626. {    endif}
  627. {    ++mcolumns;}
  628. {  endcase}
  629. //
  630. {  if ELEMENT_TYPE == @Fld_Element then}
  631. //
  632. {    if !FLD_FIELDTYPE || FLD_FIELDTYPE == Calc_data || 
  633.         (FLD_FIELDTYPE == Pred_data && FLD_PREDEFINE > 1) then}
  634. //
  635. {      if FLD_VALUE_TYPE == 67 then
  636.          j=FLD_TEMPLATE+temp;
  637.          if FLD_LENGTH == FLD_REPWIDTH && j == REPLICATE("X",FLD_LENGTH) then
  638.            j="";
  639.          endif
  640.        else
  641.          j="1";
  642.        endif}
  643. //
  644. {      if FLD_PICFUN || j then}
  645. PICTURE \
  646. {      endif}
  647. //
  648. {      if FLD_PICFUN then}
  649. "@{FLD_PICFUN}\
  650. {        if j then}
  651.  \
  652. {        else}
  653. " \
  654. {        endif}
  655. {      endif}
  656. //
  657. {      if j then}
  658. {        if i > 70 then}
  659. {          if FLD_PICFUN then}
  660. "+;
  661. {          else}
  662. ;
  663. {          endif}
  664. {          seperate(FLD_TEMPLATE);}
  665. {          if ni then}
  666. + "{temp}";
  667. {          endif}
  668. {        else}
  669. {          if !FLD_PICFUN then}
  670. "\
  671. {          endif}
  672. {FLD_TEMPLATE}" \
  673. {        endif}
  674. {      endif}
  675. {    endif}
  676. //
  677. {  endif}
  678. //
  679. {  if FLD_STYLE then}
  680. {    style=getstyle(FLD_STYLE);}
  681. STYLE "{style}" \
  682. {  endif}
  683. {  if first_combine then}
  684. AT {Col_Positn+(mrows*(lbl_wide+lbl_hspace))} \
  685. {    if combine then}
  686. {      first_combine=0;}
  687. {    endif}
  688. {  else}
  689. {    if not combine then first_combine=1; endif}
  690. {  endif}
  691. //
  692. // position to next element
  693. //
  694. {  ++k; ++item_number;}
  695. //
  696. {  if !new_line || (!EOC(k) && line == Row_Positn) then
  697.      if !new_line then}
  698. {      if long_line then}
  699. ,
  700. {      else}
  701. ;
  702. {      endif}
  703. {    else}
  704. ,
  705. {      long_line=0;}
  706. {    endif
  707.      if !EOC(k) then
  708.        goto repeat;
  709.      endif}
  710. {  else}
  711. {    long_line=0;}
  712. {  endif}
  713. //
  714. {  combine=0;}
  715. {  first_combine=1;}
  716. //
  717. {  if LABEL_NUP-1 > mrows then}
  718. ,
  719. {    if mrows && !blank_line then}
  720. {        LMARG(4);}
  721. ENDIF
  722. {    endif}
  723. {    ++mrows;}
  724. {    backup_cursor:}
  725. {    if item_number > first_item then}
  726. {      --k; --item_number;}
  727. {      if ELEMENT_TYPE == @Fld_Element then}
  728. {        --mcolumns;}
  729. {      endif}
  730. {      goto backup_cursor;}
  731. {    endif}
  732. {    new_line=1;}
  733. {    goto repeat;}
  734. {  else}
  735.  
  736. {    if mrows && !blank_line then}
  737. {        LMARG(4);}
  738. ENDIF
  739. {    endif}
  740. {    mrows=0;}
  741. {    --k; --item_number;}
  742. {  endif}
  743. //
  744. {next k;}
  745. {if blank_line then}
  746. {  if label_nup > 1 then}
  747. {LMARG(4);}
  748. ENDIF
  749. {  endif}
  750. {LMARG(1);}
  751. ENDIF
  752.  
  753. RETURN lc_ret
  754.  
  755. {endif}
  756. {LMARG(4);}
  757. {APPEND(lblname+".LBG");}
  758. {if number_of_blankable_lines then}
  759. {  if !blank_line then}
  760. ?
  761. {  endif}
  762. DO WHILE gn_line < {label_tall+lbl_vspace}
  763.    ?
  764.    gn_line=gn_line+1
  765. ENDDO
  766. {else
  767.    lastline:
  768.    if line < LABEL_TALL+lbl_vspace then}
  769. ?
  770. {    ++line;
  771.      goto lastline;
  772.    endif
  773.  endif}
  774. CONTINUE
  775. {LMARG(1);}
  776. ENDDO
  777.  
  778. IF .NOT. gl_prntflg
  779.    SET MEMOWIDTH TO gn_memowid
  780.    SET SPACE &gc_space.
  781.    SET TALK &gc_talk.
  782.    ON ESCAPE
  783.    RETURN
  784. ENDIF
  785.  
  786. ENDPRINTJOB
  787.  
  788. SET MEMOWIDTH TO gn_memowid
  789. SET SPACE &gc_space.
  790. SET TALK &gc_talk.
  791. ON ESCAPE
  792. RETURN
  793. * EOP: {lblname}.LBG
  794.  
  795. PROCEDURE prnabort
  796. gl_prntflg=.F.
  797. RETURN
  798. * EOP: prnabort
  799.  
  800. {if number_of_blankable_lines then
  801.    COPY(lblpath+"$$$LAB.TMP");
  802.    FILEERASE(lblpath+"$$$LAB.TMP");
  803.    APPEND(lblname+".LBG");
  804.  endif}
  805. {if number_of_blankable_lines then}
  806. PROCEDURE chk4null
  807. *-- Parameters:
  808. *
  809. *-- 1) line number on the design surface
  810. *-- 2) maximum number of printable lines
  811. *-- 3) parameter 2 times number of labels across
  812. *
  813. PARAMETERS ln_line, ln_nolines, ln_element
  814. gn_element=0
  815. {    x=1;
  816.      do while x <= label_nup}
  817. gn_line2[{x}]=ln_line
  818. {      ++x;
  819.      enddo}
  820. lc_temp=SPACE(7)
  821. ll_output=.F.
  822. DO WHILE gn_element < ln_element
  823.    gn_column=1
  824.    ll_output=.F.
  825.    DO WHILE gn_column <= {label_nup}
  826.       IF gn_line2[gn_column] < ln_line+ln_nolines
  827.          lc_temp=LTRIM(STR(gn_line2[gn_column]))+LTRIM(STR(gn_column))
  828.          DO WHILE ___&lc_temp.()
  829.             gn_element=gn_element+1
  830.             gn_line2[gn_column]=gn_line2[gn_column]+1
  831.             lc_temp=LTRIM(STR(gn_line2[gn_column]))+LTRIM(STR(gn_column))
  832.          ENDDO
  833.          gn_element=gn_element+1
  834.          gn_line2[gn_column]=gn_line2[gn_column]+1
  835.       ENDIF
  836.       gn_column=gn_column+1
  837.    ENDDO
  838.    IF ll_output
  839.      ?
  840.      gn_line=gn_line+1
  841.    ENDIF
  842. ENDDO
  843. RETURN
  844. * EOP: chk4null
  845.  
  846. {endif}
  847. PROCEDURE SAMPLE
  848. PRIVATE x,y,choice
  849. DEFINE WINDOW w4sample FROM 15,20 TO 17,60 DOUBLE
  850. choice="Y"
  851. x=0
  852. DO WHILE choice = "Y"
  853.    y=0
  854.    ?
  855.    DO WHILE y < {LABEL_TALL}
  856.       x=0
  857.       DO WHILE x < {LABEL_NUP}
  858.          ?? REPLICATE("X",{LABEL_WIDE})\
  859. {if LABEL_HSPACE then}
  860. +SPACE({LABEL_HSPACE})
  861. {else}
  862.  
  863. {endif}
  864.          x=x+1
  865.       ENDDO
  866.       ?
  867.       y=y+1
  868.    ENDDO
  869. {if LABEL_VSPACE then}
  870.    x=0
  871.    DO WHILE x < {LABEL_VSPACE}
  872.       ?
  873.       x=x+1
  874.    ENDDO
  875. {endif}
  876.    ACTIVATE WINDOW w4sample
  877.    @ 0,3 SAY "{more_samples}";
  878.    GET choice PICTURE "!" VALID choice $ "NY"
  879.    READ
  880.    DEACTIVATE WINDOW w4sample
  881.    IF LASTKEY() = 27
  882.       EXIT
  883.    ENDIF
  884. ENDDO
  885. RELEASE WINDOW w4sample
  886. RETURN
  887. * EOP: SAMPLE
  888. {if !count then pause(label_empty + any_key); endif}
  889. {return 0;}
  890. //--------------------------------
  891. // End of main template procedure
  892. // User defined function follows
  893. //--------------------------------
  894. {
  895.  define getstyle(mstyle);
  896.   var outstyle; 
  897.   outstyle="";
  898.   if Bold        & mstyle then outstyle=outstyle+"B"; endif
  899.   if Italic      & mstyle then outstyle=outstyle+"I"; endif
  900.   if Underline   & mstyle then outstyle=outstyle+"U"; endif
  901.   if Superscript & mstyle then outstyle=outstyle+"R"; endif
  902.   if Subscript   & mstyle then outstyle=outstyle+"L"; endif
  903.   if User_Font   & mstyle then 
  904.     if  1 & mstyle then outstyle=outstyle+"1"; endif
  905.     if  2 & mstyle then outstyle=outstyle+"2"; endif
  906.     if  4 & mstyle then outstyle=outstyle+"3"; endif
  907.     if  8 & mstyle then outstyle=outstyle+"4"; endif
  908.     if 16 & mstyle then outstyle=outstyle+"5"; endif
  909.   endif
  910. return outstyle;
  911. enddef;
  912. }
  913. {define putfld(cursor);
  914.  var value,value2;
  915.  value=cursor.FLD_FIELDTYPE;}
  916. {          if mrows+1 < LABEL_NUP then}
  917. tmp4lbl[{mrows+1},{mcolumns}] \
  918. {          else}
  919. {case value of}
  920. {Tabl_data:}
  921. {  if cursor.FLD_VALUE_TYPE == 77 then}
  922. MLINE({cursor.FLD_FIELDNAME},1)\
  923. {  else}
  924. {    cursor.FLD_FIELDNAME}\
  925. {  endif}
  926. {Calc_data:}
  927. {  if cursor.FLD_FIELDNAME then}
  928. {    cursor.FLD_FIELDNAME }\
  929. {  else}
  930. {    foreach FLD_EXPRESSION exp in cursor}
  931. {      FLD_EXPRESSION}\
  932. {    next}
  933.  ;
  934. {    long_line=1;}
  935. {  endif}
  936. {Pred_data:}
  937. {  value2=cursor.FLD_PREDEFINE;}
  938. {  case value2 of}
  939. {  0: // Date}
  940. gd_date\
  941. {  1: // Time}
  942. gc_time\
  943. {  2: // Recno}
  944. RECNO()\
  945. {  3: // Pageno}
  946. _pageno\
  947. {  endcase}
  948. {endcase}
  949.  \
  950. {          endif}
  951. {return;
  952. enddef;
  953. }
  954. {
  955.  define conditional_if_for_blank_line(cursor2, page_offset);
  956.  var current_column, current_row;
  957. }
  958. *-- Test for blank line
  959. IF LEN(TRIM( \
  960. {      current_column=cursor2.Col_Positn;
  961.        current_element=COUNTC(cursor2);
  962.        current_row=cursor2.Row_Positn;
  963.        do while !eoc(cursor2) && cursor2.Row_Positn == current_row}
  964. {        if cursor2.Col_Positn > current_column then}+ {endif}\
  965. {        if cursor2.FLD_VALUE_TYPE == 78 then}
  966. TRANSFORM(\
  967. {          if mrows+1 < LABEL_NUP then}
  968. tmp4lbl[{mrows+1},{mcolumns}],"\
  969. {          else}
  970. {            if cursor2.FLD_FIELDNAME then}
  971. {cursor2.FLD_FIELDNAME},"\
  972. {            else}
  973. {              foreach FLD_EXPRESSION exp in cursor2}
  974. {                FLD_EXPRESSION}\
  975. {              next}
  976.  ;
  977. {            endif}
  978. {          endif}
  979. {          if cursor2.FLD_PICFUN then}
  980. {            if not cursor2.FLD_FIELDNAME then}
  981. ,"\
  982. {            endif}
  983. @{cursor2.FLD_PICFUN} \
  984. {          endif}
  985. {cursor2.FLD_TEMPLATE}") \
  986. {//
  987.          else
  988.            putfld(cursor2);
  989.          endif
  990.          ++cursor2;
  991.          ++mcolumns;
  992.        enddo
  993.        do while eoc(cursor2) || COUNTC(cursor2) > current_element;
  994.          --cursor2;
  995.          --mcolumns;
  996.        enddo}
  997. )) > 0
  998. {LMARG(page_offset);}
  999. ll_output=.T.
  1000. {  return;
  1001.  enddef
  1002. }
  1003. {
  1004. define nul2zero(numbr);
  1005. //
  1006. // if number is null convert to 0
  1007. //
  1008. if !numbr then numbr=0 endif;
  1009.  return numbr;
  1010.  enddef
  1011. }
  1012. {define calcflds();}
  1013. {foreach FLD_ELEMENT k}
  1014. {  if FLD_FIELDNAME && FLD_FIELDTYPE == Calc_data then}
  1015. {FLD_FIELDNAME}=\
  1016. {foreach FLD_EXPRESSION j in k}
  1017. {FLD_EXPRESSION}
  1018. {next}
  1019.  
  1020. {  endif}
  1021. {next k;}
  1022. {return;}
  1023. {enddef}
  1024. {
  1025.  define seperate(string);
  1026.  var x,y,length;
  1027.  x=1;
  1028.  length=LEN(string);
  1029.  moreleft:
  1030.  if x < length then
  1031.    if x != 1 then}
  1032. + \
  1033. {  endif
  1034.    if x+70 <= length then y=70; else y=length-x+1; endif}
  1035. "{SUBSTR(string,x,y)}";
  1036. {  x=x+70;
  1037.    goto moreleft;
  1038.  endif
  1039.  return;
  1040.  enddef
  1041. }
  1042. // EOP: LABEL.COD
  1043.