home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
sri314_b.zip
/
DEMOPRGS.ZIP
/
LAB_GEN.PRG
< prev
next >
Wrap
Text File
|
1990-04-11
|
9KB
|
342 lines
**********************************************************************
*** LAB_GEN.PRG **
** (C) Copyright 1990, Sub Rosa Publishing Inc.
** A demonstration program provided to SR-Info and VP-Info users.
** This program may be copied freely. If it is used in commercial code,
** please credit the source, Sub Rosa Publishing Inc.
**
** LAB_GEN is a much more complicated program than any of the others in
** the SUB ROSA demo collection. It is offerred as a 'DIPLOMA' program.
** When you have understood it all, you are well on yout way.
**
**
* LAB_GEN.prg demonstration program use of macros, files as
* vectors, and general matrices. This is a general-purpose
* program generator capable of producing most forms of labels
* any number of labels across, up to width of printer.
* (Author: Sidney L. Bursten)
**********************************************************************
xpict=:picture ;save standard picture, restore at end
:picture='999' ;use short picture in generating label program
ON escape
SET print off
SPOOL
WINDOW
ERASE
:picture=xpict
CANCEL
ENDON
ON error
SET print off
SPOOL
WINDOW
ERASE
:picture=xpict
CANCEL
ENDON
DIM char 80 xline[6],xline2[6] ;vectors to hold label-line expressions
USE matrix compile ;program must have a valid file in use to compile
xfld1=0 ;variables to hold field numbers from structure
xfld2=0
xfld3=0
xfld4=0
xfld5=0
xfld6=0
xfld7=0
xfld8=0
xfld9=0
xfld10=0
xfname=blank(8) ;data file name to be put into use with macro
xndxname=blank(8)
xwidth=4.25 ;default label width in inches
xacross=3 ;default number of labels across
xcpi=10 ;default characters per inch
xlines=6 ;default depth of label (one inch at 6 lpi)
xsetup='018'+blank(12)
xselect='N'
xselection=blank(50)
WINDOW
ERASE
WINDOW 2,4,22,75 double ;read in parameters of label job
TEXT
.. xfname,!!!!!!!!
.. xndxname,!!!!!!!!
.. xacross,9
.. xwidth,99999.99
.. xcpi,99.99
.. xlines,99
.. xsetup,999-999-999-999-999
.. xselect,!
GENERAL-PURPOSE PROGRAM GENERATOR FOR LABELS
(To quit enter ALL BLANKS instead of filename.)
Enter name of file to print to labels........... @xfname
Name of index file (if any) to use for order.... @xndxname
Number of labels to print across................ @xacross
Number of lines per label (measure top to top).. @xlines
Width of each label (right side to right side).. @xwidth inches
Number of characters per inch for print font.... @xcpi
Setup string to be sent to printer at start..... @xsetup
Should selection criteria be used (Y/N)?........ @xselect
ENDTEXT
ON field
FIELD xfname
IF xfname=blank(8)
:field=65
ELSE
IF file(xfname)
USE &xfname
ELSE
:field=field(xfname)
SOUND 11
ENDIF
ENDIF
FIELD xndxname
IF xndxname>blank(8)
IF file(trim(xndxname)+'.ndx')
SET index to &xndxname
ELSE
:field=field(xndxname)
SOUND 11
ENDIF
ENDIF
FIELD xacross
IF xacross<1 .or. xacross>8
:field=field(xacross)
SOUND 11
ENDIF
FIELD xwidth
IF xwidth<1 .or. xwidth>11
:field=field(xwidth)
SOUND 11
ENDIF
FIELD xlines
IF xlines<4 .or. xlines>24
:field=field(xlines)
SOUND 11
ENDIF
FIELD xcpi
IF xcpi<5 .or. xcpi>20
:field=field(xcpi)
SOUND 11
ENDIF
ENDON
READ
xwidth=int(xcpi*xwidth-1) ;width of ultimate label in characters
xwidth2=int(xwidth-xcpi/2.5) ;width that ensures no label contents run over end
formxwidth=(xwidth+2)*xacross ;total print width just enough to accommodate labels
IF xfname=' '
CHAIN menu
ENDIF
IF xselect='Y' ;get and test valid selection criteria if required
SELECT 1,2
WINDOW 10,10,17,69 double
? ' Selection Criteria Requested. Enter below:'
@ 13,13 get xselection
DO WHILE t
ERASE 13,17
READ
IF xselection=' ' .or. test(xselection)
BREAK
ENDIF
? ' Error in selection criteria...Press any key.'
SOUND 7
inkey=inkey()
ENDDO
SCREEN 2,1
WINDOW
ENDIF
WINDOW
ERASE
USE &xfname
WINDOW 1,35,22,78 double ;list 1st 21 fields of file structure
REPEAT min(21,dbf(fields)) times varying xfld
?? str(xfld,2),fld(name,xfld)
?
ENDREPEAT
IF dbf(fields)>21 ;if necessary, list next 21 fields of structure
WINDOW 1,55,22,78 blank
REPEAT min(21,dbf(fields)-21) times varying xfld
?? str(xfld+21,2),fld(name,xfld+21)
?
ENDREPEAT
ENDIF
WINDOW 1,1,22,30 double ;read in field numbers to use in labels
TEXT
.. xfld1,99
.. xfld2,99
.. xfld3,99
.. xfld4,99
.. xfld5,99
.. xfld6,99
.. xfld7,99
.. xfld8,99
.. xfld9,99
.. xfld10,99
For each of the following, enter number of the field containing the data to include in the label.
If any item is not to appear, leave its number zero.
Title..... @xfld1
First Name @xfld2
Last Name. @xfld3
Position.. @xfld4
Company... @xfld5
Address... @xfld6
City...... @xfld7
State..... @xfld8
Zip Code.. @xfld9
Country... @xfld10
ENDTEXT
READ
WINDOW
ERASE ;following section generates expressions for label lines
DO CASE ;title, first name, last name
CASE xfld1>0 .and. xfld2>0 .and. xfld3>0
xline[1]='ltrim(trim('+fld(name,xfld1)+')+" "+trim('+fld(name,xfld2)+')+" "+'+fld(name,xfld3)+')'
CASE xfld2>0 .and. xfld3>0
xline[1]='ltrim(trim('+fld(name,xfld2)+')+" "+'+fld(name,xfld3)+')'
CASE xfld3>0
xline[1]=fld(name,xfld3)
ENDCASE
IF xfld4>0 ;position
xline[2]=fld(name,xfld4)
ENDIF
IF xfld5>0 ;company
xline[3]=fld(name,xfld5)
ENDIF
IF xfld6>0 ;address
xline[4]=fld(name,xfld6)
ENDIF
DO CASE ;city, state, zip
CASE xfld7>0 .and. xfld8>0 .and. xfld9>0
xline[5]='ltrim(trim('+fld(name,xfld7)+')+", "+trim('+fld(name,xfld8)+')+" "+'+fld(name,xfld9)+')'
CASE xfld7>0 .and. xfld9>0
xline[5]='ltrim(trim('+fld(name,xfld7)+')+" "+'+fld(name,xfld9)+')'
CASE xfld7>0
xline[5]=fld(name,xfld7)
CASE xfld7>0 .and. xfld8>0
xline[5]='ltrim(trim('+fld(name,xfld7)+')+", "+'+fld(name,xfld8)+')'
CASE xfld9>0
xline[5]=fld(name,xfld9)
ENDCASE
IF xfld10>0 ;country
xline[6]=fld(name,xfld10)
ENDIF
CLS
xlines2=0
REPEAT 6 times varying xfld ;eliminate empty lines in label form
IF xline[xfld]>' '
xlines2=xlines2+1
xline2[xlines2]=xline[xfld]
ENDIF
ENDREPEAT
xskip=xlines-xlines2-1 ;extra lines needed to get to full depth of label
SPOOL label.prg
DELETE file LABEL.cpl ;old CPL must be deleted to force use of new program
CLEAR gets
ERASE
cdate=date(dmy)
ctime=time(ampm)
SET print on ;create the execution program LABEL.PRG
?? '**********************************************************************'
TEXT
* LABEL.PRG USES &XFNAME GENERATED &CDATE &CTIME
**********************************************************************
WINDOW
ERASE
DIM char &xwidth2 label[6,&xacross]
DIM char &xwidth labelout[&xlines2,&xacross]
USE &XFNAME
ENDTEXT
IF xselect='Y' .and. xselection>' '
? 'SET filter to '+xselection
ENDIF
IF xndxname>' '
? 'SET index to',xndxname
ELSE
DO CASE
CASE xfld9>0 .and. xfld3>0
? 'INDEX on '+fld(name,xfld9)+'+!('+fld(name,xfld3)+') to xlabel'
CASE xfld3>0
? 'INDEX on !('+fld(name,xfld3)+') to xlabel'
CASE xfld9>0
? 'INDEX on '+fld(name,xfld9)+' to xlabel'
ENDCASE
ENDIF
TEXT
SET print on
SET width to &formxwidth
GOTO top
ENDTEXT
IF xsetup>' '
xstr=$(xsetup,1,3)
xsetup2='chr('+xstr+')'
REPEAT 4 times varying xfld
xstr=$(xsetup,xfld*3+1,3)
IF xstr=' '
BREAK
ENDIF
xsetup2=xsetup2+'+chr('+xstr+')'
ENDREPEAT
? 'xsetup2='+xsetup2
? '?? xsetup2'
ENDIF
TEXT
DO WHILE .not. eof
REPEAT &xlines2 times varying xfld
REPEAT &xacross times varying xcolumn
labelout[xfld,xcolumn]=' '
ENDREPEAT
ENDREPEAT
REPEAT &xacross times varying xcolumn
ENDTEXT
REPEAT xlines2 times varying xfld
? ' label[',str(xfld,2),',xcolumn]=',trim(xline2[xfld])
ENDREPEAT
TEXT
xline2=0
REPEAT &xlines2 times varying xline
IF label[xline,xcolumn]>' '
xline2=xline2+1
labelout[xline2,xcolumn]=label[xline,xcolumn]
ENDIF
ENDREPEAT
SKIP
IF eof
BREAK
ENDIF
ENDREPEAT
? labelout
ENDTEXT
IF xskip>0
TEXT
REPEAT &xskip times
?
ENDREPEAT
ENDTEXT
ENDIF
TEXT
ENDDO
SET print off
EJECT
*
* *** end of program LABEL.PRG ***
* USES &XFNAME GENERATED &CDATE &CTIME
ENDTEXT
?
SET print off
SPOOL
:picture=xpict
*WRITE label
CHAIN LABEL
*
* *** END OF PROGRAM LAB_GEN.PRG ***