home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / text / pipmag3.arc / DBASE2.PIP < prev    next >
Encoding:
Text File  |  1988-01-07  |  12.8 KB  |  312 lines

  1.      *********************************************************************
  2.      THIS ARTICLE IS BEING PRESENTED THROUGH THE PIP ONLINE CP/M MAGAZINE
  3.      OF THE  NATIONAL CP/M ROUNDTABLE  ON GENIE.   copyright (c) 1989  BY
  4.      BILL JULIANI.   ALL RIGHTS RESERVED.   PERMISSION IS  HEREBY GRANTED
  5.      TO NON-PROFIT ORGANIZATIONS  ONLY TO REPRINT THIS ARTICLE OR PASS IT
  6.      ALONG  ELECTRONICALLY AS LONG  AS PROPER CREDIT IS GIVEN TO BOTH THE
  7.      AUTHOR AND GENIE.
  8.      ********************************************************************* 
  9.  
  10.  
  11.  
  12. ==============================================================================
  13.  
  14.                         CREATING & EXPORTING CDF FILES
  15.                          (Word Star Mail Merge Files)               
  16.                              By: Carl F. Howard
  17.                                    11/05/88 
  18.                              GEnie Address: CARL.H                         
  19.                          Commodore !FlagShip* RT SySop   
  20.  
  21. ============================================================================== 
  22.  
  23.  
  24. Hi All! 
  25.  
  26. This is the second of my dBase Articles for "PIP" the GEnie Online C-128 CP/M 
  27. Magazine.  The dBase column is intended to help C-128 dBase II users with the 
  28. fundamentals  of dBase II.    If  you have a  dBase question or an  idea  for 
  29. an article you would like  to  see written drop  me  a line and I'll be  glad 
  30. to help!
  31.  
  32. Well,  I  know I promised articles on SORTING and INDEXING files and creating 
  33. REPORT  files for future articles but I just couldn't help myself when I  got 
  34. the  idea  for this one when playing with my new Upgrade to Word  Star  (Word 
  35. Star Release 4.0 for CP/M).  I felt this was a great topic and one that could 
  36. help  a lot of new C-128 CP/Mers as these two programs are the  most  powerful 
  37. CP/M  applications  available  to  us.  I will incorporate  the  SORTING  and 
  38. INDEXING  commands  into the article as needed so you won't be  disappointed.  
  39. We will hold off REPORTS till the next issue. So here we go.
  40.  
  41. This  article  will discuss the creation of a dBase II CLIENT.DBF (DATA  BASE 
  42. FILE)  which  we  can use to store (and  manipulate)  information  about  our 
  43. clients.  This  data  can be EXPORTED by dBase II to a  Comma Delimited  File 
  44. (CDF), a data format used by the MAIL-MERGE feature of Word Star for printing 
  45. form letters and merging text files with variable data.    
  46.  
  47. Although  you can create a CDF file with any ASCII editor (WS N  Mode)  this 
  48. can  get  quite  cumbersome if you have a lot of data or a lot  of  variables 
  49. (fields).   This   is  due to the way the data is formatted in a CDF file  as  
  50. we  will  see.   Unlike the SDF format,   which is sorted in a  fixed  column  
  51. format,  the    CDF   format  stores  the  information  of  each   field   by   
  52. separating  (Delimiting) the Data with quote marks and  commas.   Each  field 
  53. must  be  marked off with delimiters even if there is no information  in  the 
  54. field.  Each  record  is  separated by a carriage return similar to  the  SDF 
  55. format.   The  fields must all be in the same order on each line.  The quotes 
  56. are used so that commas can used if contained as data.   To see Why this  can 
  57. be confusing to create on  an editor look at some sample data bellow: 
  58.  
  59. 'Mr.','Alfred',' ','Wilmot',' ','A 1 Sports','2353 W Lomita Blvd','Lomita','
  60. 'Mr.','Thomas',' ','Sullivan',' ','A A A Elect Entrprs','3170 E Willow St',
  61. 'Mr.','Jerome',' ','Aaron',' ','A A A Multi Crafts','1405 E 7Th St','Long Bch
  62.  
  63. Also,  using  an editor does not allow you to reorganize (sort) the data once 
  64. it has been created. dBase gives you the flexibility of storing all your data 
  65. in a central file and generating CDF's in any order that you need  them.  Ie. 
  66. ZIP  CODE order,  CITY or STATE order,  CLIENT NAME order  etc...  The  basic 
  67. techniques  discussed  in this article can be used with any version  of  Word 
  68. Star  and  dBase  II to create data bases for form letters and  envelopes  or 
  69. labels.
  70.  
  71.  
  72. :CREATING the  CLIENTS.DBF
  73. --------------------------
  74.  
  75. The first step in this process is to CREATE a dBase II DBF.  I'm going to use  
  76. a  FILE  STRUCTURE  that  I use at the office for  sending  form  letters  to 
  77. prospective  new  customers and keeping track of the over all results of  the 
  78. various mailings that we do.  To do this load dBase and type the following at 
  79. the dBase Dot (.) Prompt.
  80.  
  81.  .CREATE CLIENTS
  82.  
  83. Type in the File Structure indicated bellow:
  84.  
  85. Primary use database           
  86. Fld   Name   Type   Width   Dec
  87. 001     GNDR         C    004  
  88. 002     FIRSTNAME    C    010  
  89. 003     MIDDLENAME   C    010  
  90. 004     LASTNAME     C    021  
  91. 005     TITLE        C    010  
  92. 006     COMPANY      C    025  
  93. 007     STREET       C    033  
  94. 008     CITY         C    019  
  95. 009     ST           C    002  
  96. 010     ZIP          C    005  
  97. 011     PHONE        C    012  
  98. 012     SOURCE       C    006  
  99. 013     DESC         C    025  
  100. 014     SIZE         C    006  
  101. 015     MAILED       C    008  
  102. 016     CNTDT        C    008  
  103. 017     COMMENTS1    C    040  
  104. 018     COMMENTS2    C    040  
  105. 019     X            C    001  
  106.  
  107. (Note:   An   Actual   DBF  with  sample data is contained in   the   ARK/ARC  
  108. file containing  this article you can use it in lieu of actually making  your  
  109. own DBF).
  110.  
  111. Once you have finished entering the structure for Field 019 above hit  return 
  112. and  at the prompt for field 020 hit return again.  You will then be prompted 
  113. to  start adding your data.  Enter some sample data or just use the  the  DBF 
  114. that came with this article.
  115.  
  116. Once you have finished entering the data you are ready to EXPORT it to a  CDF 
  117. file.  If  you want to use the data in the order that you have entered it you 
  118. can proceed to the next step however,  if you would like to change the  order 
  119. lets say,  to generate a ZIPCODE ordered CDF file you will have to INDEX  the 
  120. DBF. Which gives me the opportunity to cover the SORT and INDEX COMMANDS. 
  121.  
  122. :SORTING vs. INDEXING
  123. ---------------------
  124.  
  125. To   create  a New DBF whose records are physically organized on  your   disk  
  126. in  ZIPCODE  order  and not the order you entered them in,   you can use  the  
  127. SORT command. To do so, you would type the following at the (.) prompt.
  128.  
  129.  .USE CLIENTS
  130.  .SORT on ZIP to CLIENT2
  131.  
  132. This tells dBase to SORT on the ZIP field and send the output of the sort  to 
  133. a new file named CLIENT2.
  134.  
  135. The problem  with the SORT command is that it is an inefficient way  (from  a 
  136. disk  storage standpoint) of accomplishing this purpose.  Which brings us  to 
  137. the concept of indexing.
  138.  
  139. An  INDEX  file can be created instead.  Rather than creating a new DBF  each 
  140. time  we want to Display/list or otherwise organize the DBF we can create  an 
  141. INDEX   file   INDEXED on the FIELD who's order we want to   use.   Basically  
  142. and INDEX file Points or tells dBase where the PHYSICAL record is Located  on 
  143. your  disk.   Essentially   dBase  looks at the data stored in the field  you  
  144. want   to organize  your DBF on and creates a sorted index file  pointing  to 
  145. the  actual record location on the disk. 
  146.  
  147. This  is  much more efficient and takes much less disk space than creating  a 
  148. whole new DBF each time we want to reorganize the data.  
  149.  
  150. Another  advantage building index files is that by indexing the file you  can 
  151. use the FIND command which searches the INDEX (.NDX file) for data instead of 
  152. the LOCATE command which searches the DBF.  This obviously speeds up the time 
  153. it  takes to retrieve data,  as indexed files are almost always smaller  than 
  154. the DBF's used to create them.
  155.  
  156. Also  you  can INDEX the DBF on Multiple fields.   We will get into the  FIND  
  157. and LOCATE commands in a future article.  Suffice it to say INDEXING files is 
  158. what gives  dBase  it's  power  in data retrieval.  
  159.  
  160. All   index  files end with an extension of  .NDX.    Generally  when  naming  
  161. index  files   you  will want to use a name that indicates both the DBF  Name 
  162. and  the FIELD  name  that  they are using.   For example,   we are going  to  
  163. name   this  zipcode  indexed  file  CLZIP.NDX.   CL for the clients DBF  and  
  164. ZIP  for  the zipcode  field.   If we were using the company field,  we would 
  165. use a name  of CLCOMP.NDX  or  CLCO.NDX.  
  166.  
  167. To  create  the  zipcode index you would type the following command  at  the 
  168. (.)prompt.
  169.  
  170.  .INDEX on ZIP to CLZIP 
  171.  
  172. This command tells dBase to build an .NDX file named CLZIP.NDX using the data 
  173. from  the ZIP field.  This index will stay active until you quit  dBase,  use 
  174. or  build  another  index or open another DBF.  If you want  to  access  your 
  175. records in the original order you can cancel the INDEX by using the following  
  176. command at the (.) prompt.
  177.  
  178.  .SET INDEX to 
  179.  
  180. This  command  will close the current index.
  181.  
  182. If you ever want to use the CLIENT.DBF in zipcode order again you can  access 
  183. it in two ways. The first lets you select the index when opening a DBF. 
  184.  
  185.  .USE CLIENTS INDEX CLZIP
  186.  
  187. The  second  lets you change from another INDEX or SET it once a DBF file  is 
  188. already in use.
  189.  
  190.  .SET INDEX to CLZIP.
  191.  
  192. WARNING:  As a General rule whenever you have created one or more INDEX files 
  193. for  a given DBF you should always open it when you are editing or  appending 
  194. records  to the DBF.  If you don't do this the INDEX will become invalid  and 
  195. you  will  encounter  at the least a RECORD OUT OF RANGE error and  risk  the 
  196. chance of loosing data or getting unreliable results. 
  197.  
  198.  
  199. If  you  get  an  error message when accessing data on  INDEXed  DBF  use  the 
  200. following:
  201.  
  202.  .REINDEX
  203.  
  204. This command will REINDEX the currently selected INDEX. 
  205.  
  206.  
  207. : CREATING THE CDF FILE
  208. ------------------------
  209.  
  210. To EXPORT the data to a CDF format use the following command:
  211.  
  212.  .USE CLIENTS INDEX CLZIP    (OPTIONAL IF THE DBF IS NOT ALREADY OPENED)
  213.  .COPY to CLZIP.CDF DELIMITED
  214.  
  215. These  commands  opens the DBF and selected INDEX files and then  copies  the 
  216. data in zipcode order to the NAMED delimited file. 
  217.  
  218. Note: You must include the extension .CDF and the word DELIMITED.
  219.  
  220. Its that SIMPLE <SMILE>
  221.  
  222.  
  223.  
  224.  
  225.  
  226. : CRATING A WORD STAR MASTER DOCUMENT FOR MERGE PRINTING
  227. ---------------------------------------------------------
  228.  
  229.  
  230. Using the Mail-Merge feature of Word Star requires the creation of TWO files. 
  231. The  First  is  the Data file which we have have just  discussed  above.  The 
  232. second  is  called the MASTER DOCUMENT FILE which  contains  at  least  three 
  233. sections. 
  234.  
  235. First  you must tell Word Star the Name of the File containing the DATA to be 
  236. used. 
  237.  
  238.  
  239. This is accomplished by using the following WS Dot Command. 
  240.  
  241.  .DF <FILENAME>
  242.  
  243.  
  244. Next you must define the Data Variables.  
  245.  
  246. This is accomplished by using the following WS Dot Command. 
  247.  
  248.  .RV FIELD1 FIELD2 FIELD3   Etc. ....
  249.  
  250.  
  251. Finally   you will have a section containing the Text and/or  Data  Variables  
  252. you want printed in your document. 
  253.  
  254.  
  255. The following is a commented MASTER DOCUMENT to create a form letter using  a 
  256. CDF file created from the the CLIENT.DBF.
  257.  
  258. Note:  The  actual  working  MASTER  DOCUMENT is a  file  called  MASTER.DOC 
  259. contained in this ARC/ARK file.
  260.  
  261.  
  262. ----------------------------------------------------------------------------
  263.  .OP            (WS Dot command  to Omit Page Numbering Used in W* Ver 4.0 )
  264.  .DF CLIENTS.CDF            (WS Dot Command to Define Data File NOT PRINTED)
  265.  .RV GNDR,FIRSTNAME,MIDDLE,LASTNAME,TITLE,COMPANY,STREET,CITY,
  266.  .RV ST,ZIP,PHONE,SOURCE,DESC,SIZE,MAILED,CNTDT,COMMENTS1,
  267.  .RV COMMENTS2,X        (WS DOT Command to Define Data Variables Must be in
  268.                          the same order as found in the CDF)
  269.  
  270.                          (Note: THE ABOVE LINES ARE NOT PRINTED When the (.)
  271.                                 begins a line. ) 
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  November 11, 1988
  278.  
  279.  &GNDR& &FIRSTNAME& &LASTNAME&      (NOTE:  &  &  Precede &  Follow DV Name)
  280.  &TITLE/O&                          ( /O - Omits Blank Line if Variable does  
  281.  &COMPANY/O&                               NOT exist in the Data File) 
  282.  &STREET&
  283.  &CITY&, &ST&   &ZIP&
  284.  
  285.  Dear &GNDR& &LASTNAME&
  286.  
  287.  This is a sample letter to demonstrate the Mail-Merge features of 
  288.  Word Star. 
  289.  
  290.  Type your own letter here!
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  Sincerely,
  299.  
  300.  
  301.  
  302.  Your Name
  303.  .pa  (This is a WS Dot Command for a Page break and sends a Form Feed to the 
  304.        Printer when this file is being executed.)
  305.  
  306. ---------------------------------------------------------------------------
  307.  
  308. Next  months Articles will be on and creating REPORT files for printing  list 
  309. of  records  in  your  DBF.  After  we have mastered some  more  of  the  the 
  310. fundamentals  I'll show you how to write simple dBase programs   (.CMD  FILES) 
  311. and create Menus. 
  312.  
  313. Regards,
  314. Carl.H
  315.