home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / db4bugs.zip / LABEL.COD < prev    next >
Text File  |  1989-04-13  |  21KB  |  957 lines

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