home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / softc2.zip / MANUAL.DOC < prev    next >
Text File  |  1990-08-02  |  351KB  |  15,841 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                                SoftC Database Library
  16.  
  17.                                   Reference Manual
  18.  
  19.  
  20.                                     Version 2.0
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.                    Manual and Software Copyright 1988, 1989, 1990
  32.                                          by
  33.  
  34.  
  35.                                     SoftC, Ltd.
  36.                            16820 Third Street North East
  37.                              Ham Lake, Minnesota 55304
  38.                     Telephone (612) 434-6968  Fax (612) 780-8728
  39.  
  40.  
  41.  
  42.                                 ALL RIGHTS RESERVED
  43.  
  44.  
  45.  
  46.              This document describes version 2.0 of the SoftC Database
  47.                           Library, released in July, 1990.
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.                       SoftC Database Library License Agreement
  74.  
  75.  
  76.             This License  Agreement  (Agreement)  is  between  you  (the
  77.             Customer) and  SoftC, Ltd.  (SoftC).  The Agreement pertains
  78.             to the  SoftC Database  Library, including  the object  code
  79.             libraries, sample  programs, source  code (if provided), and
  80.             modifications and/or  recompilations of the source code (the
  81.             Product), and the documentation.
  82.  
  83.             In exchange  for the non-exclusive right to use the Product,
  84.             the Customer agrees to the following terms.
  85.  
  86.             OWNERSHIP AND LIMITED LICENSE: The Product is owned by SoftC
  87.             and  is   protected  by   applicable  copyright   laws   and
  88.             international  treaty   provisions.     Licensed  GTDA.  The
  89.             Customer is  granted a  non-exclusive  license  to  use  the
  90.             Product on  a single  computer system  (i.e., with  a single
  91.             CPU) or network node at a time.
  92.  
  93.             COPYING AND  USE: The Customer may make backup copies of the
  94.             Product, but  may install  and use  the  Product  (including
  95.             modifications and/or recompilations of the software) on only
  96.             one computer or network node at a time.  This means that the
  97.             Product may  be used  by any  number of  people and  may  be
  98.             freely moved  from one computer location to another, so long
  99.             as there  is no possibility of it being used at one location
  100.             while it is being used at another.
  101.  
  102.             PRODUCT CODE  AND DERIVATIVE  WORKS:  In  exchange  for  the
  103.             benefit from  having access  to  the  Product  the  Customer
  104.             agrees to protect the copyright and other proprietary rights
  105.             of SoftC.   Such protection includes, but is not limited to,
  106.             a) the  Customer not  disclosing  the  code  (object  and/or
  107.             source) and  the way  it functions to any party not bound by
  108.             this Agreement,  b) the  Customer not allowing any party not
  109.             bound by  this Agreement  to copy  or  use  the  Product  or
  110.             documentation in  violation of  this Agreement  and  c)  the
  111.             Customer may  not disclose,  allow disclosure,  transmit, or
  112.             allow transmission,  either directly  or indirectly,  of the
  113.             source code  to any  third party  without the  prior written
  114.             consent of SoftC.  The Customer may modify and/or re-compile
  115.             the Product source code solely for the Customer's use.  Such
  116.             modified and/or  re-compiled  versions,  regardless  of  the
  117.             extent  of  the  modifications  or  the  compiler  versions,
  118.             operating systems, or computer systems used, are part of the
  119.             same Product  under this  Agreement  and  shall  remain  the
  120.             property of  SoftC subject  to  the  same  limitations  upon
  121.             transfer or  use as  the original Product.  The Customer may
  122.             reproduce and  distribute application programs created using
  123.             the Product  without  additional  licenses  or  fees.    Any
  124.  
  125.  
  126.  
  127.                                           2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.             modification of  the Product  source code  resulting  in  an
  140.             application or  derivative work  intended  for  distribution
  141.             requires prior written permission from SoftC and may require
  142.             additional terms and fees.
  143.  
  144.             TRANSFER: The  Customer  may  transfer  this  Agreement  and
  145.             Product along  with  all  originals,  any  copies,  and  the
  146.             documentation to  another party  provided  that  such  party
  147.             agrees in  writing to  be legally bound by these terms.  The
  148.             Customer's rights  shall terminate  upon  transfer  and  the
  149.             Customer agrees  to discontinue  immediately the  use of and
  150.             destroy any  and all  retained copies  of the  Product  upon
  151.             transfer.   The software  source code  if provided under the
  152.             license is not transferrable.
  153.  
  154.             LIMITED WARRANTY:   The  physical diskette(s)  and  physical
  155.             documentation  are  warranted  to  be  free  of  defects  in
  156.             materials and  workmanship for  a period  of sixty (60) days
  157.             from the  date of  original purchase.   For the same period,
  158.             the software  is warranted  against significant  errors that
  159.             make it  unusable for  the  operating  system  and  compiler
  160.             version originally  provided by  SoftC.    If  the  Customer
  161.             notifies SoftC within this 60 day period, SoftC will replace
  162.             any defective  diskette and/or  documentation.   SoftC  will
  163.             attempt to  correct or  help the Customer to avoid errors in
  164.             the software  with efforts  that SoftC  believes suitable to
  165.             the problem, or at SoftC's option, authorize a refund of the
  166.             Customer's  license   fee.     OTHER  THAN   THE   FOREGOING
  167.             WARRANTIES, SOFTC,  LTD. MAKES  NO  WARRANTIES,  EXPRESS  OR
  168.             IMPLIED, AND  SPECIFICALLY DISCLAIMS  ANY IMPLIED WARRANTIES
  169.             OF MERCHANTABILITY  OR FITNESS  FOR ANY  PARTICULAR PURPOSE.
  170.             SoftC, Ltd.  FURTHER RESERVES  THE RIGHT  TO MAKE CHANGES TO
  171.             THE SPECIFICATIONS  OF THE  PRODUCT  WITHOUT  OBLIGATION  TO
  172.             NOTIFY ANY PERSON OR ORGANIZATION OF SUCH CHANGES.
  173.  
  174.             LIMITATION OF  LIABILITY: The  Customer's sole  remedies are
  175.             set forth  in the  warranty clause above.  SoftC's liability
  176.             for damages  shall not exceed SoftC's suggested retail price
  177.             for the  Product.   In no event will SoftC be liable for any
  178.             special, incidental  or consequential  damages even if SoftC
  179.             has been advised of the possibility of the same.
  180.  
  181.             SUPPORT:   Product support, updates, fixes, enhancements, if
  182.             and as  they become available, may be offered for a separate
  183.             charge, but  SoftC has  no obligation  to provide  any  such
  184.             support, updates,  fixes, or  enhancements to  the  Product.
  185.             SoftC may  at its  sole discretion  provide  or  discontinue
  186.             support to  specific customers  on separate terms determined
  187.             solely by SoftC.
  188.  
  189.  
  190.  
  191.  
  192.  
  193.                                           3
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.             EXPORT:   The Customer  agrees not  to allow  the Product or
  206.             applications created using the Product to be sent to or used
  207.             in any  other country  except in  compliance with applicable
  208.             U.S. laws  and regulations.  If the Customer needs advice on
  209.             such export laws and regulations, the Customer shall contact
  210.             the  U.S.   Department   of   Commerce,   Export   Division,
  211.             Washington, DC 20230, U.S.A. for clarification.
  212.  
  213.             LICENSE TERMINATION:   This  Agreement shall  terminate upon
  214.             the transfer  of the  Product or  upon breach of any term of
  215.             this Agreement  by the  Customer.   The Customer shall cease
  216.             use of  the Product  upon termination.   In  the event  that
  217.             Customer has  received source  code for  the  Product,  upon
  218.             written request  by SoftC,  Customer shall  provide  written
  219.             certification by  an officer  of Customer that all copies of
  220.             the source code have been returned or destroyed.
  221.  
  222.             GOVERNING LAW:  This Agreement shall be governed by the laws
  223.             of the  State of  Minnesota.    If  any  provision  of  this
  224.             Agreement is  found void, invalid, or unenforceable, it will
  225.             not affect  the validity  of the  balance of  the Agreement,
  226.             which shall  remain valid  and enforceable  according to its
  227.             terms.  In the event any remedy herein is determined to have
  228.             failed  of   its  essential   purpose,  all  limitations  of
  229.             liability and  exclusion of  damages set  forth herein shall
  230.             remain in  full force  and effect.  This  Agreement  may  be
  231.             modified only  in writing  by the Customer and an authorized
  232.             representative of  SoftC.   Reasonable attorneys'  fees  and
  233.             court costs  shall be awarded to the prevailing party in any
  234.             action brought  in connection  with an alleged breach of the
  235.             terms of this Agreement.
  236.  
  237.             U.S.  GOVERNMENT   RESTRICTED  RIGHTS:    The  software  and
  238.             documentation are  provided with  RESTRICTED RIGHTS.    Use,
  239.             duplication, or  disclosure by  the Government is subject to
  240.             restrictions as  set forth in subparagraph (c)(1)(ii) of the
  241.             Rights in  Technical Data  and Computer  Software clause  at
  242.             52.227-7013. Contractor/manufacturer is SoftC, Ltd.
  243.  
  244.             ACCEPTANCE OF AGREEMENT:  The licensed use of the Product is
  245.             expressly conditioned  upon  the  Customer's  acceptance  of
  246.             these terms.   The  Customer may  accept these terms only by
  247.             signing  and  returning  the  Registration  Form.    SoftC's
  248.             acceptance of  these terms is represented by shipment of the
  249.             Product.
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                           4
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                                   Table Of Contents
  269.  
  270.  
  271.  
  272.             Chapter 1 Introduction..........................................1
  273.                Registration.................................................1
  274.                Shareware....................................................2
  275.                Typographic Conventions......................................2
  276.                Trademarks...................................................3
  277.                Support and Updates..........................................3
  278.  
  279.             Chapter 2 Before You Begin......................................4
  280.                The READ.ME File.............................................4
  281.                Library Files................................................4
  282.                Installing SoftC on Your System..............................6
  283.                SoftC Applications...........................................6
  284.                Compiling with Turbo C.......................................7
  285.                Compiling with Microsoft C...................................8
  286.                Compiling with Quick C.......................................8
  287.                Recompiling the Database Libraries...........................8
  288.                Function Naming Conventions..................................9
  289.  
  290.             Chapter 3 A Database Tutorial..................................10
  291.                Sequential Files............................................10
  292.                Random Access Files.........................................10
  293.                Keys........................................................11
  294.                ISAM........................................................11
  295.                Binary Trees................................................11
  296.                B- and B+ Trees.............................................11
  297.  
  298.             Chapter 4 Database Functions...................................13
  299.                dBASE Data File Functions...................................13
  300.                dBASE Data Record I/O.......................................14
  301.                dBASE Data Field I/O........................................15
  302.                File Sharing Functions......................................15
  303.                dBASEIII Memo File Functions................................16
  304.                dBASE Index File Functions..................................16
  305.                dBASE Index Page Functions..................................17
  306.                dBASE Index Key Functions...................................17
  307.                Clipper Index Functions.....................................18
  308.                FoxBASE+ Index Functions....................................18
  309.  
  310.             Chapter 5 Clock & Calendar Functions...........................19
  311.                Conversion to String........................................19
  312.                Conversion to Integers......................................19
  313.                Conversion to Long Integer..................................19
  314.                Day of Week Conversions.....................................20
  315.                Month Conversions...........................................20
  316.                Date String Calculations....................................20
  317.                Date Validation and Testing.................................20
  318.                Get Current Date from DOS...................................20
  319.                Time String to Numeric Conversion...........................20
  320.                Time Numeric to String Conversion...........................20
  321.                Time String Calculations....................................21
  322.  
  323.  
  324.  
  325.                                             v
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                                   TABLE OF CONTENTS
  335.  
  336.  
  337.                Time Validation.............................................21
  338.                Get Current Time from DOS...................................21
  339.  
  340.             Chapter 6 Miscellaneous Functions..............................22
  341.                Program Initialization......................................22
  342.                Program Termination.........................................22
  343.                Library Version.............................................22
  344.                Default Date String Format..................................22
  345.                Errors and Warnings.........................................22
  346.  
  347.             Chapter 7 Sharing Files on a LAN...............................24
  348.                Updating a Data Record......................................24
  349.                Adding or Removing a Data Record............................25
  350.  
  351.             Chapter 8 The SoftC Database Library...........................27
  352.                sccdi2l.....................................................29
  353.                sccdi2s.....................................................30
  354.                sccdiget....................................................31
  355.                sccdileap...................................................32
  356.                sccdiperm...................................................33
  357.                sccdl2dow...................................................34
  358.                sccdl2i.....................................................35
  359.                sccdl2sx....................................................36
  360.                sccds2day...................................................37
  361.                sccds2dow...................................................38
  362.                sccds2i.....................................................39
  363.                sccds2lx....................................................40
  364.                sccds2mon...................................................41
  365.                sccds2s.....................................................42
  366.                sccdsday....................................................43
  367.                sccdsdiff...................................................44
  368.                sccdsget....................................................45
  369.                sccdsleap...................................................46
  370.                sccdsmonth..................................................47
  371.                sccdsperm...................................................48
  372.                sccdsvalid..................................................49
  373.                sccti2s.....................................................50
  374.                scctiget....................................................51
  375.                sccts2i.....................................................52
  376.                scctsdiff...................................................53
  377.                scctsget....................................................54
  378.                scctsvalid..................................................55
  379.                scdcbfrsz...................................................56
  380.                scdcclose...................................................58
  381.                scdccreate..................................................59
  382.                scdcexpr....................................................61
  383.                scdcflush...................................................63
  384.                scdcindex...................................................65
  385.                scdcinfo....................................................66
  386.                scdckadd....................................................68
  387.                scdckbot....................................................70
  388.  
  389.  
  390.  
  391.                                             vi
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                                   TABLE OF CONTENTS
  401.  
  402.  
  403.                scdckcur....................................................72
  404.                scdckdel....................................................74
  405.                scdckfind...................................................76
  406.                scdckmake...................................................78
  407.                scdcknext...................................................81
  408.                scdckprev...................................................83
  409.                scdcktop....................................................85
  410.                scdcopenx...................................................87
  411.                scddbfrsz...................................................89
  412.                scddbof.....................................................91
  413.                scddclose...................................................92
  414.                scddcreate..................................................93
  415.                scddeof.....................................................96
  416.                scddfget....................................................97
  417.                scddfgets...................................................99
  418.                scddfinfo..................................................101
  419.                scddflush..................................................103
  420.                scddfnam2no................................................104
  421.                scddfput...................................................105
  422.                scddfputs..................................................107
  423.                scddinfo...................................................109
  424.                scddlock...................................................111
  425.                scddlud....................................................113
  426.                scddopenx..................................................114
  427.                scddpack...................................................116
  428.                scddrclear.................................................117
  429.                scddrdel...................................................118
  430.                scddrget...................................................119
  431.                scddrinfo..................................................120
  432.                scddrlock..................................................121
  433.                scddrnum...................................................123
  434.                scddrput...................................................124
  435.                scddrstat..................................................126
  436.                scddrundel.................................................127
  437.                scddsize...................................................128
  438.                scddunlock.................................................129
  439.                scdibfrsz..................................................131
  440.                scdiclose..................................................133
  441.                scdicreate.................................................134
  442.                scdiexpr...................................................136
  443.                scdiflush..................................................138
  444.                scdiindex..................................................140
  445.                scdiinfo...................................................141
  446.                scdikadd...................................................143
  447.                scdikbot...................................................145
  448.                scdikcur...................................................147
  449.                scdikdate..................................................149
  450.                scdikdel...................................................151
  451.                scdikfind..................................................153
  452.                scdikmake..................................................155
  453.                scdiknext..................................................158
  454.  
  455.  
  456.  
  457.                                            vii
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                                   TABLE OF CONTENTS
  467.  
  468.  
  469.                scdiknum...................................................160
  470.                scdikprev..................................................161
  471.                scdiktop...................................................163
  472.                scdinit....................................................165
  473.                scdiopenx..................................................167
  474.                scdnbfrsz..................................................169
  475.                scdnclose..................................................171
  476.                scdncreate.................................................172
  477.                scdnexpr...................................................174
  478.                scdnflush..................................................176
  479.                scdnindex..................................................178
  480.                scdninfo...................................................179
  481.                scdnkadd...................................................181
  482.                scdnkbot...................................................183
  483.                scdnkcur...................................................185
  484.                scdnkdate..................................................187
  485.                scdnkdel...................................................188
  486.                scdnkfind..................................................190
  487.                scdnkmake..................................................192
  488.                scdnknext..................................................195
  489.                scdnkprev..................................................197
  490.                scdnktop...................................................199
  491.                scdnopenx..................................................201
  492.                scdtclose..................................................203
  493.                scdtcreate.................................................204
  494.                scdterm....................................................205
  495.                scdtinfo...................................................206
  496.                scdtopenx..................................................207
  497.                scdtpack...................................................209
  498.                scdtrget...................................................210
  499.                scdtrput...................................................212
  500.                sceclr.....................................................214
  501.                scemsg.....................................................215
  502.  
  503.             Appendix A Result Codes and Messages..........................216
  504.                Warning Codes and Messages.................................216
  505.                Error Codes and Messages...................................217
  506.                Other Messages.............................................224
  507.  
  508.             Appendix B Diskette TOC Demo Program..........................225
  509.  
  510.             Index.........................................................227
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                            viii
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.             Chapter 1
  536.  
  537.  
  538.             Introduction
  539.  
  540.  
  541.  
  542.  
  543.             C is  generally considered  to be a "bare-bones" language. A
  544.             way  to  put  some  flesh  on  those  bones  is  to  develop
  545.             generalized functions  (extensions) which  may be  reused in
  546.             many programs.  The presence  of these  functions  can  make
  547.             programming a  quick and  simple task.  The absence of these
  548.             language extensions  can mean  many hours lost "re-inventing
  549.             the wheel".
  550.  
  551.  
  552.             Few programmers  have the time required to develop and debug
  553.             such a  library  of  functions.  This  is  where  the  SoftC
  554.             Database Library  comes in.  This library is a collection of
  555.             functions designed  to make  your applications  quicker  and
  556.             easier to code and test. With the library you can spend time
  557.             on your application not on developing tools.
  558.  
  559.  
  560.             The SoftC  Database Library  adds powerful  capabilities  to
  561.             your function library:
  562.  
  563.  
  564.                  - data, memo, and index file access functions for:
  565.                       dBASE III, Clipper, FoxBASE+
  566.                  - dBASEIV data file functions
  567.                  - date and time manipulation and calculation
  568.  
  569.  
  570.             The  SoftC  Database  Library  is  intended  for  use  as  a
  571.             supplement to  your compiler's object libraries. It contains
  572.             120 user functions. The primary purpose of the library is to
  573.             provide completely  compatible access  to dBASE  data, memo,
  574.             and index  files. The  clock/calendar  functions  have  been
  575.             added to  enhance the  core dBASE  routines. The  library is
  576.             currently available  for Microsoft  C 5.x  and 6.0,  Quick C
  577.             1.0/2.0,  and  Turbo  C  2.0.  These  routines  are  written
  578.             entirely in C.
  579.  
  580.  
  581.             Registration
  582.  
  583.             If you  find this  library useful,  you  are  encouraged  to
  584.             register.   Refer to  ORDER.DOC for  registration fees.   To
  585.             register,  read   the  license  agreement,  print  the  file
  586.  
  587.  
  588.  
  589.                                           1
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                               CHAPTER 1, INTRODUCTION
  599.  
  600.  
  601.             ORDER.DOC, and  mail the completed form and appropriate fees
  602.             to:
  603.  
  604.  
  605.                                     SoftC, Ltd.
  606.                               16820 Third Street N.E.
  607.                             Ham Lake, MN 55304-4703  USA
  608.  
  609.  
  610.             Shareware
  611.  
  612.             This library  is "shareware"  (user supported  software) NOT
  613.             "public domain",    which  means  that  the  SoftC  Database
  614.             Library (including the demonstration programs - SOFTC200.EXE
  615.             and SOFTC200.ZIP)  are the  copyrighted property  of  SoftC,
  616.             Ltd. Registered  users are  legally bound  by the  terms and
  617.             conditions set  forth in the license agreement.  Everyone is
  618.             granted the  right to  make copies  and to  freely share the
  619.             UNMODIFIED demonstration programs.
  620.  
  621.  
  622.             The shareware  concept  is  an  attempt  to  provide  useful
  623.             software at low cost.  The expense of offering a new product
  624.             by conventional  means is  quite high  and thus  discourages
  625.             many independent authors and small companies from developing
  626.             and promoting  their ideas.   Shareware  is  an  attempt  to
  627.             develop a  new  marketing  channel  where  products  can  be
  628.             introduced at minimum cost.
  629.  
  630.  
  631.             Everyone will benefit if shareware works.  The user benefits
  632.             by having quality products at low cost, and by being able to
  633.             test software  thoroughly before  purchasing it.  The author
  634.             benefits by  being able  to enter  the  commercial  software
  635.             market without the need of large amounts of venture capital.
  636.  
  637.  
  638.             But it can only work with your support. If you obtain a user
  639.             supported product  from a  friend or coworker, and are still
  640.             using it  after a  few weeks,  then it  is  obviously  worth
  641.             something to you and you should register it.
  642.  
  643.  
  644.             Typographic Conventions
  645.  
  646.             []             Square brackets enclose optional data.
  647.             Boldface       SoftC Database Library function names (such
  648.                            as scdinit) and structure names when they
  649.                            appear in text (but not in program examples).
  650.             Underline      indicate variable name "identifiers" which
  651.                            appear in text.
  652.  
  653.  
  654.  
  655.                                           2
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                               CHAPTER 1, INTRODUCTION
  665.  
  666.  
  667.             Trademarks
  668.  
  669.             Clipper is a registered trademark of Nantucket Software.
  670.             dBASE, dBASEIII, and dBASEIV are registered trademarks of
  671.             Ashton-Tate.
  672.             FoxBASE+ is a registered trademark of Fox Software.
  673.             Microsoft is a registered trademark of Microsoft
  674.             Corporation.
  675.             R&R Relational Report Writer is a registered trademark of
  676.             Concentric Data.
  677.             SoftC is a trademark of SoftC, Ltd.
  678.             Turbo C is a registered trademark of Borland International.
  679.  
  680.  
  681.             Support and Updates
  682.  
  683.             Technical advice  and technical  support will  be offered to
  684.             registered users  only.    Registered  users  will  also  be
  685.             notified when updates and new products are available.
  686.  
  687.  
  688.             We can be contacted by:
  689.  
  690.  
  691.             mail          SoftC, Ltd.
  692.                           16820 Third Street N.E.
  693.                           Ham Lake, MN 55304-4703  USA
  694.  
  695.             telephone     (612) 434-6968
  696.                           after 6pm Central Time
  697.  
  698.             modem         at above number (use voice first so that we
  699.                           can set up the modem).
  700.  
  701.             GEnie     "K.SCHUMANN"
  702.  
  703.             CompuServ      73667,3420.
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.                                           3
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.             Chapter 2
  734.  
  735.  
  736.             Before You Begin
  737.  
  738.  
  739.  
  740.  
  741.             This  chapter   supplies  instructions  for  installing  the
  742.             library on your hard disk and compiling the source.
  743.  
  744.  
  745.             The READ.ME File
  746.  
  747.             For last  minute update  information not  contained in  this
  748.             documentation, and/or a brief description of what's new with
  749.             this release please read the READ.ME file.
  750.  
  751.  
  752.             Library Files
  753.  
  754.             The SoftC Database Library is distributed in several archive
  755.             files.   The    demonstration   package   (SOFTC200.EXE   or
  756.             SOFTC200.ZIP) contains twelve (12) files (you are encouraged
  757.             to freely  share this  completely  unmodified  program  with
  758.             others):
  759.  
  760.  
  761.             CLIPPER.C     DBASE.C       FOXBASE.C
  762.             LICENSE.DOC   MANUAL.DOC    ORDER.DOC
  763.             SC_BASE.H     SC_CLOCK.H    SOFTC.H
  764.             SCDMC50S.LIB  SCDMC60S.LIB  SCDTC20S.LIB
  765.  
  766.  
  767.             The source  code archive  (SOURCE.EXE), for users registered
  768.             at that level, contains 125 files:
  769.  
  770.  
  771.             CBFRSZ.C      CCREATE.C     CDI2L.C
  772.             CDI2S.C       CDIGET.C      CDILEAP.C
  773.             CDIPERM.C     CDL2DOW.C     CDL2I.C
  774.             CDL2S.C       CDS2DAY.C     CDS2DOW.C
  775.             CDS2I.C       CDS2L.C       CDS2MON.C
  776.             CDS2S.C       CDSDAY.C      CDSDIFF.C
  777.             CDSGET.C      CDSLEAP.C     CDSMONTH.C
  778.             CDSPERM.C     CDSVALID.C    CEXPR.C
  779.             CFLUSH.C      CINDEX.C      CINFO.C
  780.             CKADD.C       CKBOT.C       CKCUR.C
  781.             CKDEL.C       CKFIND.C      CKMAKE.C
  782.             CKNEXT.C      CKPREV.C      CKTOP.C
  783.             COPEN.C       CPGET.C       CPPUT.C
  784.  
  785.  
  786.  
  787.                                           4
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                             CHAPTER 2, BEFORE YOU BEGIN
  797.  
  798.  
  799.             CTI2S.C       CTIGET.C      CTS2I.C
  800.             CTSDIFF.C     CTSGET.C      CTSVALID.C
  801.             DBFRSZ.C      DBOF.C        DCREATE.C
  802.             DEOF.C        DFGET.C       DFINFO.C
  803.             DFLUSH.C      DFNAM2NO.C    DFPUT.C
  804.             DINFO.C       DLOCK.C       DLUD.C
  805.             DOPEN.C       DPACK.C       DRCLEAR.C
  806.             DRGET.C       DRINFO.C      DRNUM.C
  807.             DRPUT.C       DRSTAT.C      DSIZE.C
  808.             EMSG.C        HCREATE.C     HEOF.C
  809.             HERASE.C      HFLUSH.C      HLEN.C
  810.             HLOCK.C       HREAD.C       HRENAME.C
  811.             HSEEK.C       HSIZE.C       HTELL.C
  812.             HWRITE.C      IBFRSZ.C      ICREATE.C
  813.             IEXPR.C       IFLUSH.C      IINDEX.C
  814.             IINFO.C       IKADD.C       IKBOT.C
  815.             IKCUR.C       IKDATE.C      IKDEL.C
  816.             IKFIND.C      IKMAKE.C      IKNEXT.C
  817.             IKPREV.C      IKTOP.C       INIT.C
  818.             IOPEN.C       IPGET.C       IPPUT.C
  819.             NBFRSZ.C      NCREATE.C     NEXPR.C
  820.             NFLUSH.C      NINDEX.C      NINFO.C
  821.             NKADD.C       NKBOT.C       NKCUR.C
  822.             NKDATE.C      NKDEL.C       NKFIND.C
  823.             NKMAKE.C      NKNEXT.C      NKPREV.C
  824.             NKTOP.C       NOPEN.C       NPGET.C
  825.             NPPUT.C       TCREATE.C     TINFO.C
  826.             TOPEN.C       TPACK.C       TRGET.C
  827.             TRPUT.C       SC_BASE.NTL
  828.  
  829.  
  830.             The  Turbo  C  object  code  library  archive  (TC2LIBS.EXE)
  831.             contains the following eleven (11) files:
  832.  
  833.  
  834.             CLIPPER.C     DBASE.C       FOXBASE.C
  835.             SC_BASE.H     SC_CLOCK.H    SOFTC.H
  836.             SCDTC20S.LIB  SCDTC20M.LIB  SCDTC20C.LIB
  837.             SCDTC20L.LIB  SCDTC20H.LIB
  838.  
  839.  
  840.             The  Microsoft   C   5.x   object   code   library   archive
  841.             (MSC5LIBS.EXE) contains the following eleven (11) files:
  842.  
  843.  
  844.             CLIPPER.C     DBASE.C       FOXBASE.C
  845.             SC_BASE.H     SC_CLOCK.H    SOFTC.H
  846.             SCDMC50S.LIB  SCDMC50M.LIB  SCDMC50C.LIB
  847.             SCDMC50L.LIB  SCDMC50H.LIB
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                                           5
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                             CHAPTER 2, BEFORE YOU BEGIN
  863.  
  864.  
  865.             The  Microsoft   C   6.0   object   code   library   archive
  866.             (MSC6LIBS.EXE) contains the following eleven (11) files:
  867.  
  868.  
  869.             CLIPPER.C     DBASE.C       FOXBASE.C
  870.             SC_BASE.H     SC_CLOCK.H    SOFTC.H
  871.             SCDMC60S.LIB  SCDMC60M.LIB  SCDMC60C.LIB
  872.             SCDMC60L.LIB  SCDMC60H.LIB
  873.  
  874.  
  875.             Installing SoftC on Your System
  876.  
  877.             The SoftC  Database Library   source code is compatible with
  878.             all of  the compilers  which we  support.  The  object  code
  879.             provided is for a specific C compiler.
  880.  
  881.  
  882.             Many compiler  manufacturers  suggest  a  certain  directory
  883.             setup to enable the compiler to find the header, object, and
  884.             library files.  Rather than  trying to  explain the  various
  885.             manufacturers suggested  directory setups,  we will  explain
  886.             what files are required and where they are often located.
  887.  
  888.  
  889.             The library header files need to be placed where they can be
  890.             found by  your compiler.  In many cases this is in a special
  891.             "INCLUDE" directory.  Other times they are placed where your
  892.             source code  is found.  We would suggest that they be placed
  893.             where the header files for your compiler are located.
  894.  
  895.  
  896.             Your linker  will need  to be  able to find the SoftC object
  897.             code libraries.  It is  suggested that these be placed where
  898.             the run-time libraries for your compiler are found.
  899.  
  900.  
  901.             The name  of the  library defines  the compiler manufacturer
  902.             and version, and the memory model for which it was compiled.
  903.             All library  names begin with "SCD". The next few characters
  904.             specify the  compiler manufacturer  and  version.  The  last
  905.             character defines the memory model.
  906.  
  907.  
  908.             For example  SCDTC20S.LIB is  the small memory model library
  909.             for Borland's Turbo C compiler (version 2.0x).
  910.  
  911.  
  912.             SoftC Applications
  913.  
  914.             A typical application skeleton has the following form:
  915.  
  916.  
  917.  
  918.  
  919.                                           6
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                             CHAPTER 2, BEFORE YOU BEGIN
  929.  
  930.  
  931.             #include <sc_base.h>
  932.  
  933.             /* global declarations */
  934.  
  935.             void main()
  936.             {
  937.               /* local declarations */
  938.  
  939.               scdinit(15,0);
  940.               .
  941.               .
  942.               .
  943.               /* body of application */
  944.               .
  945.               .
  946.               .
  947.               scdterm();
  948.             }
  949.  
  950.  
  951.  
  952.             The scdinit  function must  be the  first function called in
  953.             your application  and IT  MUST BE CALLED ONLY ONCE. The last
  954.             function should be scdterm. This is not a requirement but it
  955.             is good  programming practice.  This function should also be
  956.             called only once. See the descriptions of these functions in
  957.             the library reference section of this manual.
  958.  
  959.  
  960.             Compiling with Turbo C
  961.  
  962.             Turbo  C  provides  two  ways  of  compiling  programs:  the
  963.             integrated environment  and the  command  line  version.  In
  964.             order to  use the SoftC Database Library with the integrated
  965.             environment  a   project  file   must  be  created  and  the
  966.             appropriate library must be specified in that file:
  967.  
  968.  
  969.  
  970.             myprog              /* your program name */
  971.             scdtc20s.lib        /* the desired SoftC Database library */
  972.  
  973.  
  974.  
  975.             To use  the library  with the  command line  compiler simply
  976.             include the library name in the file name list:
  977.  
  978.  
  979.  
  980.             tcc -ms -I<header_file_path> -L<lib_file_path> myprog
  981.             scdtc20s.lib
  982.  
  983.  
  984.  
  985.                                           7
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                             CHAPTER 2, BEFORE YOU BEGIN
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.             Compiling with Microsoft C
  1001.  
  1002.             To use  the library  with Microsoft's  command line compiler
  1003.             simply include the library name in the file name list:
  1004.  
  1005.  
  1006.  
  1007.             cl /AS /Zp myprog scdmc50s.lib
  1008.  
  1009.  
  1010.  
  1011.             The above example used the small memory model for C 5.x. Use
  1012.             SCDMC60S.LIB for C 6.0.
  1013.  
  1014.  
  1015.             Compiling with Quick C
  1016.  
  1017.             To use  the library  with Quick  C's command  line  compiler
  1018.             simply include the library name in the file name list:
  1019.  
  1020.  
  1021.  
  1022.             qcl /AS /Zp myprog /link scdmc50s.lib
  1023.  
  1024.  
  1025.  
  1026.             Recompiling the Database Libraries
  1027.  
  1028.             If you  modify a  SoftC Database Library source module, then
  1029.             that module  and  any  related  modules  (if  any)  must  be
  1030.             recompiled and replaced in the libraries. The library source
  1031.             code is compiled just like any other program.
  1032.  
  1033.  
  1034.             Turbo C command line:
  1035.  
  1036.  
  1037.  
  1038.             tcc -c -ms -I<header_file_path> *.c
  1039.  
  1040.  
  1041.  
  1042.             Microsoft C command line:
  1043.  
  1044.  
  1045.  
  1046.             cl /AS /c /Zp /W3 *.c
  1047.  
  1048.  
  1049.  
  1050.  
  1051.                                           8
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                             CHAPTER 2, BEFORE YOU BEGIN
  1061.  
  1062.  
  1063.             Quick C command line:
  1064.  
  1065.  
  1066.  
  1067.             qcl /AS /c /Zp /W3 *.c
  1068.  
  1069.  
  1070.  
  1071.             Refer to  your compiler  documentation for  instructions for
  1072.             replacing modules in libraries.
  1073.  
  1074.  
  1075.             Function Naming Conventions
  1076.  
  1077.             All of  the SoftC  Database Library functions begin with the
  1078.             letters  "sc".  This  is  to  differentiate  them  from  the
  1079.             standard library functions.
  1080.  
  1081.  
  1082.             "scc"     clock/calendar functions
  1083.  
  1084.                  "sccd"    date or calendar functions
  1085.                  "scct"    time functions
  1086.  
  1087.  
  1088.             "scd"     database file functions
  1089.  
  1090.                  "scdc"    Clipper index file functions (open, close,                           etc.)
  1091.                  "scdck"   Clipper index key functions (add, delete,                           etc.)
  1092.  
  1093.                  "scdd"    dBASE data file functions (open, close, etc.)
  1094.                  "scddf"   dBASE data field functions
  1095.                  "scddr"   dBASE data record functions (write, read,
  1096.                            delete, etc.)
  1097.  
  1098.                  "scdi"    FoxBASE+ index file functions (open, close,                           etc.)
  1099.                  "scdik"   FoxBASE+ index key functions (add, delete,                           etc.)
  1100.  
  1101.                  "scdn"    dBASE index file functions (open, close,                           etc.)
  1102.                  "scdnk"   dBASE index key functions (add, delete, etc.)
  1103.  
  1104.                  "scdt"    memo file functions (open, close, etc.)
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.                                           9
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.             Chapter 3
  1130.  
  1131.  
  1132.             A Database Tutorial
  1133.  
  1134.  
  1135.  
  1136.  
  1137.             Most applications  need to do some file I/O operations. Your
  1138.             C compiler  provides you  with basic functions to do general
  1139.             file I/O.  But many  cases will arise when you need to use a
  1140.             database within your application. The SoftC Database Library
  1141.             provides functions  to enable  you to integrate your program
  1142.             and dBASEIII/Clipper/FoxBASE+  compatible  data,  memo,  and
  1143.             index files, and dBASEIV compatible data files.
  1144.  
  1145.  
  1146.             For those of you who may be unfamiliar with databases, think
  1147.             of a  filing cabinet filled with folders of invoices ordered
  1148.             alphabetically by  company name.  If we  wish  to  put  this
  1149.             information "on  computer" we have two choices for data file
  1150.             I/O: a simple sequential file, or a random access file.
  1151.  
  1152.  
  1153.             Sequential Files
  1154.  
  1155.             The concept of using a sequential file to store invoice data
  1156.             by company  name is very simple. Just enter the data as it's
  1157.             found in  the filing cabinet. To access the information just
  1158.             begin reading  at the  start of  the file and continue until
  1159.             finished. As  you can  see  the  time  required  to  find  a
  1160.             specific record  greatly increases  as more and more records
  1161.             are added to the file. Also the act of adding information to
  1162.             the file  while trying  to keep  it  in  alphabetical  order
  1163.             becomes very  time consuming  due  to  the  fact  that  many
  1164.             existing records will have to be moved in order to make room
  1165.             for the new record.
  1166.  
  1167.  
  1168.             Random Access Files
  1169.  
  1170.             By using  random access techniques it becomes much easier to
  1171.             access any  particular data  record. All that is required is
  1172.             the desired  record number  and you  can seek  to the proper
  1173.             location within  the data  file. But  how do  you know which
  1174.             record number  to use?  And what about adding records in the
  1175.             middle of  the data  file? dBASE  uses keys  and an  indexed
  1176.             lookup system called ISAM to solve both of these problems.
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.                                          10
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                            CHAPTER 3, A DATABASE TUTORIAL
  1193.  
  1194.  
  1195.             Keys
  1196.  
  1197.             Keys are  generally comprised  of  one  or  more  pieces  of
  1198.             information (data  fields) found  in a  data record.  In our
  1199.             example the  company name  could be  used as a key. Each key
  1200.             would point  to one  or more records found in the data file.
  1201.             When many keys are grouped together they form an index file.
  1202.             A technique  called ISAM  is used  to access  the underlying
  1203.             binary tree structure of the index files.
  1204.  
  1205.  
  1206.             ISAM
  1207.  
  1208.             The relationship  between a  key and  the data  file  record
  1209.             number is  established via  a "key item". Many key items are
  1210.             found on  an "index  page". Many index pages are combined to
  1211.             form an  "index file".  The method  used to navigate through
  1212.             the index  file is called "Indexed Sequential Access Method"
  1213.             or ISAM. The underlying structure used in ISAM is the binary
  1214.             tree (or decision tree).
  1215.  
  1216.  
  1217.             Binary Trees
  1218.  
  1219.             Binary trees are composed of nodes. Each node contains a key
  1220.             item (key  value, data  reference, and  pointers to left and
  1221.             right subtrees).  The node  that begins the tree is known as
  1222.             the root, and leaf nodes are found at the end of the tree.
  1223.  
  1224.  
  1225.             To find  a particular  data reference,  the binary  tree  is
  1226.             traversed from  the root node. At each node, the desired key
  1227.             is compared  with the  node's key;  if they don't match, one
  1228.             branch of  the node's subtree or the other is selected based
  1229.             on whether  the desired key is less than or greater than the
  1230.             node's key. This process continues until a match is found or
  1231.             an empty subtree is encountered.
  1232.  
  1233.  
  1234.             Binary trees  can get  quite unbalanced causing erratic tree
  1235.             traversal times. There are two variations of the binary tree
  1236.             commonly used to create balanced trees: B- and B+.
  1237.  
  1238.  
  1239.             B- and B+ Trees
  1240.  
  1241.             Generally speaking  B- trees allow more than one key item to
  1242.             be stored in a node (now called pages), and all the branches
  1243.             of the  tree are  of identical  length. The  B- tree  offers
  1244.             significant speed  advantages over  binary  trees,  but  the
  1245.             maintenance of  a B-  tree is  correspondingly more complex.
  1246.  
  1247.  
  1248.  
  1249.                                          11
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.                            CHAPTER 3, A DATABASE TUTORIAL
  1259.  
  1260.  
  1261.             Adding, modifying, or deleting a key value may result in the
  1262.             splitting or  merging of  a  page,  which  in  turns  forces
  1263.             additional operations on the tree to rebalance it.
  1264.  
  1265.  
  1266.             A B+  tree is a specialized form of the B- tree that has two
  1267.             types of  pages: internal,  which only  point to other pages
  1268.             (do not  contain data  reference field), and external, which
  1269.             contain the  actual data  reference (do  not contain subtree
  1270.             fields). The  advantage of  the B+ tree is that the internal
  1271.             pages can  hold more  decision values  than the intermediate
  1272.             pages of  a B-  tree, so  that the  fan out  of the  tree is
  1273.             faster and the average length of the branch is shorter. This
  1274.             makes up  for the fact that you must always follow a B+ tree
  1275.             to the  leaf page to get the data reference, whereas in a B-
  1276.             tree the data reference may be found in an intermediate page
  1277.             or even in the root page.
  1278.  
  1279.  
  1280.             dBASE and  Clipper use  a B-  tree structure, but dBASE does
  1281.             not make  use of the data reference in intermediate and root
  1282.             pages. FoxBASE+ uses a B+ tree structure.
  1283.  
  1284.  
  1285.             The first  question above  has been  obviously answered, but
  1286.             what about  the second?  The answer  lies in  the fact  that
  1287.             because we are using an index file we no longer have to keep
  1288.             the data  file in  alphabetical order,  all we need to do is
  1289.             append records  to the end of the data file and add a key to
  1290.             the index file.
  1291.  
  1292.  
  1293.             This ends  the general discussion of databases. One note, it
  1294.             is good  programming practice to create keys only from  data
  1295.             fields  found   in  the   data  record,   this  allows   the
  1296.             reconstruction   of   an   index   file   should   something
  1297.             catastrophic happen.
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.                                          12
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.             Chapter 4
  1328.  
  1329.  
  1330.             Database Functions
  1331.  
  1332.  
  1333.  
  1334.  
  1335.             In order  to benefit  fully from the SoftC Database Library,
  1336.             it is  necessary to  use only  the functions  found  in  the
  1337.             library  when   performing  database   I/O.  When   standard
  1338.             functions such  as fprintf  are  used,  the  SoftC  Database
  1339.             Library file  manager is bypassed. This means that it can no
  1340.             longer keep  track of  the activities in your database files
  1341.             which can lead to unpredictable results.
  1342.  
  1343.  
  1344.             This is  not to  say that you cannot use the standard C file
  1345.             I/O functions  found in your compiler's libraries, but their
  1346.             use should be restricted to non-database I/O.
  1347.  
  1348.  
  1349.             dBASE Data File Functions
  1350.  
  1351.             In order  to use  a data  file  it  first  must  be  opened.
  1352.             scddopenx will  open any  dBASEIII,  dBASEIII+,  or  dBASEIV
  1353.             compatible  data  file.  The  SoftC  Database  Library  file
  1354.             manager handle  will be returned. This handle number must be
  1355.             used for all I/O with that specific data file.
  1356.  
  1357.  
  1358.             When you  are finished  with a data file it is good practice
  1359.             to close  that data  file via  a call  to scddclose. This is
  1360.             true for  a couple  of reasons:  1) the data will be safe if
  1361.             your application  crashes, and  2) computer  memory will  be
  1362.             freed for  other use. A safety net is provided by scdterm in
  1363.             that it  will close  all data, memo, and index files open at
  1364.             program termination.
  1365.  
  1366.  
  1367.             The length  of the  data file  in bytes  can be  found using
  1368.             scddsize. The  name of the data file (and other information)
  1369.             associated with  a particular  handle can be retrieved via a
  1370.             call to  scddinfo. Also  a new  data file  can be created by
  1371.             scddcreate.
  1372.  
  1373.  
  1374.             scddbof checks the file pointer position and returns SC_TRUE
  1375.             if at  the beginning of the file. scddeof returns SC_TRUE if
  1376.             at the  end of  file. The  date the file was created or last
  1377.             modified is returned by scddlud.
  1378.  
  1379.  
  1380.  
  1381.                                          13
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.                            CHAPTER 4, DATABASE FUNCTIONS
  1391.  
  1392.  
  1393.             Record I/O will be buffered if the file was opened using the
  1394.             SC_BUFFER switch.  scddflush will flush all buffered data to
  1395.             the disk.  To get  the current  size of the I/O buffer or to
  1396.             change it, use scddbfrsz.
  1397.  
  1398.  
  1399.             dBASE Data Record I/O
  1400.  
  1401.             Having  a  data  file  is  of  little  use  unless  you  can
  1402.             manipulate the individual records. The library provides nine
  1403.             functions to:  read/write individual records, delete/recover
  1404.             deleted  records,   manipulate  I/O  buffers,  and  retrieve
  1405.             information about the record structure.
  1406.  
  1407.  
  1408.             A data record can be read from the data file using scddrget.
  1409.             The actual  data will  be placed  in an internal buffer. See
  1410.             the discussion  on Data  Field I/O  for more  information on
  1411.             accessing the individual fields found in a data record. When
  1412.             a data  record needs  to be  written to  the file,  scddrput
  1413.             should be  used. This function is used both for the changing
  1414.             of a record as well as adding new records.
  1415.  
  1416.  
  1417.             dBASE data  records are not physically removed from the data
  1418.             file when  they are deleted. This enables the user to change
  1419.             his mind  and recover the deleted records for use again. The
  1420.             SoftC Database  Library follows  this guideline by providing
  1421.             the scddrdel  function to mark a data record as deleted, and
  1422.             the scddrundel  function to  recover the  record (or mark as
  1423.             active).
  1424.  
  1425.  
  1426.              When  you have  inactive data  records which  you no longer
  1427.             want to  save use  scddpack to  "pack" the  data  file.  All
  1428.             inactive data  records will be removed from the file and the
  1429.             file compressed.
  1430.  
  1431.  
  1432.             Information about the data record structure can be retrieved
  1433.             by a  call to scddrinfo. The record length, number of fields
  1434.             in the  data record,  and the address of the internal record
  1435.             buffer can be obtained in this way.
  1436.  
  1437.  
  1438.             scddrclear is  useful in  clearing the  record buffer before
  1439.             placing data  in the  individual  fields.  The  entire  data
  1440.             record will  be set  to spaces (" "). This has the effect on
  1441.             numeric fields  of placing  nothing in the field rather than
  1442.             zero.
  1443.  
  1444.  
  1445.  
  1446.  
  1447.                                          14
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                            CHAPTER 4, DATABASE FUNCTIONS
  1457.  
  1458.  
  1459.             To get  the status  (active/inactive) of  the current record
  1460.             use scddrstat.  Use  scddrnum  to  get  the  current  record
  1461.             number.
  1462.  
  1463.  
  1464.             dBASE Data Field I/O
  1465.  
  1466.             The six  data field  manipulation functions provide for: the
  1467.             writing and  reading of  data to  and  from  fields  in  the
  1468.             internal I/O  buffer, the conversion of field names to field
  1469.             numbers,  and   the  retrieval  of  the  field  descriptions
  1470.             originally setup with scddcreate.
  1471.  
  1472.  
  1473.             There are  two types  of field  I/O: standard  C  types  and
  1474.             ASCIIZ string.  scddfput and  scddfget use  the  standard  C
  1475.             types  below  to  place  data  in  and  retrieve  data  from
  1476.             individual fields in a record. scddfput attempts to properly
  1477.             format the  data before  placing it in the field. This means
  1478.             that the  proper number  of spaces,  zeros, and/or a decimal
  1479.             point will  be added as appropriate. Please see the "Default
  1480.             Date  String  Format"  discussion  in  Chapter  6  for  more
  1481.             information about date fields.
  1482.  
  1483.  
  1484.             C types                  dBASE types
  1485.             ASCIIZ string            character
  1486.             ASCIIZ string            date
  1487.             double                   float (dBASEIV BCD)
  1488.             char                     logical
  1489.             unsigned long            memo
  1490.             double                   numeric
  1491.  
  1492.  
  1493.             scddfputs and  scddfgets use  ASCIIZ strings exclusively. It
  1494.             is left  up to  the users  of these functions to ensure that
  1495.             the data is properly formatted.
  1496.  
  1497.  
  1498.             A function  exists to retrieve the field descriptions (name,
  1499.             type, length,  number of  decimal places)  and the length of
  1500.             the longest  data field  (scddfinfo). A  field name to field
  1501.             number translation  function (scddfnam2no)  is  provided  to
  1502.             isolate your  application from  the structure  of  the  data
  1503.             files.
  1504.  
  1505.  
  1506.             File Sharing Functions
  1507.  
  1508.             Three functions  are available to facilitate file sharing on
  1509.             a local area network: scddlock (locks the entire data file),
  1510.  
  1511.  
  1512.  
  1513.                                          15
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.                            CHAPTER 4, DATABASE FUNCTIONS
  1523.  
  1524.  
  1525.             scddrlock (locks an individual record of the data file), and
  1526.             scddunlock (unlocks  the locked  region).  Please  refer  to
  1527.             Chapter 7  for  more  information  on  sharing  files  on  a
  1528.             network.
  1529.  
  1530.  
  1531.             dBASEIII Memo File Functions
  1532.  
  1533.             dBASE stores  the memo  file record number in the data file.
  1534.             The "scddfget"  functions return  the record  number and the
  1535.             "scddfput" functions expect a valid memo record number.
  1536.  
  1537.  
  1538.             Memo files  are not automatically opened when the data files
  1539.             are opened.  These  files  must  be  explicitly  opened  via
  1540.             scdtopenx. Any  dBASEIII+ compatible memo file can be opened
  1541.             with this  function. The SoftC Database Library file manager
  1542.             handle will  be returned on exit. This handle number must be
  1543.             used for all I/O with that memo file.
  1544.  
  1545.  
  1546.             When you  are finished  with a memo file it should be closed
  1547.             with a  call  to  scdtclose.  The  name  of  the  memo  file
  1548.             associated with  a particular  handle can be retrieved via a
  1549.             call to scdtinfo. A new file can be created by scdtcreate.
  1550.  
  1551.  
  1552.             dBASEIII inserts  soft carriage  returns in the memo data as
  1553.             it is written to the file. scdtrget will return the contents
  1554.             of the  memo record.  The user  specifies whether or not the
  1555.             soft carriage returns are removed.
  1556.  
  1557.  
  1558.             scdtrput allows  the user  to specify  whether or  not  soft
  1559.             carriage returns  are added  and, if added, the line length.
  1560.             Note that  the memo  file record  number  returned  by  this
  1561.             function should  be written  into the  appropriate data file
  1562.             field by using scddfput.
  1563.  
  1564.  
  1565.             There will  be times  when the data record associated with a
  1566.             memo record  has been physically removed (data file packed).
  1567.             When this occurs the memo file must be packed with scdtpack.
  1568.  
  1569.  
  1570.             dBASE Index File Functions
  1571.  
  1572.             In order  to use  an index  file it  first must  be  opened.
  1573.             scdnopenx will  open any  dBASEIII,  dBASEIII+,  or  dBASEIV
  1574.             compatible index  file (.NDX).  The SoftC  Database  Library
  1575.  
  1576.  
  1577.  
  1578.  
  1579.                                          16
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                            CHAPTER 4, DATABASE FUNCTIONS
  1589.  
  1590.  
  1591.             file manager  handle will  be returned.  This handle  number
  1592.             must be used for all I/O with that specific index file.
  1593.  
  1594.  
  1595.             When you  are finished  with an index file, it can be closed
  1596.             via a  call to  scdnclose. Information  about the index file
  1597.             such as  the file  name and length of the key expression can
  1598.             be retrieved  by a call to scdninfo. A new index file can be
  1599.             created by using the function scdncreate.
  1600.  
  1601.  
  1602.             scdnexpr can be used to get the actual index key expression.
  1603.             This key expression is generally a formula listing the field
  1604.             names used  to make  the index  key. For example, FIRST_NAME
  1605.             and LAST_NAME  are both  fields found  in a data file. If an
  1606.             index key was made from the combination of these fields, the
  1607.             key expression could be "LAST_NAME + FIRST_NAME".
  1608.  
  1609.  
  1610.             The functional  equivalent to  dBASE's "INDEX ON" command is
  1611.             provided by  scdnindex. This  function will  build an  index
  1612.             file.
  1613.  
  1614.  
  1615.             dBASE Index Page Functions
  1616.  
  1617.             Page I/O  will be  buffered if the file was opened using the
  1618.             SC_BUFFER switch.  scdnflush will flush all buffered data to
  1619.             the disk.  To get  the current  size of the I/O buffer or to
  1620.             change it, use scdnbfrsz.
  1621.  
  1622.  
  1623.             dBASE Index Key Functions
  1624.  
  1625.             Twelve functions  have been  provided for  use in: finding a
  1626.             key, moving  to the  next or previous key, adding/deleting a
  1627.             key, retrieving  the current  key, and building a key. There
  1628.             are three  search functions  supported: find  the first  key
  1629.             (scdnktop), find  the last  key (scdnkbot), and search for a
  1630.             specific key  (scdnkfind). The  keys found  in  this  manner
  1631.             become the  "current key".  Wildcards such  as "?"  and  "*"
  1632.             cannot be used.
  1633.  
  1634.  
  1635.             Once a  particular key  is found  it is often desired to get
  1636.             the key  following (scdnknext)  or preceding (scdnkprev) it.
  1637.             These keys,  if  found,  become  the  current  key.  Another
  1638.             function is provided to return the current key, scdnkcur.
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.                                          17
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                            CHAPTER 4, DATABASE FUNCTIONS
  1655.  
  1656.  
  1657.             It is  also desirable to be able to add and delete keys from
  1658.             the  index   file.  scdnkadd   and  scdnkdel  provide  these
  1659.             functions.
  1660.  
  1661.  
  1662.             A function  is supplied   to  convert date  fields to  valid
  1663.             index keys,  scdnkdate allows  the user  to specify the date
  1664.             string format.
  1665.  
  1666.  
  1667.             dBASE provides  certain functions which may be used in a key
  1668.             expression. scdnkmake  will build  a key  for you  using the
  1669.             index  key  expression  and  the  current  contents  of  the
  1670.             internal record  buffer of  the  data  file.  This  function
  1671.             supports five  of the  more common  dBASE  functions:  dtoc,
  1672.             left, right,  str, and  substr (and  the various  legitimate
  1673.             combinations). Note  that this function is not necessary for
  1674.             single  field   character  or   numeric  keys,  but  it  (or
  1675.             scdnkdate) can be used for date keys.
  1676.  
  1677.  
  1678.             Clipper Index Functions
  1679.  
  1680.             All the dBASE Index File functions listed above have Clipper
  1681.             equivalents with  the exception  of scdnkdate.  Clipper does
  1682.             not need the functionality provided by this function.
  1683.  
  1684.  
  1685.             FoxBASE+ Index Functions
  1686.  
  1687.             All  the  dBASE  Index  File  functions  listed  above  have
  1688.             FoxBASE+ equivalents.  FoxBASE+ has  one additional function
  1689.             used to  create  a  numeric  key  (scdiknum).  The  FoxBASE+
  1690.             numeric key  format as  stored on disk is different from 'C'
  1691.             doubles.
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.                                          18
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.             Chapter 5
  1724.  
  1725.  
  1726.             Clock & Calendar Functions
  1727.  
  1728.  
  1729.  
  1730.  
  1731.             This chapter  will describe  the  time  and  date  functions
  1732.             available in the SoftC Database Library. Currently there are
  1733.             twenty-seven functions   implemented:  twenty-one  calendar,
  1734.             and six clock.
  1735.  
  1736.  
  1737.             Five  date   string   formats   are   supported:   SC_GREGOR
  1738.             (mm/dd/yy), SC_GREGORL  (mm/dd/yyyy), SC_JULIAN  (yyyy/ddd),
  1739.             SC_YMD (yyyymmdd),  and SC_DMY  (ddmmyy).  Two  time  string
  1740.             formats are  supported: SC_CSHMS (hh:mm:ss) and SC_MIL (0000
  1741.             - 2359).
  1742.  
  1743.  
  1744.             Conversion to String
  1745.  
  1746.             Internal to  dBASE the  date fields are formatted as SC_YMD.
  1747.             This format enables the date field to be used properly as an
  1748.             index key and ensures that the date "February 13, 1989" will
  1749.             always be  larger than  the date  "December 15,  1988". Note
  1750.             that this  date format  is not  the one  normally used  when
  1751.             entering or  displaying dates.  In fact  dBASE uses the date
  1752.             format SC_GREGOR  when it displays dates. A function sccds2s
  1753.             was created  to allow  switching between  the  various  date
  1754.             formats.
  1755.  
  1756.  
  1757.             There are  two functions available to translate from numeric
  1758.             dates to  string  format:  sccdi2s,  source  date  is  three
  1759.             integers, and sccdl2sx, source date is a long integer.
  1760.  
  1761.  
  1762.             Conversion to Integers
  1763.  
  1764.             Conversion to integer date from a string is accomplished via
  1765.             sccds2i, and from a long integer by sccdl2i.
  1766.  
  1767.  
  1768.             Conversion to Long Integer
  1769.  
  1770.             Two functions  are provided to assist in the conversion to a
  1771.             long integer  date: sccdi2l translates an  integer date, and
  1772.             sccds2lx translates a string date.
  1773.  
  1774.  
  1775.  
  1776.  
  1777.                                          19
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.                        CHAPTER 5, CLOCK & CALENDAR FUNCTIONS
  1787.  
  1788.  
  1789.             Day of Week Conversions
  1790.  
  1791.             Two functions  are provided  to calculate the numeric day of
  1792.             week  (0-Sunday  ...  6-Saturday):  sccdl2dow  uses  a  long
  1793.             integer date input, and sccds2dow uses an ASCIIZ string. Two
  1794.             functions are  available to  return the  day of week string:
  1795.             sccdsday accepts  a numeric  input and sccds2day uses a date
  1796.             string.
  1797.  
  1798.  
  1799.             Month Conversions
  1800.  
  1801.             sccds2mon converts  from a  date string  to a  month of year
  1802.             string. Another  function uses  the month  number  as  input
  1803.             (sccdsmonth).
  1804.  
  1805.  
  1806.             Date String Calculations
  1807.  
  1808.             Three functions  are provided  to perform date calculations:
  1809.             sccdsdiff will  compute the  difference in  days between two
  1810.             dates, sccdsperm  and sccdiperm  return the  number of  days
  1811.             found in  the month  of the desired year. sccdsperm requires
  1812.             an ASCIIZ  string and sccdiperm requires an integer year and
  1813.             month as input.
  1814.  
  1815.  
  1816.             Date Validation and Testing
  1817.  
  1818.             Two functions  are provided  to  test  for  leap  year:  one
  1819.             requires an ASCIIZ string as input (sccdsleap) and the other
  1820.             an integer (sccdileap). Also sccdsvalid can be used to check
  1821.             the validity of an ASCIIZ date string.
  1822.  
  1823.  
  1824.             Get Current Date from DOS
  1825.  
  1826.             The current  DOS date  can be  returned either  in a  string
  1827.             (sccdsget) or in three integers (sccdiget).
  1828.  
  1829.  
  1830.             Time String to Numeric Conversion
  1831.  
  1832.             sccts2i can  be used  to convert  an ASCIIZ  string to three
  1833.             integers (hours, minutes, and seconds).
  1834.  
  1835.  
  1836.             Time Numeric to String Conversion
  1837.  
  1838.             A function  is also  provided to convert from integers to an
  1839.             ASCIIZ string: sccti2s.
  1840.  
  1841.  
  1842.  
  1843.                                          20
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.                        CHAPTER 5, CLOCK & CALENDAR FUNCTIONS
  1853.  
  1854.  
  1855.             Time String Calculations
  1856.  
  1857.             scctsdiff can  be used  to calculate  the difference between
  1858.             two ASCIIZ  time  strings.  The  difference  in  seconds  is
  1859.             returned in a long integer.
  1860.  
  1861.  
  1862.             Time Validation
  1863.  
  1864.             A function  is included in the library to validate an ASCIIZ
  1865.             time character string: scctsvalid.
  1866.  
  1867.  
  1868.             Get Current Time from DOS
  1869.  
  1870.             The current  DOS time  can be  returned either  in a  string
  1871.             (scctsget) or in four integers (scctiget).
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.                                          21
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.             Chapter 6
  1922.  
  1923.  
  1924.             Miscellaneous Functions
  1925.  
  1926.  
  1927.  
  1928.  
  1929.             This chapter will describe the miscellaneous functions found
  1930.             in the SoftC Database Library.
  1931.  
  1932.  
  1933.             Program Initialization
  1934.  
  1935.             scdinit sets  up the  SoftC Database  Library file  manager.
  1936.             Memory  will   be  allocated   for  a  variety  of  internal
  1937.             structures. As  previously mentioned this function should be
  1938.             called only once at the beginning of your application.
  1939.  
  1940.  
  1941.             Program Termination
  1942.  
  1943.             scdterm is  called at  the end  of your application. It will
  1944.             close all  dBASE files (unlocking any shared files) and free
  1945.             the memory  allocated  by  scdinit.  It  is  suggested  that
  1946.             scdterm be  registered with  atexit in  order to  activate a
  1947.             simple safety-net.
  1948.  
  1949.  
  1950.             Library Version
  1951.  
  1952.             The global  variable sc_version  contains the SoftC Database
  1953.             Library version as an ASCIIZ string.
  1954.  
  1955.  
  1956.             Default Date String Format
  1957.  
  1958.             The global  variable sc_date_style  holds  the  date  string
  1959.             format style  used by  scddfget and  scddfput.  The  initial
  1960.             value for  this variable  is SC_GREGOR. If, for example, you
  1961.             desire European/Military dates as the default style then set
  1962.             sc_date_style equal  to SC_DMY  at  the  beginning  of  your
  1963.             program.
  1964.  
  1965.  
  1966.             Errors and Warnings
  1967.  
  1968.             A global  variable sc_code  will contain  the results of the
  1969.             last library function call executed. Errors are indicated by
  1970.             negative numbers,  warnings by positive numbers greater than
  1971.             zero, and  a zero  indicates success.  Most functions in the
  1972.  
  1973.  
  1974.  
  1975.                                          22
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.                          CHAPTER 6, MISCELLANEOUS FUNCTIONS
  1985.  
  1986.  
  1987.             library will  NOT execute  if  sc_code  contains  an  error.
  1988.             Because  the   functions  will   not   operate   on   errant
  1989.             information,  this  feature  provides  a  small  measure  of
  1990.             security for your data.
  1991.  
  1992.  
  1993.             During program  debug it  may be  advantageous to  print the
  1994.             text message associated with the contents of sc_code. scemsg
  1995.             will return  the address  of the message associated with the
  1996.             contents of sc_code, which can then be printed by puts.
  1997.  
  1998.  
  1999.             If you  desire to clear an error or warning condition either
  2000.             the   global variable  sc_code can  be set  to zero  or  the
  2001.             function sceclr  can be  used. It  is preferable  to use the
  2002.             function rather than the global variable.
  2003.  
  2004.  
  2005.             See Appendix  A for  a complete  list of  error and  warning
  2006.             codes and their associated messages.
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.                                          23
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.             Chapter 7
  2054.  
  2055.  
  2056.             Sharing Files on a LAN
  2057.  
  2058.  
  2059.  
  2060.  
  2061.             As discussed previously, the SoftC Database Library provides
  2062.             three functions  to facilitate sharing files with dBASE on a
  2063.             Local  Area   Network  (LAN):   scddlock,   scddrlock,   and
  2064.             scddunlock. scddrlock  is used only when you are updating an
  2065.             individual record.  If a  record is  to be added to the data
  2066.             file or  an index  or memo  file is  to be modified (or even
  2067.             read), then  scddlock must  be used  to lock the entire data
  2068.             file. scddunlock is used to remove either of the locks.
  2069.  
  2070.  
  2071.             It is  NEVER a  good idea to keep a record/file locked while
  2072.             input is solicited from the keyboard.
  2073.  
  2074.  
  2075.             Updating a Data Record
  2076.  
  2077.             The proper  sequence to  follow when  updating a  record (no
  2078.             changes required to any associated index or memo files) is:
  2079.  
  2080.  
  2081.                  1)   Lock the record in the data file. If the record
  2082.                       cannot be locked then wait for a period of time
  2083.                       and try again. If after a reasonable number of
  2084.                       retries the record still cannot be locked then
  2085.                       fail.
  2086.                  2)   Read the original contents of the record.
  2087.                  3)   Unlock the record.
  2088.                  4)   Solicit keyboard input.
  2089.                  5)   Lock the record (as in step 1).
  2090.                  6)   Re-read the record.
  2091.                  7)   Verify no one else has changed it. If altered then
  2092.                       either go back to step 3, or if changes made by
  2093.                       others are unaffected by your changes then update
  2094.                       modified fields and continue.
  2095.                  8)   Update the record.
  2096.                  9)   Unlock the record.
  2097.  
  2098.  
  2099.  
  2100.             If you  think about  it the  reason for  steps 5-7  above is
  2101.             fairly obvious.  It is  reasonable to  expect that since you
  2102.             are updating  a record  someone else may want to update that
  2103.  
  2104.  
  2105.  
  2106.  
  2107.                                          24
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                          CHAPTER 7, SHARING FILES ON A LAN
  2117.  
  2118.  
  2119.             same record. Changes could be lost if steps are not taken to
  2120.             explicitly protect them.
  2121.  
  2122.  
  2123.             There will  be occasions  when the  field  modified  in  the
  2124.             record will  be: 1)  part of  or the entire key for an index
  2125.             file, or  2) an  added or  modified memo  record. When  this
  2126.             occurs the following sequence should be followed:
  2127.  
  2128.  
  2129.                  1)   Lock the record in the data file. If the record
  2130.                       cannot be locked, then wait for a period of time
  2131.                       and try again. If after a reasonable number of
  2132.                       retries the record still cannot be locked then
  2133.                       fail.
  2134.                  2)   Read the original contents of the record.
  2135.                  3)   Unlock the record.
  2136.                  4)   Solicit keyboard input.
  2137.                  5)   Lock the data file (similar to step 1).
  2138.                  6)   Re-read the record.
  2139.                  7)   Verify no one else has changed it. If altered then
  2140.                       either unlock the file and go back to step 4, or
  2141.                       if changes made by others are unaffected by your
  2142.                       changes then update modified fields and continue.
  2143.                  8)   Modify any memo or index files required.
  2144.                  9)   Update the record.
  2145.                  10)  Unlock the file.
  2146.  
  2147.  
  2148.             The memo  file must  be updated before the data file because
  2149.             the memo record number must be recorded in the data record.
  2150.  
  2151.  
  2152.             Adding or Removing a Data Record
  2153.  
  2154.             The proper  sequence to  follow when  adding or  removing  a
  2155.             record is:
  2156.  
  2157.  
  2158.                  1)   Lock the data file. If the file cannot be locked,
  2159.                       then wait for a period of time and try again. If
  2160.                       after a reasonable number of retries the file
  2161.                       still cannot be locked then fail.
  2162.                  2)   Modify memo file as needed.
  2163.                  3)   Add or delete the record.
  2164.                  4)   Update index file(s) as needed.
  2165.                  5)   Unlock the file.
  2166.  
  2167.  
  2168.             The memo  file must  be updated before the data file because
  2169.             the memo  record number must be recorded in the data record.
  2170.  
  2171.  
  2172.  
  2173.                                          25
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.                          CHAPTER 7, SHARING FILES ON A LAN
  2183.  
  2184.  
  2185.             The index  file(s) must  be updated after the data record is
  2186.             added because  the data  record number  is written  into the
  2187.             index file along with the key.
  2188.  
  2189.  
  2190.             The  locking  mechanisms  provided  by  dBASE  (Clipper  and
  2191.             FoxBASE+ as  well) are  very simple  and crude.  Many  other
  2192.             schemes exist  to provide  a more  elegant solution  to  the
  2193.             locking  problem,  but  keep  in  mind  that  they  are  not
  2194.             implicitly compatible  with dBASE.  They will  not work with
  2195.             dBASEIII+'s ASSIST  or with  R&R Report Writer, for example.
  2196.             We would  advise caution when contemplating straying too far
  2197.             from the dBASE standards.
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.                                          26
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.             Chapter 8
  2252.  
  2253.  
  2254.             The SoftC Database Library
  2255.  
  2256.  
  2257.  
  2258.  
  2259.             This chapter  contains a detailed description of each of the
  2260.             functions in the library.
  2261.  
  2262.  
  2263.             Many of  the code  samples listed  in this chapter are based
  2264.             upon the  demo programs  (versions for  dBASE, Clipper,  and
  2265.             FoxBASE+ index files) found in Appendix B.
  2266.  
  2267.  
  2268.             The following  sample function  description explains  how to
  2269.             use this  portion of  the SoftC  Database Library  Reference
  2270.             Manual.
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.                                          27
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2315.  
  2316.  
  2317.             function name  
  2318.  
  2319.             USAGE
  2320.                       function(
  2321.                            modifier parameter[,...]);
  2322.  
  2323.  
  2324.                       The declaration  syntax for  function, "parameter"
  2325.                       names are  underlined. The  [,...] indicates  that
  2326.                       other parameters and their modifiers may follow.
  2327.  
  2328.  
  2329.             PROTOTYPE IN
  2330.                       This lists  the header files in which the function
  2331.                       is prototyped.
  2332.  
  2333.  
  2334.             DESCRIPTION
  2335.                       This  describes   what  the   function  does,  the
  2336.                       parameters it  takes, and  any details you need in
  2337.                       order to use the function and the related routines
  2338.                       listed.
  2339.  
  2340.  
  2341.             SEE ALSO
  2342.                       Routines related  to the  function about which you
  2343.                       may wish to read are listed here.
  2344.  
  2345.  
  2346.             EXAMPLE
  2347.                       A sample  program listing  demonstrating  how  the
  2348.                       function is used.
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.                                          28
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2381.  
  2382.  
  2383.  
  2384.             sccdi2l   
  2385.  
  2386.             USAGE
  2387.                       signed int sccdi2l(
  2388.                            signed long *date,
  2389.                            signed int year,
  2390.                            signed int month,
  2391.                            signed int day );
  2392.  
  2393.  
  2394.             PROTOTYPE IN
  2395.                       sc_clock.h
  2396.  
  2397.  
  2398.             DESCRIPTION
  2399.                       sccdi2l  converts   three  integer   date   values
  2400.                       ("year", "month",  and "day") into a long integer.
  2401.                       The integer values are verified to be a valid date
  2402.                       before conversion.
  2403.  
  2404.  
  2405.             SEE ALSO
  2406.                       sccdl2i.
  2407.  
  2408.  
  2409.  
  2410.  
  2411.             EXAMPLE
  2412.  
  2413.             #include <stdio.h>
  2414.             #include <softc.h>
  2415.             #include <sc_clock.h>
  2416.  
  2417.             void main()
  2418.             {
  2419.               int year = 1990, month = 5, day = 16;
  2420.               long date = 0L;
  2421.  
  2422.               scdinit(20,0);
  2423.               sccdi2l(&date, year, month, day);
  2424.               printf("%d %d %d = %ld\n", year, month, day, date);
  2425.               scdterm();
  2426.             }
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.                                          29
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2447.  
  2448.  
  2449.  
  2450.             sccdi2s   
  2451.  
  2452.             USAGE
  2453.                       signed int sccdi2s(
  2454.                            signed char *string,
  2455.                            signed int format,
  2456.                            signed int year,
  2457.                            signed int month,
  2458.                            signed int day );
  2459.  
  2460.  
  2461.             PROTOTYPE IN
  2462.                       sc_clock.h
  2463.  
  2464.  
  2465.             DESCRIPTION
  2466.                       sccdi2s  converts   three  integer   date   values
  2467.                       ("year", "month", and "day") into an ASCIIZ string
  2468.                       "string" using  the date  string style "format". A
  2469.                       check is  made to  verify that "string" is a valid
  2470.                       date string before exiting.
  2471.  
  2472.  
  2473.                       Date string styles:
  2474.                       SC_GREGOR   mm/dd/yy
  2475.                       SC_GREGORL  mm/dd/yyyy
  2476.                       SC_JULIAN   yyyy/ddd
  2477.                       SC_YMD      yyyymmdd
  2478.                       SC_DMY      ddmmyy
  2479.  
  2480.             SEE ALSO
  2481.                       sccdsvalid, sccds2i.
  2482.  
  2483.  
  2484.  
  2485.  
  2486.             EXAMPLE
  2487.  
  2488.             #include <stdio.h>
  2489.             #include <softc.h>
  2490.             #include <sc_clock.h>
  2491.  
  2492.             void main()
  2493.             {
  2494.               signed char d[9];
  2495.  
  2496.               sccdi2s(d,SC_YMD,1989,2,13);
  2497.               puts(d);
  2498.             }
  2499.  
  2500.  
  2501.  
  2502.  
  2503.                                          30
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2513.  
  2514.  
  2515.  
  2516.             sccdiget  
  2517.  
  2518.             USAGE
  2519.                       signed int sccdiget(
  2520.                            signed int *year,
  2521.                            signed int *month,
  2522.                            signed int *monthday,
  2523.                            signed int *dayofweek );
  2524.  
  2525.  
  2526.             PROTOTYPE IN
  2527.                       sc_clock.h
  2528.  
  2529.  
  2530.             DESCRIPTION
  2531.                       sccdiget returns  the current date in integer form
  2532.                       from DOS.
  2533.  
  2534.  
  2535.             SEE ALSO
  2536.                       sccdsget.
  2537.  
  2538.  
  2539.  
  2540.  
  2541.             EXAMPLE
  2542.  
  2543.             #include <stdio.h>
  2544.             #include <softc.h>
  2545.             #include <sc_clock.h>
  2546.  
  2547.             void main()
  2548.             {
  2549.               int year, month, dayofmonth, dayofweek;
  2550.  
  2551.               sccdiget(&year, &month, &dayofmonth, &dayofweek);
  2552.               printf("%d %d %d %d\n",year, month, dayofmonth,
  2553.             dayofweek);
  2554.             }
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.                                          31
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2579.  
  2580.  
  2581.  
  2582.             sccdileap 
  2583.  
  2584.             USAGE
  2585.                       signed int sccdileap(
  2586.                            signed int leap );
  2587.  
  2588.  
  2589.             PROTOTYPE IN
  2590.                       sc_clock.h
  2591.  
  2592.  
  2593.             DESCRIPTION
  2594.                       sccdileap tests  the integer  year passed to it in
  2595.                       "leap" to see if it is a leap year.
  2596.  
  2597.  
  2598.             RETURN VALUES
  2599.                       SC_TRUE     is leap year
  2600.                       SC_FALSE    not leap year
  2601.  
  2602.             SEE ALSO
  2603.                       sccdsleap.
  2604.  
  2605.  
  2606.  
  2607.  
  2608.             EXAMPLE
  2609.  
  2610.             #include <stdio.h>
  2611.             #include <softc.h>
  2612.             #include <sc_clock.h>
  2613.  
  2614.             void main()
  2615.             {
  2616.               if (sccdileap(1989))
  2617.                 puts("Leap Year!");
  2618.               else
  2619.                 puts("Normal Year.");
  2620.             }
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.                                          32
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2645.  
  2646.  
  2647.  
  2648.             sccdiperm 
  2649.  
  2650.             USAGE
  2651.                       signed int sccdiperm(
  2652.                            signed char *days,
  2653.                            signed int year,
  2654.                            signed int month );
  2655.  
  2656.  
  2657.             PROTOTYPE IN
  2658.                       sc_clock.h
  2659.  
  2660.  
  2661.             DESCRIPTION
  2662.                       sccdiperm  calculates  the  number  of  "days"  in
  2663.                       "month" for "year". This function also senses leap
  2664.                       year  and   will  properly   return  29  days  for
  2665.                       February.
  2666.  
  2667.  
  2668.             SEE ALSO
  2669.                       sccdsperm.
  2670.  
  2671.  
  2672.  
  2673.  
  2674.             EXAMPLE
  2675.  
  2676.             #include <stdio.h>
  2677.             #include <softc.h>
  2678.             #include <sc_clock.h>
  2679.  
  2680.             void main()
  2681.             {
  2682.               signed char d;
  2683.  
  2684.               sccdiperm(&d,1989,3);
  2685.               printf("%d",d);
  2686.             }
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.                                          33
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2711.  
  2712.  
  2713.  
  2714.             sccdl2dow 
  2715.  
  2716.             USAGE
  2717.                       signed int sccdl2dow(
  2718.                            signed char *dayofweek,
  2719.                            signed long date );
  2720.  
  2721.  
  2722.             PROTOTYPE IN
  2723.                       sc_clock.h
  2724.  
  2725.  
  2726.             DESCRIPTION
  2727.                       sccdl2dow converts  a long  integer "date"  to  an
  2728.                       integer "dayofweek".  "dayofweek" will  be a value
  2729.                       between 0 (Sunday) and 6 (Saturday).
  2730.  
  2731.  
  2732.             SEE ALSO
  2733.                       sccds2dow.
  2734.  
  2735.  
  2736.  
  2737.  
  2738.             EXAMPLE
  2739.  
  2740.             #include <stdio.h>
  2741.             #include <softc.h>
  2742.             #include <sc_clock.h>
  2743.  
  2744.             void main()
  2745.             {
  2746.               char dayofweek;
  2747.               long date;
  2748.  
  2749.               sccdi2l(&date,1990,5,16);
  2750.               sccdl2dow(&dayofweek,date);
  2751.               printf("%d\n",dayofweek);
  2752.             }
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.                                          34
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2777.  
  2778.  
  2779.  
  2780.             sccdl2i   
  2781.  
  2782.             USAGE
  2783.                       signed int sccdl2i(
  2784.                            signed int *year,
  2785.                            signed int *month,
  2786.                            signed int *day,
  2787.                            signed long date );
  2788.  
  2789.  
  2790.             PROTOTYPE IN
  2791.                       sc_clock.h
  2792.  
  2793.  
  2794.             DESCRIPTION
  2795.                       sccdl2i converts  a long integer "date" into three
  2796.                       integers: "year",  "month", and  "day".   The long
  2797.                       "date"  is   tested  for   validity   before   the
  2798.                       conversion takes place.
  2799.  
  2800.  
  2801.             SEE ALSO
  2802.                       sccdi2l.
  2803.  
  2804.  
  2805.  
  2806.  
  2807.             EXAMPLE
  2808.  
  2809.             #include <stdio.h>
  2810.             #include <softc.h>
  2811.             #include <sc_clock.h>
  2812.  
  2813.             void main()
  2814.             {
  2815.               int year, month, day;
  2816.               long date;
  2817.  
  2818.               sccdi2l(&date,1990,5,16);
  2819.               date++;
  2820.               sccdl2i(&year,&month,&day,date);
  2821.               printf("%d %d %d\n",year,month,day);
  2822.             }
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.                                          35
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2843.  
  2844.  
  2845.  
  2846.             sccdl2sx  
  2847.  
  2848.             USAGE
  2849.                       signed int sccdl2sx(
  2850.                            signed char *string,
  2851.                            signed int format,
  2852.                            signed long date);
  2853.  
  2854.  
  2855.             PROTOTYPE IN
  2856.                       sc_clock.h
  2857.  
  2858.  
  2859.             DESCRIPTION
  2860.                       sccdl2sx converts  a long  "date"   into an ASCIIZ
  2861.                       string "string"  of the  date  style  "format".  A
  2862.                       check is  made to  verify that "string" is a valid
  2863.                       date string before exiting.
  2864.  
  2865.  
  2866.                       Date string styles:
  2867.                       SC_GREGOR   mm/dd/yy
  2868.                       SC_GREGORL  mm/dd/yyyy
  2869.                       SC_JULIAN   yyyy/ddd
  2870.                       SC_YMD      yyyymmdd
  2871.                       SC_DMY      ddmmyy
  2872.  
  2873.             SEE ALSO
  2874.                       sccds2lx.
  2875.  
  2876.  
  2877.  
  2878.  
  2879.             EXAMPLE
  2880.  
  2881.             #include <stdio.h>
  2882.             #include <softc.h>
  2883.             #include <sc_clock.h>
  2884.  
  2885.             void main()
  2886.             {
  2887.               signed char d[9];
  2888.  
  2889.               sccdl2sx(d,SC_YMD,726489);
  2890.               puts(d);
  2891.             }
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.                                          36
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2909.  
  2910.  
  2911.  
  2912.             sccds2day 
  2913.  
  2914.             USAGE
  2915.                       signed int sccds2day(
  2916.                            signed char *dayofweek,
  2917.                            signed char *daystr,
  2918.                            signed int format );
  2919.  
  2920.  
  2921.             PROTOTYPE IN
  2922.                       sc_clock.h
  2923.  
  2924.  
  2925.             DESCRIPTION
  2926.                       sccds2day converts an ASCIIZ string date "datestr"
  2927.                       of style "format" to an ASCIIZ string "dayofweek".
  2928.                       "dayofweek"  will  be  a  NULL  terminated  string
  2929.                       "Sunday" ... "Saturday".
  2930.  
  2931.  
  2932.                       Date string styles:
  2933.                       SC_GREGOR   mm/dd/yy
  2934.                       SC_GREGORL  mm/dd/yyyy
  2935.                       SC_JULIAN   yyyy/ddd
  2936.                       SC_YMD      yyyymmdd
  2937.                       SC_DMY      ddmmyy
  2938.  
  2939.             SEE ALSO
  2940.                       sccds2dow.
  2941.  
  2942.  
  2943.  
  2944.  
  2945.             EXAMPLE
  2946.  
  2947.             #include <stdio.h>
  2948.             #include <softc.h>
  2949.             #include <sc_clock.h>
  2950.  
  2951.             void main()
  2952.             {
  2953.               char dayofweek[10];
  2954.  
  2955.               sccds2day(dayofweek, "19900516", SC_YMD);
  2956.               printf("%s\n",dayofweek);
  2957.             }
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.                                          37
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2975.  
  2976.  
  2977.  
  2978.             sccds2dow 
  2979.  
  2980.             USAGE
  2981.                       signed int sccds2dow(
  2982.                            signed char *dayofweek,
  2983.                            signed char *daystr,
  2984.                            signed int format );
  2985.  
  2986.  
  2987.             PROTOTYPE IN
  2988.                       sc_clock.h
  2989.  
  2990.  
  2991.             DESCRIPTION
  2992.                       sccds2dow converts an ASCIIZ string date "datestr"
  2993.                       to an  integer "dayofweek".  "dayofweek" will be a
  2994.                       value between 0 (Sunday) and 6 (Saturday).
  2995.  
  2996.  
  2997.                       Date string styles:
  2998.                       SC_GREGOR   mm/dd/yy
  2999.                       SC_GREGORL  mm/dd/yyyy
  3000.                       SC_JULIAN   yyyy/ddd
  3001.                       SC_YMD      yyyymmdd
  3002.                       SC_DMY      ddmmyy
  3003.  
  3004.             SEE ALSO
  3005.                       sccds2day.
  3006.  
  3007.  
  3008.  
  3009.  
  3010.             EXAMPLE
  3011.  
  3012.             #include <stdio.h>
  3013.             #include <softc.h>
  3014.             #include <sc_clock.h>
  3015.  
  3016.             void main()
  3017.             {
  3018.               char dayofweek;
  3019.  
  3020.               sccds2dow(&dayofweek, "19900516", SC_YMD);
  3021.               printf("%d\n",dayofweek);
  3022.             }
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.                                          38
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3041.  
  3042.  
  3043.  
  3044.             sccds2i   
  3045.  
  3046.             USAGE
  3047.                       signed int sccds2i(
  3048.                            signed int *year,
  3049.                            signed int *month,
  3050.                            signed int *day,
  3051.                            signed char *string,
  3052.                            signed int format );
  3053.  
  3054.  
  3055.             PROTOTYPE IN
  3056.                       sc_clock.h
  3057.  
  3058.  
  3059.             DESCRIPTION
  3060.                       sccds2i  converts  dates  from  an  ASCIIZ  string
  3061.                       "string" of  the style  "format"  to three integer
  3062.                       values ("year",  "month", and  "day").  A  partial
  3063.                       check is  made to  verify that "string" is a valid
  3064.                       date string before attempting to convert.
  3065.  
  3066.  
  3067.                       Date string styles:
  3068.                       SC_GREGOR   mm/dd/yy
  3069.                       SC_GREGORL  mm/dd/yyyy
  3070.                       SC_JULIAN   yyyy/ddd
  3071.                       SC_YMD      yyyymmdd
  3072.                       SC_DMY      ddmmyy
  3073.  
  3074.             SEE ALSO
  3075.                       sccdi2s.
  3076.  
  3077.  
  3078.  
  3079.  
  3080.             EXAMPLE
  3081.  
  3082.             #include <stdio.h>
  3083.             #include <softc.h>
  3084.             #include <sc_clock.h>
  3085.  
  3086.             void main()
  3087.             {
  3088.               signed int y, m, d;
  3089.  
  3090.               sccds2i(&y,&m,&d,"19890213",SC_YMD);
  3091.               printf("%d %d %d",y,m,d);
  3092.             }
  3093.  
  3094.  
  3095.  
  3096.  
  3097.                                          39
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3107.  
  3108.  
  3109.  
  3110.             sccds2lx  
  3111.  
  3112.             USAGE
  3113.                       signed int sccds2lx(
  3114.                            signed long *date,
  3115.                            signed char *string,
  3116.                            signed int format );
  3117.  
  3118.  
  3119.             PROTOTYPE IN
  3120.                       sc_clock.h
  3121.  
  3122.  
  3123.             DESCRIPTION
  3124.                       sccds2lx converts  an ASCIIZ  "string" into a long
  3125.                       "date". The  date string  must  be  of  the  style
  3126.                       "format". This  date is a calculated count of days
  3127.                       since 1/1/0001. No attempt has been made to adjust
  3128.                       for changes made in the calendar. This function is
  3129.                       used   predominantly    for    date    arithmetic,
  3130.                       calculating elapsed days, etc.
  3131.  
  3132.  
  3133.                       Date string styles:
  3134.                       SC_GREGOR   mm/dd/yy
  3135.                       SC_GREGORL  mm/dd/yyyy
  3136.                       SC_JULIAN   yyyy/ddd
  3137.                       SC_YMD      yyyymmdd
  3138.                       SC_DMY      ddmmyy
  3139.  
  3140.  
  3141.  
  3142.             EXAMPLE
  3143.  
  3144.             #include <stdio.h>
  3145.             #include <softc.h>
  3146.             #include <sc_clock.h>
  3147.  
  3148.             void main()
  3149.             {
  3150.               signed long l;
  3151.  
  3152.               sccds2lx(&l,"19890323",SC_YMD);
  3153.               printf("%ld",l);
  3154.             }
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.                                          40
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3173.  
  3174.  
  3175.  
  3176.             sccds2mon 
  3177.  
  3178.             USAGE
  3179.                       signed int sccds2mon(
  3180.                            signed char *monthstr,
  3181.                            signed char *date,
  3182.                            signed int format );
  3183.  
  3184.  
  3185.             PROTOTYPE IN
  3186.                       sc_clock.h
  3187.  
  3188.  
  3189.             DESCRIPTION
  3190.                       sccds2mon  returns   the  ASCIIZ   month  of  year
  3191.                       ("monthstr").   The ASCIIZ date string ("date") is
  3192.                       converted to  integers under  control of  the date
  3193.                       string format  indicator ("format")  and then  the
  3194.                       month is translated into a string.
  3195.  
  3196.  
  3197.                       Date string styles:
  3198.                       SC_GREGOR   mm/dd/yy
  3199.                       SC_GREGORL  mm/dd/yyyy
  3200.                       SC_JULIAN   yyyy/ddd
  3201.                       SC_YMD      yyyymmdd
  3202.                       SC_DMY      ddmmyy
  3203.  
  3204.             SEE ALSO
  3205.                       sccds2day.
  3206.  
  3207.  
  3208.  
  3209.  
  3210.             EXAMPLE
  3211.  
  3212.             #include <stdio.h>
  3213.             #include <softc.h>
  3214.             #include <sc_clock.h>
  3215.  
  3216.             void main()
  3217.             {
  3218.               char month[10];
  3219.  
  3220.               sccds2mon(&month,"5/16/90",SC_GREGOR);
  3221.               puts(month);
  3222.             }
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.                                          41
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3239.  
  3240.  
  3241.  
  3242.             sccds2s   
  3243.  
  3244.             USAGE
  3245.                       signed int sccds2s(
  3246.                            signed char *outstr,
  3247.                            signed int outformat,
  3248.                            signed char *instr,
  3249.                            signed int informat );
  3250.  
  3251.  
  3252.             PROTOTYPE IN
  3253.                       sc_clock.h
  3254.  
  3255.  
  3256.             DESCRIPTION
  3257.                       sccds2s translates  one ASCIIZ date string "instr"
  3258.                       of   "informat"    to   another    ("outstr"    of
  3259.                       "outformat").   The input date string is converted
  3260.                       to integers  and checked for validity before being
  3261.                       translated to  a  string  again.    This  function
  3262.                       replaces the  sccdxlat  function  which  has  been
  3263.                       removed from the library.
  3264.  
  3265.  
  3266.                       Date string styles:
  3267.                       SC_GREGOR   mm/dd/yy
  3268.                       SC_GREGORL  mm/dd/yyyy
  3269.                       SC_JULIAN   yyyy/ddd
  3270.                       SC_YMD      yyyymmdd
  3271.                       SC_DMY      ddmmyy
  3272.  
  3273.  
  3274.  
  3275.             EXAMPLE
  3276.  
  3277.             #include <stdio.h>
  3278.             #include <softc.h>
  3279.             #include <sc_clock.h>
  3280.  
  3281.             void main()
  3282.             {
  3283.               char day[10];
  3284.  
  3285.               sccds2s(day, SC_GREGOR, "19900516", SC_YMD);
  3286.               puts(day);
  3287.             }
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.                                          42
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3305.  
  3306.  
  3307.  
  3308.             sccdsday  
  3309.  
  3310.             USAGE
  3311.                       signed int sccdsday(
  3312.                            signed char *daystr,
  3313.                            signed char day );
  3314.  
  3315.  
  3316.             PROTOTYPE IN
  3317.                       sc_clock.h
  3318.  
  3319.  
  3320.             DESCRIPTION
  3321.                       sccdsday returns the day of the week ASCIIZ string
  3322.                       in "daystr"  for the day specified by "day". "day"
  3323.                       must  be   in  the   range  of  0  (Sunday)  to  6
  3324.                       (Saturday).  The  maximum  length  of  the  string
  3325.                       returned will be 9 plus the NULL byte.
  3326.  
  3327.  
  3328.                       Date string styles:
  3329.                       SC_GREGOR   mm/dd/yy
  3330.                       SC_GREGORL  mm/dd/yyyy
  3331.                       SC_JULIAN   yyyy/ddd
  3332.                       SC_YMD      yyyymmdd
  3333.                       SC_DMY      ddmmyy
  3334.  
  3335.             SEE ALSO
  3336.                       sccdsmonth.
  3337.  
  3338.  
  3339.  
  3340.  
  3341.             EXAMPLE
  3342.  
  3343.             #include <stdio.h>
  3344.             #include <softc.h>
  3345.             #include <sc_clock.h>
  3346.  
  3347.             void main()
  3348.             {
  3349.               char day[10];
  3350.  
  3351.               sccdsday(day,0);
  3352.               puts(day);
  3353.             }
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.                                          43
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3371.  
  3372.  
  3373.  
  3374.             sccdsdiff 
  3375.  
  3376.             USAGE
  3377.                       signed int sccdsdiff(
  3378.                            signed long *diff,
  3379.                            signed char *date1,
  3380.                            signed int format1,
  3381.                            signed char *date2,
  3382.                            signed int format2 );
  3383.  
  3384.  
  3385.             PROTOTYPE IN
  3386.                       sc_clock.h
  3387.  
  3388.  
  3389.             DESCRIPTION
  3390.                       sccdsdiff returns  the difference  in days between
  3391.                       "date1" and  "date2". The  two ASCIIZ date strings
  3392.                       can be  in any  order, but  the styles ("format1",
  3393.                       "format2") must be valid.
  3394.  
  3395.  
  3396.                       Date string styles:
  3397.                       SC_GREGOR   mm/dd/yy
  3398.                       SC_GREGORL  mm/dd/yyyy
  3399.                       SC_JULIAN   yyyy/ddd
  3400.                       SC_YMD      yyyymmdd
  3401.                       SC_DMY      ddmmyy
  3402.  
  3403.             SEE ALSO
  3404.                       sccds2s, sccdi2s, sccdsvalid.
  3405.  
  3406.  
  3407.  
  3408.  
  3409.             EXAMPLE
  3410.  
  3411.             #include <stdio.h>
  3412.             #include <softc.h>
  3413.             #include <sc_clock.h>
  3414.  
  3415.             void main()
  3416.             {
  3417.               signed long d;
  3418.  
  3419.               sccdsdiff(&d, "19890213", SC_YMD, "19881217", SC_YMD);
  3420.               printf("%ld",d);
  3421.             }
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.                                          44
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3437.  
  3438.  
  3439.  
  3440.             sccdsget  
  3441.  
  3442.             USAGE
  3443.                       signed int sccdsget(
  3444.                            signed char *date,
  3445.                            signed int format );
  3446.  
  3447.  
  3448.             PROTOTYPE IN
  3449.                       sc_clock.h
  3450.  
  3451.  
  3452.             DESCRIPTION
  3453.                       sccdsget returns  the  current  "date"  in  ASCIIZ
  3454.                       string "format" from DOS.
  3455.  
  3456.  
  3457.                       Date string styles:
  3458.                       SC_GREGOR   mm/dd/yy
  3459.                       SC_GREGORL  mm/dd/yyyy
  3460.                       SC_JULIAN   yyyy/ddd
  3461.                       SC_YMD      yyyymmdd
  3462.                       SC_DMY      ddmmyy
  3463.  
  3464.             SEE ALSO
  3465.                       sccdiget, scctsget.
  3466.  
  3467.  
  3468.  
  3469.  
  3470.             EXAMPLE
  3471.  
  3472.             #include <stdio.h>
  3473.             #include <softc.h>
  3474.             #include <sc_clock.h>
  3475.  
  3476.             void main()
  3477.             {
  3478.               char date[10];
  3479.  
  3480.               sccdsget(date,SC_GREGOR);
  3481.               puts(date);
  3482.             }
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.                                          45
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3503.  
  3504.  
  3505.  
  3506.             sccdsleap 
  3507.  
  3508.             USAGE
  3509.                       signed int sccdsleap(
  3510.                            signed char *leap,
  3511.                            signed int format );
  3512.  
  3513.  
  3514.             PROTOTYPE IN
  3515.                       sc_clock.h
  3516.  
  3517.  
  3518.             DESCRIPTION
  3519.                       sccdsleap tests  the ASCIIZ  year string formatted
  3520.                       as "format" passed to it in "leap" to see if it is
  3521.                       a leap year.
  3522.  
  3523.  
  3524.                       Date string styles:
  3525.                       SC_GREGOR   mm/dd/yy
  3526.                       SC_GREGORL  mm/dd/yyyy
  3527.                       SC_JULIAN   yyyy/ddd
  3528.                       SC_YMD      yyyymmdd
  3529.                       SC_DMY      ddmmyy
  3530.  
  3531.             RETURN VALUES
  3532.                       SC_TRUE     is leap year
  3533.                       SC_FALSE    not leap year
  3534.  
  3535.             SEE ALSO
  3536.                       sccdileap
  3537.  
  3538.  
  3539.  
  3540.  
  3541.             EXAMPLE
  3542.  
  3543.             #include <stdio.h>
  3544.             #include <softc.h>
  3545.             #include <sc_clock.h>
  3546.  
  3547.             void main()
  3548.             {
  3549.               if (sccdsleap("19890101",SC_YMD))
  3550.                 puts("Leap Year!");
  3551.               else
  3552.                 puts("Normal Year.");
  3553.              }
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.                                          46
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3569.  
  3570.  
  3571.  
  3572.             sccdsmonth     
  3573.  
  3574.             USAGE
  3575.                       signed int sccdsmonth(
  3576.                            signed char *monthstr,
  3577.                            signed char month );
  3578.  
  3579.  
  3580.             PROTOTYPE IN
  3581.                       sc_clock.h
  3582.  
  3583.  
  3584.             DESCRIPTION
  3585.                       sccdsmonth returns  the  ASCIIZ  month  string  in
  3586.                       "monthstr" for  the month  specified  by  "month".
  3587.                       "month" must  be in the range of 1 (January) to 12
  3588.                       (December).  The  maximum  length  of  the  string
  3589.                       returned will be 9 plus the NULL byte.
  3590.  
  3591.  
  3592.                       Date string styles:
  3593.                       SC_GREGOR   mm/dd/yy
  3594.                       SC_GREGORL  mm/dd/yyyy
  3595.                       SC_JULIAN   yyyy/ddd
  3596.                       SC_YMD      yyyymmdd
  3597.                       SC_DMY      ddmmyy
  3598.  
  3599.             SEE ALSO
  3600.                       sccdsday
  3601.  
  3602.  
  3603.  
  3604.  
  3605.             EXAMPLE
  3606.  
  3607.             #include <stdio.h>
  3608.             #include <softc.h>
  3609.             #include <sc_clock.h>
  3610.  
  3611.             void main()
  3612.             {
  3613.               char month[10];
  3614.  
  3615.               sccdsmonth(month,4);
  3616.               puts(month);
  3617.             }
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.                                          47
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3635.  
  3636.  
  3637.  
  3638.             sccdsperm 
  3639.  
  3640.             USAGE
  3641.                       signed int sccdsperm(
  3642.                            signed char *days,
  3643.                            signed char *date,
  3644.                            signed int format );
  3645.  
  3646.  
  3647.             PROTOTYPE IN
  3648.                       sc_clock.h
  3649.  
  3650.  
  3651.             DESCRIPTION
  3652.                       sccdsperm calculates  the number  of "days" in the
  3653.                       month for  the year  specified in "date". The date
  3654.                       string  style   ("format")  must  be  valid.  This
  3655.                       function also  senses leap  year and will properly
  3656.                       return 29 days for February.
  3657.  
  3658.  
  3659.                       Date string styles:
  3660.                       SC_GREGOR   mm/dd/yy
  3661.                       SC_GREGORL  mm/dd/yyyy
  3662.                       SC_JULIAN   yyyy/ddd
  3663.                       SC_YMD      yyyymmdd
  3664.                       SC_DMY      ddmmyy
  3665.  
  3666.             SEE ALSO
  3667.                       sccdiperm.
  3668.  
  3669.  
  3670.  
  3671.  
  3672.             EXAMPLE
  3673.  
  3674.             #include <stdio.h>
  3675.             #include <softc.h>
  3676.             #include <sc_clock.h>
  3677.  
  3678.             void main()
  3679.             {
  3680.               signed char d;
  3681.  
  3682.               sccdsperm(&d, "19890325", SC_YMD);
  3683.               printf("%d",d);
  3684.             }
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.                                          48
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3701.  
  3702.  
  3703.  
  3704.             sccdsvalid     
  3705.  
  3706.             USAGE
  3707.                       signed int sccdsvalid(
  3708.                            signed char *string,
  3709.                            signed int format );
  3710.  
  3711.  
  3712.             PROTOTYPE IN
  3713.                       sc_clock.h
  3714.  
  3715.  
  3716.             DESCRIPTION
  3717.                       sccdsvalid tests  the date  ASCIIZ "string" passed
  3718.                       for validity:  string properly formatted (format),
  3719.                       valid day of month, and valid month of year.
  3720.  
  3721.  
  3722.                       Date string styles:
  3723.                       SC_GREGOR   mm/dd/yy
  3724.                       SC_GREGORL  mm/dd/yyyy
  3725.                       SC_JULIAN   yyyy/ddd
  3726.                       SC_YMD      yyyymmdd
  3727.                       SC_DMY      ddmmyy
  3728.  
  3729.  
  3730.  
  3731.             EXAMPLE
  3732.  
  3733.             #include <stdio.h>
  3734.             #include <softc.h>
  3735.             #include <sc_clock.h>
  3736.  
  3737.             void main()
  3738.             {
  3739.               if (sccdsvalid("19890213" SC_YMD) == SC_SUCCESS)
  3740.                 puts("Good Date.");
  3741.               else
  3742.                 puts("Bad Date.");
  3743.             }
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.                                          49
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3767.  
  3768.  
  3769.  
  3770.             sccti2s   
  3771.  
  3772.             USAGE
  3773.                       signed int sccti2s(
  3774.                            signed char *string,
  3775.                            signed int format,
  3776.                            signed int hours,
  3777.                            signed int minutes,
  3778.                            signed int seconds );
  3779.  
  3780.  
  3781.             PROTOTYPE IN
  3782.                       sc_clock.h
  3783.  
  3784.  
  3785.             DESCRIPTION
  3786.                       sccti2s  converts   three  integer   time   values
  3787.                       "hours", "minutes",  and "seconds"  into an ASCIIZ
  3788.                       string "string"  of the  string style  "format". A
  3789.                       check is  made to  verify that "string" is a valid
  3790.                       time string before exiting.
  3791.  
  3792.  
  3793.                       Time string styles:
  3794.                       SC_CSHMS    hh:mm:ss
  3795.                       SC_MIL      European/military
  3796.  
  3797.             SEE ALSO
  3798.                       scctsvalid, sccts2i.
  3799.  
  3800.  
  3801.  
  3802.  
  3803.             EXAMPLE
  3804.  
  3805.             #include <stdio.h>
  3806.             #include <softc.h>
  3807.             #include <sc_clock.h>
  3808.  
  3809.             void main()
  3810.             {
  3811.               signed char d[9];
  3812.  
  3813.               sccti2s(d,SC_GREGOR,12,3,59);
  3814.               puts(d);
  3815.             }
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.                                          50
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3833.  
  3834.  
  3835.  
  3836.             scctiget  
  3837.  
  3838.  
  3839.  
  3840.             USAGE
  3841.                       signed int scctiget(
  3842.                            signed int *hours,
  3843.                            signed int *minutes,
  3844.                            signed int *seconds,
  3845.                            signed int *fraction );
  3846.  
  3847.  
  3848.             PROTOTYPE IN
  3849.                       sc_clock.h
  3850.  
  3851.  
  3852.             DESCRIPTION
  3853.                       scctiget returns  the current  time  from  DOS  in
  3854.                       integer form:  "hours", "minutes",  "seconds", and
  3855.                       hundredths of a second ("fraction").
  3856.  
  3857.  
  3858.  
  3859.  
  3860.             EXAMPLE
  3861.  
  3862.             #include <stdio.h>
  3863.             #include <softc.h>
  3864.             #include <sc_clock.h>
  3865.  
  3866.             void main()
  3867.             {
  3868.               int hours, minutes, seconds, fraction;
  3869.  
  3870.               scctiget(&hours, &minutes, &seconds, &fraction);
  3871.               printf("%d %d %d %d\n", hours, minutes, seconds,
  3872.             fraction);
  3873.             }
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.                                          51
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3899.  
  3900.  
  3901.  
  3902.             sccts2i   
  3903.  
  3904.             USAGE
  3905.                       signed int sccts2i(
  3906.                            signed int *hours,
  3907.                            signed int *minutes,
  3908.                            signed int *seconds,
  3909.                            signed char *string,
  3910.                            signed int format );
  3911.  
  3912.  
  3913.             PROTOTYPE IN
  3914.                       sc_clock.h
  3915.  
  3916.  
  3917.             DESCRIPTION
  3918.                       sccts2i  converts  times  from  an  ASCIIZ  string
  3919.                       "string" of style "format" to three integer values
  3920.                       "hour", "minute", and "second". A partial check is
  3921.                       made to  verify that  "string"  is  a  valid  time
  3922.                       string before attempting to convert.
  3923.  
  3924.  
  3925.                       Time string styles:
  3926.                       SC_CSHMS    hh:mm:ss
  3927.                       SC_MIL      European/military
  3928.  
  3929.             SEE ALSO
  3930.                       sccti2s.
  3931.  
  3932.  
  3933.  
  3934.  
  3935.             EXAMPLE
  3936.  
  3937.             #include <stdio.h>
  3938.             #include <softc.h>
  3939.             #include <sc_clock.h>
  3940.  
  3941.             void main()
  3942.             {
  3943.               signed int h, m, s;
  3944.  
  3945.               sccts2i(&h,&m,&s,"12:03:59",SC_CSHMS);
  3946.               printf("%d %d %d",h,m,s);
  3947.             }
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.                                          52
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3965.  
  3966.  
  3967.  
  3968.             scctsdiff 
  3969.  
  3970.             USAGE
  3971.                       signed int scctsdiff(
  3972.                            signed long *diff,
  3973.                            signed char *time1,
  3974.                            signed int format1,
  3975.                            signed char *time2,
  3976.                            signed int format2 );
  3977.  
  3978.  
  3979.             PROTOTYPE IN
  3980.                       sc_clock.h
  3981.  
  3982.  
  3983.             DESCRIPTION
  3984.                       scctsdiff  returns   the  difference   in  seconds
  3985.                       between "time1"  and "time2".  The two ASCIIZ time
  3986.                       strings can  be in  any order,  but must  be valid
  3987.                       string styles ("format1", "format2").
  3988.  
  3989.  
  3990.                       Time string styles:
  3991.                       SC_CSHMS    hh:mm:ss
  3992.                       SC_MIL      European/military
  3993.  
  3994.             SEE ALSO
  3995.                       sccti2s, scctsvalid.
  3996.  
  3997.  
  3998.  
  3999.  
  4000.             EXAMPLE
  4001.  
  4002.             #include <stdio.h>
  4003.             #include <softc.h>
  4004.             #include <sc_clock.h>
  4005.  
  4006.             void main()
  4007.             {
  4008.               signed long d;
  4009.  
  4010.               scctsdiff(&d, "12:03:59", SC_CSHMS, "11:30:00", SC_CSHMS);
  4011.               printf("%ld",d);
  4012.             }
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.                                          53
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4031.  
  4032.  
  4033.  
  4034.             scctsget  
  4035.  
  4036.             USAGE
  4037.                       signed int scctsget(
  4038.                            signed char *time,
  4039.                            signed int format );
  4040.  
  4041.  
  4042.             PROTOTYPE IN
  4043.                       sc_clock.h
  4044.  
  4045.  
  4046.             DESCRIPTION
  4047.                       scctsget returns  the current  "time" from  DOS in
  4048.                       ASCIIZ string "format".
  4049.  
  4050.  
  4051.                       Time string styles:
  4052.                       SC_CSHMS    hh:mm:ss
  4053.                       SC_MIL      European/military
  4054.  
  4055.  
  4056.  
  4057.             EXAMPLE
  4058.  
  4059.             #include <stdio.h>
  4060.             #include <softc.h>
  4061.             #include <sc_clock.h>
  4062.  
  4063.             void main()
  4064.             {
  4065.               char time[10];
  4066.  
  4067.               scctsget(time,SC_MIL);
  4068.               puts(time);
  4069.             }
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.                                          54
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4097.  
  4098.  
  4099.  
  4100.             scctsvalid     
  4101.  
  4102.             USAGE
  4103.                       signed int scctsvalid(
  4104.                            signed char *string,
  4105.                            signed int format );
  4106.  
  4107.  
  4108.             PROTOTYPE IN
  4109.                       sc_clock.h
  4110.  
  4111.  
  4112.             DESCRIPTION
  4113.                       scctsvalid tests  the ASCIIZ  time string "string"
  4114.                       passed for  validity:  string  properly  formatted
  4115.                       ("format"), valid hours, minutes, and seconds.
  4116.  
  4117.  
  4118.                       Time string styles:
  4119.                       SC_CSHMS    hh:mm:ss
  4120.                       SC_MIL      European/military
  4121.  
  4122.  
  4123.  
  4124.             EXAMPLE
  4125.  
  4126.             #include <stdio.h>
  4127.             #include <softc.h>
  4128.             #include <sc_clock.h>
  4129.  
  4130.             void main()
  4131.             {
  4132.               if (scctsvalid("12:03:59",SC_CSHMS) == SC_SUCCESS)
  4133.                 puts("Good Time.");
  4134.               else
  4135.                 puts("Bad Time.");
  4136.             }
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.                                          55
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4163.  
  4164.  
  4165.  
  4166.             scdcbfrsz 
  4167.  
  4168.             USAGE
  4169.                       signed int scdcbfrsz(
  4170.                            signed int handle,
  4171.                            signed int *numpgs,
  4172.                            signed int command );
  4173.  
  4174.  
  4175.             PROTOTYPE IN
  4176.                       sc_base.h
  4177.  
  4178.  
  4179.             DESCRIPTION
  4180.                       scdcbfrsz  will   either  get  (SC_GETSZ)  or  set
  4181.                       (SC_SETSZ) the  maximum number  of index pages the
  4182.                       library  file  manager  can  keep  in  memory  and
  4183.                       returns it via "numpgs".  This is under control of
  4184.                       "command".
  4185.  
  4186.  
  4187.  
  4188.  
  4189.             EXAMPLE
  4190.  
  4191.             /* get size */
  4192.             #include <stdio.h>
  4193.             #include <softc.h>
  4194.             #include <sc_base.h>
  4195.  
  4196.             void main()
  4197.             {
  4198.               int ntx, numpgs;
  4199.  
  4200.               scdinit(20,0);
  4201.               if (scdcopenx(&ntx,"TOCNAME.NTX",SC_BUFFER) == SC_SUCCESS)
  4202.             {
  4203.                 scdcbfrsz(ntx,&numpgs,SC_GETSZ);
  4204.                 printf("Maximum number of pages = %d\n", numpgs);
  4205.                 scdcclose(ntx);
  4206.               }
  4207.               scdterm();
  4208.             }
  4209.  
  4210.             /* set size */
  4211.             #include <stdio.h>
  4212.             #include <softc.h>
  4213.             #include <sc_base.h>
  4214.  
  4215.             void main()
  4216.  
  4217.  
  4218.  
  4219.                                          56
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4229.  
  4230.  
  4231.             {
  4232.               int ntx, numpgs = 5;
  4233.  
  4234.               scdinit(20,0);
  4235.               if (scdcopenx(&ntx,"TOCNAME.NTX",SC_BUFFER) == SC_SUCCESS)
  4236.             {
  4237.                 scdcbfrsz(ntx,&numpgs,SC_SETSZ);
  4238.                 printf("New max = %d\n",numpgs);
  4239.                 scdcclose(ntx);
  4240.               }
  4241.               scdterm();
  4242.             }
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.                                          57
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4295.  
  4296.  
  4297.  
  4298.             scdcclose 
  4299.  
  4300.             USAGE
  4301.                       signed int scdcclose(
  4302.                            signed int handle );
  4303.  
  4304.  
  4305.             PROTOTYPE IN
  4306.                       sc_base.h
  4307.  
  4308.  
  4309.             DESCRIPTION
  4310.                       scdcclose closes  a Clipper  index file  and frees
  4311.                       all allocated memory associated with "handle".
  4312.  
  4313.  
  4314.  
  4315.  
  4316.             EXAMPLE
  4317.  
  4318.             #include <softc.h>
  4319.             #include <sc_base.h>
  4320.  
  4321.             void main()
  4322.             {
  4323.               int ntx;
  4324.  
  4325.               scdinit(20,0);
  4326.               if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  4327.             SC_SUCCESS)
  4328.                 scdcclose(ntx);
  4329.               scdterm();
  4330.             }
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.                                          58
  4352.  
  4353.  
  4354.  
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4361.  
  4362.  
  4363.  
  4364.             scdccreate     
  4365.  
  4366.             USAGE
  4367.                       signed int scdccreate(
  4368.                            signed char *filename,
  4369.                            signed int keytype,
  4370.                            signed char *keyexpr,
  4371.                            signed int keylen,
  4372.                            signed int decpl );
  4373.  
  4374.  
  4375.             PROTOTYPE IN
  4376.                       sc_base.h
  4377.  
  4378.  
  4379.             DESCRIPTION
  4380.                       scdccreate creates a Clipper index file. "keyexpr"
  4381.                       will be  translated to  all upper  case  when  the
  4382.                       index file is created.
  4383.  
  4384.  
  4385.                       If "keytype" is SC_CKEY, then "keyexpr" must be an
  4386.                       ASCIIZ string  consisting of  one  or  more  field
  4387.                       names from the data record. All fields included in
  4388.                       the  expression   must  be   of  type  'c'  or  be
  4389.                       translated into  type 'c'.  No check  is  made  to
  4390.                       verify this. "keylen" cannot exceed 100.
  4391.  
  4392.  
  4393.                       If "keytype"  is SC_NKEY,  then  "keyexpr"  should
  4394.                       consist of  only one  data field.  "keylen" cannot
  4395.                       exceed  19,  and  "decpl"  must  be  2  less  than
  4396.                       "keylen" and not more than 15.
  4397.  
  4398.  
  4399.                       If "keytype"  is SC_DKEY,  then  "keyexpr"  should
  4400.                       consist of  only  one  data  field.  "keylen"  and
  4401.                       "decpl" are ignored as the length is forced to 8.
  4402.  
  4403.  
  4404.                       When unique  keys are  required, OR SC_UNIQUE with
  4405.                       "keytype".
  4406.  
  4407.  
  4408.             NOTES
  4409.                       scdccreate will  create a  new index  file even if
  4410.                       one had already existed.
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.                                          59
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4427.  
  4428.  
  4429.                       "keyexpr" is  NOT checked  for validity during the
  4430.                       file  creation   process.   Currently   only   the
  4431.                       scdckmake function uses "keyexpr".
  4432.  
  4433.  
  4434.             SEE ALSO
  4435.                       scdckmake.
  4436.  
  4437.  
  4438.  
  4439.  
  4440.             EXAMPLE
  4441.  
  4442.             #include <sc_base.h>
  4443.  
  4444.             void main()
  4445.             {
  4446.               scdinit(20,0);
  4447.               scdccreate("TOCNAME.NTX", SC_DKEY, "name", 64, 0);
  4448.               scdterm();
  4449.             }
  4450.  
  4451.  
  4452.  
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.  
  4483.                                          60
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4493.  
  4494.  
  4495.  
  4496.             scdcexpr  
  4497.  
  4498.             USAGE
  4499.                       signed int scdcexpr(
  4500.                            signed int handle,
  4501.                            signed char *keyexpr );
  4502.  
  4503.  
  4504.             PROTOTYPE IN
  4505.                       sc_base.h
  4506.  
  4507.  
  4508.             DESCRIPTION
  4509.                       scdcexpr gets the index key expression and returns
  4510.                       it as an ASCIIZ string into a user supplied buffer
  4511.                       "keyexpr". The user must ensure that the buffer is
  4512.                       large enough  (the key  expression length  can  be
  4513.                       determined via  a call  to scdcinfo)  to hold  the
  4514.                       entire key expression.
  4515.  
  4516.  
  4517.             NOTES
  4518.                       A NULL  byte will  be appended  to the  end of the
  4519.                       expression string returned.
  4520.  
  4521.  
  4522.             SEE ALSO
  4523.                       scdcinfo.
  4524.  
  4525.  
  4526.  
  4527.  
  4528.             EXAMPLE
  4529.  
  4530.             #include <stdio.h>
  4531.             #include <softc.h>
  4532.             #include <sc_base.h>
  4533.  
  4534.             void main()
  4535.             {
  4536.               int ntx;
  4537.               char buffer[512];
  4538.  
  4539.               scdinit(20,0);
  4540.               if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  4541.             SC_SUCCESS) {
  4542.                 scdcexpr(ntx,buffer);
  4543.                 printf("key expression = %s",buffer);
  4544.                 scdcclose(ntx);
  4545.               }
  4546.  
  4547.  
  4548.  
  4549.                                          61
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4559.  
  4560.  
  4561.               scdterm();
  4562.             }
  4563.  
  4564.  
  4565.  
  4566.  
  4567.  
  4568.  
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.                                          62
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4625.  
  4626.  
  4627.  
  4628.             scdcflush 
  4629.  
  4630.             USAGE
  4631.                       signed int scdcflush(
  4632.                            signed int handle );
  4633.  
  4634.  
  4635.             PROTOTYPE IN
  4636.                       sc_base.h
  4637.  
  4638.  
  4639.             DESCRIPTION
  4640.                       scdcflush will write the contents of the I/O cache
  4641.                       to disk.   An  I/O cache  will be used only if the
  4642.                       index  file  was  opened  with  SC_BUFFER  command
  4643.                       switch.
  4644.  
  4645.  
  4646.             SEE ALSO
  4647.                       scdcopenx
  4648.  
  4649.  
  4650.  
  4651.  
  4652.             EXAMPLE
  4653.  
  4654.             #include <string.h>
  4655.             #include <softc.h>
  4656.             #include <sc_base.h>
  4657.  
  4658.             void main()
  4659.             {
  4660.               int dbf, ntx;
  4661.               char *key;
  4662.               long record;
  4663.  
  4664.               scdinit(20,0);
  4665.               if (scddopenx(&dbf, "TOC.DBF", SC_BUFFER) == SC_SUCCESS) {
  4666.                 if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  4667.             SC_SUCCESS) {
  4668.                   scddfput(dbf,0,"TOC.DBF");
  4669.                   scddrput(dbf,&record,SC_ADD);
  4670.                   scdckmake(dbf,ntx,&key);
  4671.                   scdckadd(ntx,key,record);
  4672.                   free(key);
  4673.                   scdcflush(ntx);
  4674.                   scdcclose(ntx);
  4675.                 }
  4676.                 scddclose(dbf);
  4677.               }
  4678.  
  4679.  
  4680.  
  4681.                                          63
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4691.  
  4692.  
  4693.               scdterm();
  4694.             }
  4695.  
  4696.  
  4697.  
  4698.  
  4699.  
  4700.  
  4701.  
  4702.  
  4703.  
  4704.  
  4705.  
  4706.  
  4707.  
  4708.  
  4709.  
  4710.  
  4711.  
  4712.  
  4713.  
  4714.  
  4715.  
  4716.  
  4717.  
  4718.  
  4719.  
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.  
  4726.  
  4727.  
  4728.  
  4729.  
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.                                          64
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4757.  
  4758.  
  4759.  
  4760.             scdcindex 
  4761.  
  4762.             USAGE
  4763.                       signed int scdcindex(
  4764.                            signed int datafile,
  4765.                            signed char *filename,
  4766.                            signed int keytype,
  4767.                            signed char *keyexpr,
  4768.                            signed int keylen,
  4769.                            signed int decpl );
  4770.  
  4771.  
  4772.             PROTOTYPE IN
  4773.                       sc_base.h
  4774.  
  4775.  
  4776.             DESCRIPTION
  4777.                       scdcindex will  create and  build a  Clipper index
  4778.                       file.     A  blank  file  will  be  created  using
  4779.                       "filename", "keytype",  "keyexpr",  "keylen",  and
  4780.                       "decpl".   The resultant  file will be opened, and
  4781.                       the "datafile"  will be read sequentially building
  4782.                       keys from  each data  record.  The index file will
  4783.                       be closed  at exit.   The  "datafile" must be open
  4784.                       prior to the function call.
  4785.  
  4786.  
  4787.             SEE ALSO
  4788.                       scdccreate
  4789.  
  4790.  
  4791.  
  4792.  
  4793.             EXAMPLE
  4794.  
  4795.             #include <softc.h>
  4796.             #include <sc_base.h>
  4797.  
  4798.             void main()
  4799.             {
  4800.               int dbf;
  4801.  
  4802.               scdinit(20,0);
  4803.               if (scddopenx(&dbf,"TOC.DBF",SC_BUFFER) == SC_SUCCESS) {
  4804.                 scdcindex(dbf, "TOCNAME.NTX", SC_CKEY, "NAME", 64, 0);
  4805.                 scddclose(dbf);
  4806.               }
  4807.               scdterm();
  4808.             }
  4809.  
  4810.  
  4811.  
  4812.  
  4813.                                          65
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4823.  
  4824.  
  4825.  
  4826.             scdcinfo  
  4827.  
  4828.             USAGE
  4829.                       signed int scdcinfo(
  4830.                            signed int handle,
  4831.                            SC_NTXINFO *info );
  4832.  
  4833.  
  4834.             PROTOTYPE IN
  4835.                       sc_base.h
  4836.  
  4837.  
  4838.             DESCRIPTION
  4839.                       scdcinfo gets  the  filename  of  the  index  file
  4840.                       associated with  "handle", the index key type, the
  4841.                       maximum index  key length  and number  of  decimal
  4842.                       places (numeric  keys) ,  and the  length  of  the
  4843.                       index key expression via the structure:
  4844.  
  4845.  
  4846.                       typedef struct {
  4847.                         signed char fname[80]; /* file name */
  4848.                         signed char keylen;    /* key length */
  4849.                         signed char keydpl;    /* decimal places */
  4850.                         signed char exprlen;   /* expression len */
  4851.                         SC_FLAGS flags;   /* misc. flags */
  4852.                       } SC_NTXINFO;
  4853.  
  4854.  
  4855.             NOTES
  4856.                       If you  are using the value returned for the index
  4857.                       expression to  dynamically allocate memory to hold
  4858.                       the key  expression, be  sure to  add one  to  the
  4859.                       length before allocation.
  4860.  
  4861.  
  4862.             SEE ALSO
  4863.                       scdcopenx.
  4864.  
  4865.  
  4866.  
  4867.  
  4868.             EXAMPLE
  4869.  
  4870.             #include <stdio.h>
  4871.             #include <softc.h>
  4872.             #include <sc_base.h>
  4873.  
  4874.             void main()
  4875.             {
  4876.  
  4877.  
  4878.  
  4879.                                          66
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4889.  
  4890.  
  4891.               int ntx;
  4892.               SC_NTXINFO info;
  4893.  
  4894.               scdinit(20,0);
  4895.               if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  4896.             SC_SUCCESS) {
  4897.                 scdcinfo(ntx,&info);
  4898.                 printf("File name = %s\n",info.fname);
  4899.                 printf("Maximum key length = %d\n",info.keylen);
  4900.                 printf("Number of decimals = %d\n,info.keydpl);
  4901.                 printf("Key expression length = %d\n",info.exprlen);
  4902.                 scdcclose(ntx);
  4903.               }
  4904.               scdterm();
  4905.             }
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.                                          67
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4955.  
  4956.  
  4957.  
  4958.             scdckadd  
  4959.  
  4960.             USAGE
  4961.                       signed int scdckadd(
  4962.                            signed int handle,
  4963.                            void *key,
  4964.                            signed long recno );
  4965.  
  4966.  
  4967.             PROTOTYPE IN
  4968.                       sc_base.h
  4969.  
  4970.  
  4971.             DESCRIPTION
  4972.                       scdckadd  will   add  "key"   to  the  index  file
  4973.                       specified by  "handle". "recno" is the data record
  4974.                       number to  be  associated  with  "key"  (the  data
  4975.                       record pointed  to by  recno must  exist prior  to
  4976.                       calling scdckadd).
  4977.  
  4978.  
  4979.             NOTES
  4980.                       When adding character keys it is not necessary  to
  4981.                       pad   the key  string to  size with  spaces (" "),
  4982.                       because the  function will  automatically do  this
  4983.                       for you.
  4984.  
  4985.  
  4986.             SEE ALSO
  4987.                       scdckmake.
  4988.  
  4989.  
  4990.  
  4991.  
  4992.             EXAMPLE
  4993.  
  4994.             #include <string.h>
  4995.             #include <softc.h>
  4996.             #include <sc_base.h>
  4997.  
  4998.             void main()
  4999.             {
  5000.               int dbf, ntx;
  5001.               char name[65] = "ABC.DEF";
  5002.               long recno;
  5003.  
  5004.               scdinit(20,0);
  5005.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  5006.                 if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  5007.             SC_SUCCESS) {
  5008.  
  5009.  
  5010.  
  5011.                                          68
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5021.  
  5022.  
  5023.                   scddfputs(dbf,0,name);
  5024.                   if (scddrput(dbf,&recno,SC_ADD) == SC_SUCCESS)
  5025.                     scdckadd(ntx,name,recno);
  5026.                   scdcclose(ntx);
  5027.                 }
  5028.                 scddclose(dbf)
  5029.               }
  5030.               scdterm();
  5031.             }
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.                                          69
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5087.  
  5088.  
  5089.  
  5090.             scdckbot  
  5091.  
  5092.             USAGE
  5093.                       signed int scdckbot(
  5094.                            signed int handle,
  5095.                            void *key,
  5096.                            signed long *recno );
  5097.  
  5098.  
  5099.             PROTOTYPE IN
  5100.                       sc_base.h
  5101.  
  5102.  
  5103.             DESCRIPTION
  5104.                       scdckbot will  set the  current key pointer to the
  5105.                       last logical  key in  the index and return the key
  5106.                       value  "key"   and  data   record  number  "recno"
  5107.                       associated with the new current key.
  5108.  
  5109.  
  5110.             NOTES
  5111.                       The user  must ensure  that  the  buffer  used  to
  5112.                       return the  key is large enough to hold the entire
  5113.                       key.  The   maximum  length  of  the  key  can  be
  5114.                       determined via a call to scdcinfo.
  5115.  
  5116.  
  5117.                       All keys are returned as strings.
  5118.  
  5119.  
  5120.             SEE ALSO
  5121.                       scdcinfo.
  5122.  
  5123.  
  5124.  
  5125.  
  5126.             EXAMPLE
  5127.  
  5128.             #include <stdio.h>
  5129.             #include <softc.h>
  5130.             #include <sc_base.h>
  5131.  
  5132.             void main()
  5133.             {
  5134.               int ntx;
  5135.               char name[65];
  5136.               long recno;
  5137.  
  5138.               scdinit(20,0);
  5139.               if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  5140.  
  5141.  
  5142.  
  5143.                                          70
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5153.  
  5154.  
  5155.             SC_SUCCESS) {
  5156.                 name[64] = 0;
  5157.                 scdckbot(ntx,name,&recno);
  5158.                 printf("%s %ld\n",name,recno);
  5159.                 scdcclose(ntx);
  5160.               }
  5161.               scdterm();
  5162.             }
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.                                          71
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5219.  
  5220.  
  5221.  
  5222.             scdckcur  
  5223.  
  5224.             USAGE
  5225.                       signed int scdckcur(
  5226.                            signed int handle,
  5227.                            void *key,
  5228.                            signed long *recno );
  5229.  
  5230.  
  5231.             PROTOTYPE IN
  5232.                       sc_base.h
  5233.  
  5234.  
  5235.             DESCRIPTION
  5236.                       scdckcur will  return the key value "key" and data
  5237.                       record number  "recno" associated with the current
  5238.                       key in the index file.
  5239.  
  5240.  
  5241.                       The current  key pointer  must be set by a call to
  5242.                       either scdckfind,  scdcktop, scdckbot,  scdcknext,
  5243.                       or scdckprev before calling scdckcur.
  5244.  
  5245.  
  5246.             NOTES
  5247.                       The user  must ensure  that  the  buffer  used  to
  5248.                       return the  key is large enough to hold the entire
  5249.                       key.  The   maximum  length  of  the  key  can  be
  5250.                       determined via a call to scdcinfo.
  5251.  
  5252.  
  5253.             SEE ALSO
  5254.                       scdcinfo, scdckfind, scdcktop, scdckbot,
  5255.                       scdcknext, scdckprev.
  5256.  
  5257.  
  5258.  
  5259.  
  5260.             EXAMPLE
  5261.  
  5262.             #include <stdio.h>
  5263.             #include <softc.h>
  5264.             #include <sc_base.h>
  5265.  
  5266.             void main()
  5267.             {
  5268.               int ntx;
  5269.               char date[17], dat[17];
  5270.               long recno, recn;
  5271.  
  5272.  
  5273.  
  5274.  
  5275.                                          72
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5285.  
  5286.  
  5287.               scdinit(20,0);
  5288.               if (scdcopenx(&ntx, "TOCDATE.NTX", SC_BUFFER) ==
  5289.             SC_SUCCESS) {
  5290.                 date[16] = 0;
  5291.                 dat[16] = 0;
  5292.                 scdcktop(ntx,date,&recn);
  5293.                 scdckcur(ntx,dat,&recno);
  5294.                 printf("%s %s %ld %ld\n",      date,dat,recno,recn);
  5295.                 scdcclose(ntx);
  5296.               }
  5297.               scdterm();
  5298.             }
  5299.  
  5300.  
  5301.  
  5302.  
  5303.  
  5304.  
  5305.  
  5306.  
  5307.  
  5308.  
  5309.  
  5310.  
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.                                          73
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5351.  
  5352.  
  5353.  
  5354.             scdckdel  
  5355.  
  5356.             USAGE
  5357.                       signed int scdckdel(
  5358.                            signed int handle,
  5359.                            void *key,
  5360.                            signed long recno );
  5361.  
  5362.  
  5363.             PROTOTYPE IN
  5364.                       sc_base.h
  5365.  
  5366.  
  5367.             DESCRIPTION
  5368.                       scdckdel will  remove "key"  from the  index  file
  5369.                       specified by  "handle". "recno" is used along with
  5370.                       "key" to  ensure that  the  proper  key  has  been
  5371.                       removed from the index file.
  5372.  
  5373.  
  5374.             NOTES
  5375.                       When deleting  keys it  is not  necessary  to  pad
  5376.                       the key  string to  size with  spaces ("  "),  the
  5377.                       function will automatically do this for you.
  5378.  
  5379.  
  5380.             SEE ALSO
  5381.                       scdckadd.
  5382.  
  5383.  
  5384.  
  5385.  
  5386.             EXAMPLE
  5387.  
  5388.             #include <string.h>
  5389.             #include <softc.h>
  5390.             #include <sc_base.h>
  5391.  
  5392.             void main()
  5393.             {
  5394.               int ntx;
  5395.               char date[17];
  5396.  
  5397.               scdinit(20,0);
  5398.               if (scdcopenx(&ntx, "TOCDATE.NTX", SC_BUFFER) ==
  5399.             SC_SUCCESS) {
  5400.                 strcpy(date,"12/05/8815:30:04");
  5401.                 scdckdel(ntx,date,7L);
  5402.                 scdcclose(ntx);
  5403.               }
  5404.  
  5405.  
  5406.  
  5407.                                          74
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5417.  
  5418.  
  5419.               scdterm();
  5420.             }
  5421.  
  5422.  
  5423.  
  5424.  
  5425.  
  5426.  
  5427.  
  5428.  
  5429.  
  5430.  
  5431.  
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439.  
  5440.  
  5441.  
  5442.  
  5443.  
  5444.  
  5445.  
  5446.  
  5447.  
  5448.  
  5449.  
  5450.  
  5451.  
  5452.  
  5453.  
  5454.  
  5455.  
  5456.  
  5457.  
  5458.  
  5459.  
  5460.  
  5461.  
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.  
  5470.  
  5471.  
  5472.  
  5473.                                          75
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5483.  
  5484.  
  5485.  
  5486.             scdckfind 
  5487.  
  5488.             USAGE
  5489.                       signed int scdckfind(
  5490.                            signed int handle,
  5491.                            void *key,
  5492.                            signed long *recno,
  5493.                            signed int method );
  5494.  
  5495.  
  5496.             PROTOTYPE IN
  5497.                       sc_base.h
  5498.  
  5499.  
  5500.             DESCRIPTION
  5501.                       scdckfind  supports   two   key   search   methods
  5502.                       (determined by "method"): SC_EXACT - find an exact
  5503.                       match with  "key" and "recno", and SC_FIRST - find
  5504.                       the first logical occurrence of "key" in the index
  5505.                       and return the associated record number "recno" if
  5506.                       found.
  5507.  
  5508.  
  5509.                       If a  match cannot  be found, the current key will
  5510.                       be  the   physical  key  which  would  immediately
  5511.                       precede "key".  The current  key's value  and data
  5512.                       record  number  will  be  returned  in  "key"  and
  5513.                       "recno".
  5514.  
  5515.  
  5516.             NOTES
  5517.                       The user  must ensure  that  the  buffer  used  to
  5518.                       return the  key is large enough to hold the entire
  5519.                       key.  The   maximum  length  of  the  key  can  be
  5520.                       determined via a call to scdcinfo.
  5521.  
  5522.  
  5523.                       When searching  it is  not necessary  to  pad  the
  5524.                       key string to size with spaces (" "), the function
  5525.                       will automatically do this for you.
  5526.  
  5527.  
  5528.                       Searching for  partial keys can be accomplished by
  5529.                       using the  SC_FIRST method.  For example,  you are
  5530.                       using a fifteen character key and you want to find
  5531.                       the first  entry where  the first  five characters
  5532.                       are "ABCDE".  All you  need do  is copy  that five
  5533.                       character ASCIIZ  string into  your key buffer and
  5534.                       then call  scdckfind. The  function will space pad
  5535.                       to length and then find the first matching entry.
  5536.  
  5537.  
  5538.  
  5539.                                          76
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5549.  
  5550.  
  5551.                       All keys are returned as strings.
  5552.  
  5553.  
  5554.             SEE ALSO
  5555.                       scdcinfo.
  5556.  
  5557.  
  5558.  
  5559.  
  5560.             EXAMPLE
  5561.  
  5562.             #include <stdio.h>
  5563.             #include <string.h>
  5564.             #include <softc.h>
  5565.             #include <sc_base.h>
  5566.  
  5567.             void main()
  5568.             {
  5569.               int ntx;
  5570.               char key[65];
  5571.               long recno;
  5572.  
  5573.               scdinit(20,0);
  5574.               if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  5575.             SC_SUCCESS) {
  5576.                 strcpy(key,"ABCDE.XYZ");
  5577.                 recno = 7L;
  5578.                 if (scdckfind(ntx,key,&recno,SC_FIRST) != SC_SUCCESS)
  5579.                   printf("%s\n",scemsg());
  5580.                 else
  5581.                   printf("%s %ld\n",key,recno);
  5582.                 scdcclose(ntx);
  5583.               }
  5584.               scdterm();
  5585.             }
  5586.  
  5587.  
  5588.  
  5589.  
  5590.  
  5591.  
  5592.  
  5593.  
  5594.  
  5595.  
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601.  
  5602.  
  5603.  
  5604.  
  5605.                                          77
  5606.  
  5607.  
  5608.  
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5615.  
  5616.  
  5617.  
  5618.             scdckmake 
  5619.  
  5620.             USAGE
  5621.                       signed int scdckmake(
  5622.                            signed int datahandle,
  5623.                            signed int indexhandle,
  5624.                            void **key );
  5625.  
  5626.  
  5627.             PROTOTYPE IN
  5628.                       sc_base.h
  5629.  
  5630.  
  5631.             DESCRIPTION
  5632.                       scdckmake will  build an  index key  using the key
  5633.                       expression  of   the  index   file  specified   by
  5634.                       "indexhandle" and  the data  found in  the  record
  5635.                       buffer of the data file "datahandle". Memory space
  5636.                       for the "key" will be allocated and the address of
  5637.                       this block will be returned.
  5638.  
  5639.  
  5640.                       The key  expression can consist of either the data
  5641.                       field name  or one  of five Clipper functions or a
  5642.                       combination thereof.  Data field  types  of  date,
  5643.                       numeric,  or   character  are   allowed.   Clipper
  5644.                       functions dtoc,  left, right,  str, and substr are
  5645.                       currently supported by scdckmake.
  5646.  
  5647.  
  5648.                       Following is  a  brief  description  of  the  five
  5649.                       expression functions:
  5650.  
  5651.  
  5652.                       dtoc will  convert data  from a  date field  to an
  5653.                       ASCIIZ string of the format "mm/dd/yy". Syntax is:
  5654.  
  5655.  
  5656.                       dtoc(field_name)
  5657.  
  5658.  
  5659.                       left will  return the  left portion of a character
  5660.                       field  as   an  ASCIIZ   string.  The   number  of
  5661.                       characters returned  is specified  after the field
  5662.                       name. Syntax is:
  5663.  
  5664.  
  5665.                       left(field_name,number)
  5666.  
  5667.  
  5668.  
  5669.  
  5670.  
  5671.                                          78
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5681.  
  5682.  
  5683.                       right will return the right portion of a character
  5684.                       field  as   an  ASCIIZ   string.  The   number  of
  5685.                       characters returned  is specified  after the field
  5686.                       name. This  is a  count from the right side of the
  5687.                       field. Syntax is:
  5688.  
  5689.  
  5690.                       right(field_name,number)
  5691.  
  5692.  
  5693.                       str will  convert a  numeric field  to  an  ASCIIZ
  5694.                       string. The  total length  of the  string and  the
  5695.                       number of  decimal places are optional parameters.
  5696.                       The default  string length is 10 and the number of
  5697.                       decimal places is 0. Syntax is:
  5698.  
  5699.  
  5700.                       str(field_name,length,decimal_places)
  5701.  
  5702.  
  5703.                       substr  will   return  the  middle  portion  of  a
  5704.                       character field.  The  starting  offset  into  the
  5705.                       field is  a  required  parameter.  The  number  of
  5706.                       characters to  be used  is an  optional  parameter
  5707.                       whose default value is the remainder of the field.
  5708.                       Syntax is:
  5709.  
  5710.  
  5711.                       substr(field_name,start,count)
  5712.  
  5713.  
  5714.                       An example of a more complex key expression:
  5715.  
  5716.  
  5717.                       right(dtoc(date),2)+left(dtoc(date,2)
  5718.  
  5719.  
  5720.                       This expression would cause scdckmake to create an
  5721.                       index key  string consisting of the year and month
  5722.                       ("yymm"). For example if date equals "2/13/89" the
  5723.                       resultant key would be "8902".
  5724.  
  5725.  
  5726.             NOTES
  5727.                       For key  expressions consisting  of only  one data
  5728.                       field scdckmake  is probably  an overkill. You can
  5729.                       easily generate  these keys yourself. scdckmake is
  5730.                       a fairly  large module  and if not needed probably
  5731.                       should not  be used.  This function  is best  used
  5732.                       when the key expression is more complex.
  5733.  
  5734.  
  5735.  
  5736.  
  5737.                                          79
  5738.  
  5739.  
  5740.  
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5747.  
  5748.  
  5749.                       Memory is  allocated for  the generated key and it
  5750.                       is the  responsibility of  the caller to free this
  5751.                       memory when finished.
  5752.  
  5753.  
  5754.             SEE ALSO
  5755.                       scdccreate.
  5756.  
  5757.  
  5758.  
  5759.  
  5760.             EXAMPLE
  5761.  
  5762.             #include <stdio.h>
  5763.             #include <softc.h>
  5764.             #include <sc_base.h>
  5765.  
  5766.             void main()
  5767.             {
  5768.               int ntx, dbf;
  5769.               char *key;
  5770.               long recno;
  5771.  
  5772.               scdinit(20,0);
  5773.               if (scddopenx(&dbf, "TOC.DBF", 0) == SC_SUCCESS) {
  5774.                 if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) ==
  5775.             SC_SUCCESS) {
  5776.                   scddfput(dbf,0,"ABCDEF.XYZ");
  5777.                   scddrput(dbf,&recno,SC_ADD);
  5778.                   scdckmake(dbf,ntx,(void **) &key);
  5779.                   printf("%s\n",key);
  5780.                   scdckadd(ntx,key,recno);
  5781.                   free(key);         /* free memory allocated for key */
  5782.                   scdcclose(ntx);
  5783.                 }
  5784.                 scddclose(dbf);
  5785.               }
  5786.               scdterm();
  5787.             }
  5788.  
  5789.  
  5790.  
  5791.  
  5792.  
  5793.  
  5794.  
  5795.  
  5796.  
  5797.  
  5798.  
  5799.  
  5800.  
  5801.  
  5802.  
  5803.                                          80
  5804.  
  5805.  
  5806.  
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5813.  
  5814.  
  5815.  
  5816.             scdcknext 
  5817.  
  5818.             USAGE
  5819.                       signed int scdcknext(
  5820.                            signed int handle,
  5821.                            void *key,
  5822.                            signed long *recno );
  5823.  
  5824.  
  5825.             PROTOTYPE IN
  5826.                       sc_base.h
  5827.  
  5828.  
  5829.             DESCRIPTION
  5830.                       scdcknext  will  increment  the  key  pointer  and
  5831.                       return the  key value "key" and data record number
  5832.                       "recno" associated with the new current key.
  5833.  
  5834.  
  5835.                       If scdcknext  is called  immediately after opening
  5836.                       the index  file the  first  logical  key  will  be
  5837.                       returned.
  5838.  
  5839.  
  5840.             NOTES
  5841.                       The user  must ensure  that  the  buffer  used  to
  5842.                       return the  key is large enough to hold the entire
  5843.                       key.  The   maximum  length  of  the  key  can  be
  5844.                       determined via a call to scdcinfo.
  5845.  
  5846.  
  5847.                       All keys are returned as strings.
  5848.  
  5849.  
  5850.             SEE ALSO
  5851.                       scdcinfo.
  5852.  
  5853.  
  5854.  
  5855.  
  5856.             EXAMPLE
  5857.  
  5858.             #include <stdio.h>
  5859.             #include <softc.h>
  5860.             #include <sc_base.h>
  5861.  
  5862.             void main()
  5863.             {
  5864.               int ntx;
  5865.               char key[11];
  5866.  
  5867.  
  5868.  
  5869.                                          81
  5870.  
  5871.  
  5872.  
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5879.  
  5880.  
  5881.               long recno;
  5882.  
  5883.               scdinit(20,0);
  5884.               if (scdcopenx(&ntx, "TOCLNGTH.NTX", SC_BUFFER) ==
  5885.             SC_SUCCESS) {
  5886.                 scdcknext(ntx,key,&recno);     /* return first key */
  5887.                 printf("%s %ld\n",key,recno);
  5888.                 scdcclose(ntx);
  5889.               }
  5890.               scdterm();
  5891.             }
  5892.  
  5893.  
  5894.  
  5895.  
  5896.  
  5897.  
  5898.  
  5899.  
  5900.  
  5901.  
  5902.  
  5903.  
  5904.  
  5905.  
  5906.  
  5907.  
  5908.  
  5909.  
  5910.  
  5911.  
  5912.  
  5913.  
  5914.  
  5915.  
  5916.  
  5917.  
  5918.  
  5919.  
  5920.  
  5921.  
  5922.  
  5923.  
  5924.  
  5925.  
  5926.  
  5927.  
  5928.  
  5929.  
  5930.  
  5931.  
  5932.  
  5933.  
  5934.  
  5935.                                          82
  5936.  
  5937.  
  5938.  
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5945.  
  5946.  
  5947.  
  5948.             scdckprev 
  5949.  
  5950.             USAGE
  5951.                       signed int scdckprev(
  5952.                            signed int handle,
  5953.                            void *key,
  5954.                            signed long *recno );
  5955.  
  5956.  
  5957.             PROTOTYPE IN
  5958.                       sc_base.h
  5959.  
  5960.  
  5961.             DESCRIPTION
  5962.                       scdckprev  will  decrement  the  key  pointer  and
  5963.                       return the  key value "key" and data record number
  5964.                       "recno" associated with the new current key.
  5965.  
  5966.  
  5967.                       If scdckprev  is called  immediately after opening
  5968.                       the index  file  the  last  logical  key  will  be
  5969.                       returned.
  5970.  
  5971.  
  5972.             NOTES
  5973.                       The user  must ensure  that  the  buffer  used  to
  5974.                       return the  key is large enough to hold the entire
  5975.                       key.  The   maximum  length  of  the  key  can  be
  5976.                       determined via a call to scdcinfo.
  5977.  
  5978.  
  5979.                       All keys are returned as strings.
  5980.  
  5981.  
  5982.             SEE ALSO
  5983.                       scdcinfo.
  5984.  
  5985.  
  5986.  
  5987.  
  5988.             EXAMPLE
  5989.  
  5990.             #include <stdio.h>
  5991.             #include <softc.h>
  5992.             #include <sc_base.h>
  5993.  
  5994.             void main()
  5995.             {
  5996.               int ntx;
  5997.               char character[65];
  5998.  
  5999.  
  6000.  
  6001.                                          83
  6002.  
  6003.  
  6004.  
  6005.  
  6006.  
  6007.  
  6008.  
  6009.  
  6010.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6011.  
  6012.  
  6013.               long recno;
  6014.  
  6015.               scdinit(20,0);
  6016.               if (scdcopenx(&ntx,"TOCNAME.NTX",SC_BUFFER) == SC_SUCCESS)
  6017.             {
  6018.                 scdckprev(ntx,character,&recno);    /* get last key */
  6019.                 printf("%s %ld\n",character,recno);
  6020.                 scdcclose(ntx);
  6021.               }
  6022.               scdterm();
  6023.             }
  6024.  
  6025.  
  6026.  
  6027.  
  6028.  
  6029.  
  6030.  
  6031.  
  6032.  
  6033.  
  6034.  
  6035.  
  6036.  
  6037.  
  6038.  
  6039.  
  6040.  
  6041.  
  6042.  
  6043.  
  6044.  
  6045.  
  6046.  
  6047.  
  6048.  
  6049.  
  6050.  
  6051.  
  6052.  
  6053.  
  6054.  
  6055.  
  6056.  
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  
  6064.  
  6065.  
  6066.  
  6067.                                          84
  6068.  
  6069.  
  6070.  
  6071.  
  6072.  
  6073.  
  6074.  
  6075.  
  6076.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6077.  
  6078.  
  6079.  
  6080.             scdcktop  
  6081.  
  6082.             USAGE
  6083.                       signed int scdcktop(
  6084.                            signed int handle,
  6085.                            void *key,
  6086.                            signed long *recno );
  6087.  
  6088.  
  6089.             PROTOTYPE IN
  6090.                       sc_base.h
  6091.  
  6092.  
  6093.             DESCRIPTION
  6094.                       scdcktop will  set the  current key pointer to the
  6095.                       first logical  key in the index and return the key
  6096.                       value  "key"   and  data   record  number  "recno"
  6097.                       associated with the new current key.
  6098.  
  6099.  
  6100.             NOTES
  6101.                       The user  must ensure  that  the  buffer  used  to
  6102.                       return the  key is large enough to hold the entire
  6103.                       key.  The   maximum  length  of  the  key  can  be
  6104.                       determined via a call to scdcinfo.
  6105.  
  6106.  
  6107.                       All keys are returned as strings.
  6108.  
  6109.  
  6110.             SEE ALSO
  6111.                       scdcinfo.
  6112.  
  6113.  
  6114.  
  6115.  
  6116.             EXAMPLE
  6117.  
  6118.             #include <stdio.h>
  6119.             #include <softc.h>
  6120.             #include <sc_base.h>
  6121.  
  6122.             void main()
  6123.             {
  6124.               int ntx;
  6125.               char date[17];
  6126.               long recno;
  6127.  
  6128.               scdinit(20,0);
  6129.               if (scdcopenx(&ntx,"TOCDATE.NTX",SC_BUFFER) == SC_SUCCESS)
  6130.  
  6131.  
  6132.  
  6133.                                          85
  6134.  
  6135.  
  6136.  
  6137.  
  6138.  
  6139.  
  6140.  
  6141.  
  6142.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6143.  
  6144.  
  6145.             {
  6146.                 date[16] = 0;
  6147.                 scdcktop(ntx,date,&recno);
  6148.                 printf("%s %ld\n",date,recno);
  6149.                 scdcclose(ntx);
  6150.               }
  6151.               scdterm();
  6152.             }
  6153.  
  6154.  
  6155.  
  6156.  
  6157.  
  6158.  
  6159.  
  6160.  
  6161.  
  6162.  
  6163.  
  6164.  
  6165.  
  6166.  
  6167.  
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.                                          86
  6200.  
  6201.  
  6202.  
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6209.  
  6210.  
  6211.  
  6212.             scdcopenx 
  6213.  
  6214.             USAGE
  6215.                       signed int scdcopenx(
  6216.                            signed int *handle,
  6217.                            signed char *filename,
  6218.                            signed int command );
  6219.  
  6220.  
  6221.             PROTOTYPE IN
  6222.                       sc_base.h
  6223.  
  6224.  
  6225.             DESCRIPTION
  6226.                       scdcopenx  opens  a  Clipper  index  file  (.NTX).
  6227.                       Memory will  be allocated  for a  file packet, I/O
  6228.                       buffers, and  other miscellaneous  structures  for
  6229.                       use internally  by the SoftC Database Library file
  6230.                       manager. The  index file will be tested as much as
  6231.                       possible to insure that it is a legitimate Clipper
  6232.                       index file.
  6233.  
  6234.  
  6235.                       A block  of memory large enough to hold at least 3
  6236.                       pages (3072  bytes) will  be allocated  during the
  6237.                       open. Three pages is the minimum number of buffers
  6238.                       required to add or delete index keys.
  6239.  
  6240.  
  6241.                       The file  will be  opened  under  control  of  the
  6242.                       "command" parameter.  Using SC_RDWR opens the file
  6243.                       for  both   read  and  write  access.    SC_RDONLY
  6244.                       overrides SC_RDWR and causes the file to be opened
  6245.                       for read  access only.   Any attempt to write to a
  6246.                       read  only   file  will   result   in   an   error
  6247.                       (SC_READOLY).
  6248.  
  6249.  
  6250.                       Using SC_EXCLUDE  opens the file for exclusive use
  6251.                       of  this   station  (single   user).     SC_SHARED
  6252.                       overrides SC_EXCLUDE  and opens the file in multi-
  6253.                       user mode.   This  mode is used when a LAN file is
  6254.                       to be shared with other stations.
  6255.  
  6256.  
  6257.                       Using SC_BUFFER  opens the  file with  I/O caching
  6258.                       enabled.   Memory for  up   to 10  pages  will  be
  6259.                       allocated during  the open.   Caching  of page I/O
  6260.                       greatly  increases   the  speed  of  file  access.
  6261.                       Typically this  mode  is  used  with  single  user
  6262.  
  6263.  
  6264.  
  6265.                                          87
  6266.  
  6267.  
  6268.  
  6269.  
  6270.  
  6271.  
  6272.  
  6273.  
  6274.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6275.  
  6276.  
  6277.                       files.   SC_FLUSH overrides  SC_BUFFER and  causes
  6278.                       the file  to be opened with no caching.  This mode
  6279.                       is generally  used with  file sharing, although it
  6280.                       is not required.
  6281.  
  6282.  
  6283.                       The index  expression will  be translated to upper
  6284.                       case after being read from the index file.
  6285.  
  6286.  
  6287.  
  6288.  
  6289.             EXAMPLE
  6290.  
  6291.             #include <softc.h>
  6292.             #include <sc_base.h>
  6293.  
  6294.             void main()
  6295.             {
  6296.               int ntx;
  6297.  
  6298.               scdinit(20,0);
  6299.               if (scdcopenx(&ntx, "UNKNOWN.NTX", SC_BUFFER) ==
  6300.             SC_SUCCESS) {
  6301.                 scdcclose(ntx);
  6302.               }
  6303.               scdterm();
  6304.             }
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.  
  6311.  
  6312.  
  6313.  
  6314.  
  6315.  
  6316.  
  6317.  
  6318.  
  6319.  
  6320.  
  6321.  
  6322.  
  6323.  
  6324.  
  6325.  
  6326.  
  6327.  
  6328.  
  6329.  
  6330.  
  6331.                                          88
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6341.  
  6342.  
  6343.  
  6344.             scddbfrsz 
  6345.  
  6346.             USAGE
  6347.                       signed int scddbfrsz(
  6348.                            signed int handle,
  6349.                            signed int *length,
  6350.                            signed int command );
  6351.  
  6352.  
  6353.             PROTOTYPE IN
  6354.                       sc_base.h
  6355.  
  6356.  
  6357.             DESCRIPTION
  6358.                       scddbfrsz   either   sets   (SC_SETSZ)   or   gets
  6359.                       (SC_GETSZ) the  I/O cache  "length"  (in  records)
  6360.                       based upon the value of "command".
  6361.  
  6362.  
  6363.                       If the  cache length  is being  set,  the  current
  6364.                       cache will be flushed to disk before the buffer is
  6365.                       reallocated.
  6366.  
  6367.  
  6368.                       An I/O  cache will  be used  only if the data file
  6369.                       was opened with SC_BUFFER in the command field.
  6370.  
  6371.  
  6372.             SEE ALSO
  6373.                       scddopenx
  6374.  
  6375.  
  6376.  
  6377.  
  6378.             EXAMPLE
  6379.  
  6380.             /* Get Size */
  6381.             #include <stdio.h>
  6382.             #include <softc.h>
  6383.             #include <sc_base.h>
  6384.  
  6385.             void main()
  6386.             {
  6387.               int dbf, length;
  6388.  
  6389.               scdinit(20,0);
  6390.               if (scddopenx(&dbf,"TOC.DBF",SC_BUFFER) == SC_SUCCESS) {
  6391.                 scddbfrsz(dbf,&length,SC_GETSZ);
  6392.                 printf("%d\n",length);
  6393.                 scddclose(dbf);
  6394.  
  6395.  
  6396.  
  6397.                                          89
  6398.  
  6399.  
  6400.  
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6407.  
  6408.  
  6409.               }
  6410.               scdterm();
  6411.             }
  6412.  
  6413.             /* Get Size */
  6414.             #include <stdio.h>
  6415.             #include <softc.h>
  6416.             #include <sc_base.h>
  6417.  
  6418.             void main()
  6419.             {
  6420.               int dbf, length = 100;
  6421.  
  6422.               scdinit(20,0);
  6423.               if (scddopenx(&dbf, "TOC.DBF", SC_BUFFER) == SC_SUCCESS) {
  6424.                 scddbfrsz(dbf,&length,SC_SETSZ);
  6425.                 printf("%d\n",length);
  6426.                 scddclose(dbf);
  6427.               }
  6428.               scdterm();
  6429.             }
  6430.  
  6431.  
  6432.  
  6433.  
  6434.  
  6435.  
  6436.  
  6437.  
  6438.  
  6439.  
  6440.  
  6441.  
  6442.  
  6443.  
  6444.  
  6445.  
  6446.  
  6447.  
  6448.  
  6449.  
  6450.  
  6451.  
  6452.  
  6453.  
  6454.  
  6455.  
  6456.  
  6457.  
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.                                          90
  6464.  
  6465.  
  6466.  
  6467.  
  6468.  
  6469.  
  6470.  
  6471.  
  6472.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6473.  
  6474.  
  6475.  
  6476.             scddbof   
  6477.  
  6478.             USAGE
  6479.                       signed int scddbof(
  6480.                            signed int handle );
  6481.  
  6482.  
  6483.             PROTOTYPE IN
  6484.                       sc_base.h
  6485.  
  6486.  
  6487.             DESCRIPTION
  6488.                       scddbof returns  an indicator as to whether or not
  6489.                       the record  pointer is positioned at the beginning
  6490.                       of the file.
  6491.  
  6492.  
  6493.             RETURN VALUES
  6494.                       SC_TRUE     at beginning of file
  6495.                       SC_FALSE    somewhere else
  6496.  
  6497.             SEE ALSO
  6498.                       scddeof, scddrnum.
  6499.  
  6500.  
  6501.  
  6502.  
  6503.             EXAMPLE
  6504.  
  6505.             #include <stdio.h>
  6506.             #include <softc.h>
  6507.             #include <sc_base.h>
  6508.  
  6509.             void main()
  6510.             {
  6511.               int dbf;
  6512.  
  6513.               scdinit(20,0);
  6514.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6515.                 if (scddbof(dbf) < SC_SUCCESS)
  6516.                   puts(scemsg());
  6517.                 else if (sc_code == SC_TRUE)
  6518.                   puts("At beginning of file");
  6519.                 else
  6520.                   puts("Somewhere else.");
  6521.                 scddclose(dbf);
  6522.               }
  6523.               scdterm();
  6524.             }
  6525.  
  6526.  
  6527.  
  6528.  
  6529.                                          91
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6539.  
  6540.  
  6541.  
  6542.             scddclose 
  6543.  
  6544.             USAGE
  6545.                       signed int scddclose(
  6546.                            signed int handle );
  6547.  
  6548.  
  6549.             PROTOTYPE IN
  6550.                       sc_base.h
  6551.  
  6552.  
  6553.             DESCRIPTION
  6554.                       scddclose  closes   a  data  file  and  frees  all
  6555.                       allocated  memory   associated  with   data   file
  6556.                       "handle". If  the data  file was modified, today's
  6557.                       date will be written into the file header.
  6558.  
  6559.  
  6560.             NOTES
  6561.                       If any locks are applied to the file, they will be
  6562.                       removed before closing.
  6563.  
  6564.  
  6565.             SEE ALSO
  6566.                       scddopenx
  6567.  
  6568.  
  6569.  
  6570.  
  6571.             EXAMPLE
  6572.  
  6573.             #include <softc.h>
  6574.             #include <sc_base.h>
  6575.  
  6576.             void main()
  6577.             {
  6578.               int dbf;
  6579.  
  6580.               scdinit(20,0);
  6581.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS)
  6582.                 scddclose(dbf);
  6583.               scdterm();
  6584.             }
  6585.  
  6586.  
  6587.  
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.                                          92
  6596.  
  6597.  
  6598.  
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6605.  
  6606.  
  6607.  
  6608.             scddcreate     
  6609.  
  6610.             USAGE
  6611.                       signed int scddcreate(
  6612.                            signed char *filename,
  6613.                            signed int numfields,
  6614.                            SC_FIELD *fields,
  6615.                            signed int style );
  6616.  
  6617.  
  6618.             PROTOTYPE IN
  6619.                       sc_base.h
  6620.  
  6621.  
  6622.             DESCRIPTION
  6623.                       scddcreate   creates   a   dBASEIII   or   dBASEIV
  6624.                       compatible data  file. A  pointer to  an array  of
  6625.                       SC_FIELD must be passed.
  6626.  
  6627.  
  6628.                       typedef struct {
  6629.                         signed char name[11];  /* field name */
  6630.                         signed char type; /* field type */
  6631.                         unsigned char len;     /* field length */
  6632.                         unsigned char decpl;   /* decimal places */
  6633.                       } SC_FIELD;
  6634.  
  6635.  
  6636.                       The field  description array  must be  initialized
  6637.                       and each  element set  to appropriate  values. The
  6638.                       array determines  the  organization  of  the  data
  6639.                       record. The  data file  does not  remain open upon
  6640.                       exit of this function.
  6641.  
  6642.  
  6643.                       This function  will create a new data file even if
  6644.                       one had already existed.
  6645.  
  6646.  
  6647.                       Field names  and types  are converted to all upper
  6648.                       case when the file is created.
  6649.  
  6650.  
  6651.                       Valid field types are:
  6652.  
  6653.  
  6654.                       'C' character (not NULL terminated in record)
  6655.                       'D' date ("yyyymmdd" format)
  6656.                       'F' floating point (valid only for dBASEIV files)
  6657.                       'L' logical (TRUE, FALSE)
  6658.  
  6659.  
  6660.  
  6661.                                          93
  6662.  
  6663.  
  6664.  
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6671.  
  6672.  
  6673.                       'M' memo (memo file record number)
  6674.                       'N' numeric.
  6675.  
  6676.                       Both 'F'  and 'N' fields are handled as doubles by
  6677.                       the library.  The library  does  not  support  BCD
  6678.                       numbers.
  6679.  
  6680.  
  6681.                       The type  of data  file created  depends upon  the
  6682.                       value of  the "style" parameter: SC_DB3 - dBASEIII
  6683.                       compatible, or SC_DB4 - dBASEIV compatible.
  6684.  
  6685.  
  6686.             RESTRICTIONS
  6687.                       The maximum record length is 4000 bytes.
  6688.  
  6689.                       The maximum number of dBASE III fields is 128, but
  6690.                       the maximum number of dBASEIV fields is 255.
  6691.  
  6692.                       The maximum length of character fields is 254, and
  6693.                       they cannot be longer than 100 if used as a key.
  6694.  
  6695.                       The maximum length of dBASE III numeric fields is
  6696.                       19, but the maximum length of dBASE IV numeric &
  6697.                       float fields is 20.
  6698.  
  6699.                       The length of a date field is forced to 8.
  6700.  
  6701.                       The length of a logical field is forced to 1.
  6702.  
  6703.                       The length of a memo field is forced to 10.
  6704.  
  6705.                       The number of decimal places will be forced to
  6706.                       zero for all types except: 1) dBASE III NUMERIC -
  6707.                       it must be less than ('len' - 2) and also less
  6708.                       than 16, and 2) dBASE IV NUMERIC and FLOAT - it
  6709.                       must be less than ('len' - 2). The number of
  6710.                       decimal places cannot be less than zero.
  6711.  
  6712.  
  6713.             SEE ALSO
  6714.                       scddcreate
  6715.  
  6716.  
  6717.  
  6718.  
  6719.             EXAMPLE
  6720.  
  6721.             #include <softc.h>
  6722.             #include <sc_base.h>
  6723.  
  6724.  
  6725.  
  6726.  
  6727.                                          94
  6728.  
  6729.  
  6730.  
  6731.  
  6732.  
  6733.  
  6734.  
  6735.  
  6736.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6737.  
  6738.  
  6739.             void main()
  6740.             {
  6741.               SC_FIELD fields[] = {
  6742.                 "name",'c',64,0,     /* file name */
  6743.                 "length",'n',10,0,   /* file size */
  6744.                 "date",'d',8,0, /* date */
  6745.                 "time",'c',8,0, /* time */
  6746.                 "attribute",'c',3,0  /* file attributes */
  6747.               };
  6748.  
  6749.               scdinit(20,0);
  6750.               scddcreate("TOC.DBF",5,fields,SC_DB3);
  6751.               scdterm();
  6752.             }
  6753.  
  6754.  
  6755.  
  6756.  
  6757.  
  6758.  
  6759.  
  6760.  
  6761.  
  6762.  
  6763.  
  6764.  
  6765.  
  6766.  
  6767.  
  6768.  
  6769.  
  6770.  
  6771.  
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.  
  6778.  
  6779.  
  6780.  
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787.  
  6788.  
  6789.  
  6790.  
  6791.  
  6792.  
  6793.                                          95
  6794.  
  6795.  
  6796.  
  6797.  
  6798.  
  6799.  
  6800.  
  6801.  
  6802.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6803.  
  6804.  
  6805.  
  6806.             scddeof   
  6807.  
  6808.             USAGE
  6809.                       signed int scddeof(
  6810.                            signed int handle );
  6811.  
  6812.  
  6813.             PROTOTYPE IN
  6814.                       sc_base.h
  6815.  
  6816.  
  6817.             DESCRIPTION
  6818.                       scddeof returns  an indicator as to whether or not
  6819.                       the record pointer is positioned at the end of the
  6820.                       file.
  6821.  
  6822.  
  6823.             RETURN VALUES
  6824.                       SC_TRUE     at end of file
  6825.                       SC_FALSE    somewhere else
  6826.  
  6827.             SEE ALSO
  6828.                       scddbof, scddrnum.
  6829.  
  6830.  
  6831.  
  6832.  
  6833.             EXAMPLE
  6834.  
  6835.             #include <sc_base.h>
  6836.  
  6837.             void main()
  6838.             {
  6839.               int dbf;
  6840.  
  6841.               scdinit(20,0);
  6842.               if (scddopenx(&dbf, "TOC.DBF", 0) == SC_SUCCESS) {
  6843.                 if (scddeof(dbf) < SC_SUCCESS)
  6844.                   puts(scemsg());
  6845.                 else if (sc_code == SC_TRUE)
  6846.                   puts("At end of file");
  6847.                 else
  6848.                   puts("Somewhere else");
  6849.                 scddclose(dbf);
  6850.               }
  6851.               scdterm();
  6852.             }
  6853.  
  6854.  
  6855.  
  6856.  
  6857.  
  6858.  
  6859.                                          96
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6869.  
  6870.  
  6871.  
  6872.             scddfget  
  6873.  
  6874.             USAGE
  6875.                       signed int scddfget(
  6876.                            signed int handle,
  6877.                            signed int fieldno,
  6878.                            void *data );
  6879.  
  6880.  
  6881.             PROTOTYPE IN
  6882.                       sc_base.h
  6883.  
  6884.  
  6885.             DESCRIPTION
  6886.                       scddfget  gets   data  from   the  desired   field
  6887.                       "fieldno" of the record I/O buffer. "data" will be
  6888.                       converted from  dBASE to  a more natural data type
  6889.                       for 'c':
  6890.  
  6891.  
  6892.                       dBASE field type   returned data type
  6893.                       'C'                signed char *
  6894.                       'D'                signed char [9]
  6895.                       'F'                double (dBASEIV)
  6896.                       'L'                signed char
  6897.                       'M'                unsigned long
  6898.                       'N'                double
  6899.  
  6900.  
  6901.                       Date and  character fields  are returned as ASCIIZ
  6902.                       strings. The  date strings will be formatted under
  6903.                       control of the global variable sc_date_style. This
  6904.                       variable will default to SC_GREGOR.
  6905.  
  6906.  
  6907.                       Data returned  by this function for memo fields is
  6908.                       the memo  file record  number NOT  the actual memo
  6909.                       text. A  call must be made to scdtrget to retrieve
  6910.                       the memo text.
  6911.  
  6912.  
  6913.                       scddfinfo can  be used  to determine the length of
  6914.                       the longest data field in the file.
  6915.  
  6916.  
  6917.             NOTES
  6918.                       Fields are numbered from zero (0).
  6919.  
  6920.  
  6921.  
  6922.  
  6923.  
  6924.  
  6925.                                          97
  6926.  
  6927.  
  6928.  
  6929.  
  6930.  
  6931.  
  6932.  
  6933.  
  6934.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6935.  
  6936.  
  6937.             SEE ALSO
  6938.                       scdtrget, scddfgets, scddfput, scddfinfo,
  6939.                       scddrget.
  6940.  
  6941.  
  6942.  
  6943.  
  6944.             EXAMPLE
  6945.  
  6946.             #include <stdio.h>
  6947.             #include <softc.h>
  6948.             #include <sc_base.h>
  6949.  
  6950.             void main()
  6951.             {
  6952.               int dbf;
  6953.               char name[65], time[9], date[9];
  6954.               double length, attribute;
  6955.  
  6956.               scdinit(20,0);
  6957.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6958.                 scddrget(dbf,1L);
  6959.                 scddfget(dbf,0,name);
  6960.                 scddfget(dbf,1,&length);
  6961.                 scddfget(dbf,2,date);
  6962.                 scddfget(dbf,3,time);
  6963.                 scddfget(dbf,4,&attribute);
  6964.                 printf("%s %lf %s %s %lf\n",
  6965.             name,length,date,time,attribute);
  6966.                 scddclose(dbf);
  6967.               }
  6968.               scdterm();
  6969.             }
  6970.  
  6971.  
  6972.  
  6973.  
  6974.  
  6975.  
  6976.  
  6977.  
  6978.  
  6979.  
  6980.  
  6981.  
  6982.  
  6983.  
  6984.  
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.                                          98
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7001.  
  7002.  
  7003.  
  7004.             scddfgets 
  7005.  
  7006.             USAGE
  7007.                       signed int scddfgets(
  7008.                            signed int handle,
  7009.                            signed int fieldno,
  7010.                            char *data );
  7011.  
  7012.  
  7013.             PROTOTYPE IN
  7014.                       sc_base.h
  7015.  
  7016.  
  7017.             DESCRIPTION
  7018.                       scddfgets  gets   data  from   the  desired  field
  7019.                       "fieldno" of the record I/O buffer. "data" will be
  7020.                       returned as an ASCIIZ string.
  7021.  
  7022.  
  7023.                       scddfinfo can  be used  to determine the length of
  7024.                       the longest data field in the file.
  7025.  
  7026.  
  7027.             NOTES
  7028.                       Date fields  are returned  in the form "yyyymmdd".
  7029.                       There is  a difference between the date formats of
  7030.                       scddfgets and scddfget.
  7031.  
  7032.  
  7033.                       Fields are numbered from zero (0).
  7034.  
  7035.  
  7036.             SEE ALSO
  7037.                       scddfget, scddfputs, scddfinfo, scddrget.
  7038.  
  7039.  
  7040.  
  7041.  
  7042.             EXAMPLE
  7043.  
  7044.             #include <stdio.h>
  7045.             #include <softc.h>
  7046.             #include <sc_base.h>
  7047.  
  7048.             void main()
  7049.             {
  7050.               int dbf;
  7051.               char name[65], time[9], date[9], length[11], attribute[4];
  7052.  
  7053.               scdinit(20,0);
  7054.  
  7055.  
  7056.  
  7057.                                          99
  7058.  
  7059.  
  7060.  
  7061.  
  7062.  
  7063.  
  7064.  
  7065.  
  7066.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7067.  
  7068.  
  7069.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7070.                 scddrget(dbf,1L);
  7071.                 scddfgets(dbf,0,name);
  7072.                 scddfgets(dbf,1,length);
  7073.                 scddfgets(dbf,2,date);
  7074.                 scddfgets(dbf,3,time);
  7075.                 scddfgets(dbf,4,attribute);
  7076.                 printf("%s %s %s %s %s\n",
  7077.             name,length,date,time,attribute);
  7078.                 scddclose(dbf);
  7079.               }
  7080.               scdterm();
  7081.             }
  7082.  
  7083.  
  7084.  
  7085.  
  7086.  
  7087.  
  7088.  
  7089.  
  7090.  
  7091.  
  7092.  
  7093.  
  7094.  
  7095.  
  7096.  
  7097.  
  7098.  
  7099.  
  7100.  
  7101.  
  7102.  
  7103.  
  7104.  
  7105.  
  7106.  
  7107.  
  7108.  
  7109.  
  7110.  
  7111.  
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.  
  7118.  
  7119.  
  7120.  
  7121.  
  7122.  
  7123.                                          100
  7124.  
  7125.  
  7126.  
  7127.  
  7128.  
  7129.  
  7130.  
  7131.  
  7132.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7133.  
  7134.  
  7135.  
  7136.             scddfinfo 
  7137.  
  7138.             USAGE
  7139.                       signed int scddfinfo(
  7140.                            signed int handle,
  7141.                            signed int *longfldlen,
  7142.                            SC_FIELD *fields );
  7143.  
  7144.  
  7145.             PROTOTYPE IN
  7146.                       sc_base.h
  7147.  
  7148.  
  7149.             DESCRIPTION
  7150.                       scddfinfo copies  the data  field descriptions  to
  7151.                       "fields" using  the structure SC_FIELD. The length
  7152.                       of  the   longest  data  field  is  also  returned
  7153.                       "longfldlen".
  7154.  
  7155.  
  7156.                       typedef struct {
  7157.                         signed char name[11];  /* field name */
  7158.                         signed char type; /* field type */
  7159.                         unsigned char len;     /* field length */
  7160.                         unsigned char decpl;   /* decimal places */
  7161.                       } SC_FIELD;
  7162.  
  7163.  
  7164.             NOTES
  7165.                       The user  must ensure  that the  array defined for
  7166.                       "fields" is  large enough to hold all of the field
  7167.                       descriptions because  scddfinfo blindly copies the
  7168.                       descriptions to  "fields". Severe  program  errors
  7169.                       can be the result if the field array is too small.
  7170.                       Use scddrinfo to determine the number of fields in
  7171.                       the data record.
  7172.  
  7173.  
  7174.             SEE ALSO
  7175.                       scddrinfo
  7176.  
  7177.  
  7178.  
  7179.  
  7180.             EXAMPLE
  7181.  
  7182.             #include <stdio.h>
  7183.             #include <softc.h>
  7184.             #include <sc_base.h>
  7185.  
  7186.  
  7187.  
  7188.  
  7189.                                          101
  7190.  
  7191.  
  7192.  
  7193.  
  7194.  
  7195.  
  7196.  
  7197.  
  7198.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7199.  
  7200.  
  7201.             void main()
  7202.             {
  7203.               int dbf, longfld, numflds, a, reclen;
  7204.               SC_FIELD fields[128];  /* dBASEIII max size */
  7205.               unsigned char *bfr;
  7206.               SC_DBFRINFO rinfo;
  7207.  
  7208.               scdinit(20,0);
  7209.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7210.                 scddrinfo(dbf,&rinfo);
  7211.                 scddfinfo(dbf,&longfld,fields);
  7212.                 printf("longest field length = %d\n",longfld);
  7213.                 for (a=0; a<rinfo.numflds; a++)
  7214.                   printf("%s %c %d %d\n", fields[a].name,
  7215.             fields[a].type,
  7216.                       fields[a].len, fields[a].decpl);
  7217.                 scddclose(dbf);
  7218.               }
  7219.               scdterm();
  7220.             }
  7221.  
  7222.  
  7223.  
  7224.  
  7225.  
  7226.  
  7227.  
  7228.  
  7229.  
  7230.  
  7231.  
  7232.  
  7233.  
  7234.  
  7235.  
  7236.  
  7237.  
  7238.  
  7239.  
  7240.  
  7241.  
  7242.  
  7243.  
  7244.  
  7245.  
  7246.  
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.                                          102
  7256.  
  7257.  
  7258.  
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7265.  
  7266.  
  7267.  
  7268.             scddflush 
  7269.  
  7270.             USAGE
  7271.                       signed int scddflush(
  7272.                            signed int handle );
  7273.  
  7274.  
  7275.             PROTOTYPE IN
  7276.                       sc_base.h
  7277.  
  7278.  
  7279.             DESCRIPTION
  7280.                       scddflush will write the contents of the I/O cache
  7281.                       to disk.   An  I/O cache  will be used only if the
  7282.                       data file was opened with SC_BUFFER in the command
  7283.                       switch.
  7284.  
  7285.  
  7286.             SEE ALSO
  7287.                       scddopenx
  7288.  
  7289.  
  7290.  
  7291.  
  7292.             EXAMPLE
  7293.  
  7294.             #include <softc.h>
  7295.             #include <sc_base.h>
  7296.  
  7297.             void main()
  7298.             {
  7299.               int dbf;
  7300.               long record;
  7301.  
  7302.               scdinit(20,0);
  7303.               if (scddopenx(&dbf,"TOC.DBF",SC_BUFFER) == SC_SUCCESS) {
  7304.                 .
  7305.                 .
  7306.                 .
  7307.                 scddrput(dbf,&record,SC_ADD);
  7308.                 scddflush(dbf);
  7309.                 .
  7310.                 .
  7311.                 .
  7312.                 scddclose(dbf);
  7313.               }
  7314.               scdterm();
  7315.             }
  7316.  
  7317.  
  7318.  
  7319.  
  7320.  
  7321.                                          103
  7322.  
  7323.  
  7324.  
  7325.  
  7326.  
  7327.  
  7328.  
  7329.  
  7330.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7331.  
  7332.  
  7333.  
  7334.             scddfnam2no    
  7335.  
  7336.             USAGE
  7337.                       signed int scddfnam2no(
  7338.                            signed int handle,
  7339.                            signed int *fieldno,
  7340.                            signed char *fieldname );
  7341.  
  7342.  
  7343.             PROTOTYPE IN
  7344.                       sc_base.h
  7345.  
  7346.  
  7347.             DESCRIPTION
  7348.                       scddfnam2no searches through the field description
  7349.                       array  for   data  file   "handle"   looking   for
  7350.                       "fieldname".  It  will  return  the  corresponding
  7351.                       field number.
  7352.  
  7353.  
  7354.             NOTES
  7355.                       Data files  created by  the SoftC Database Library
  7356.                       will have  field names  and types  changed to  all
  7357.                       upper case.
  7358.  
  7359.  
  7360.  
  7361.  
  7362.             EXAMPLE
  7363.  
  7364.             #include <stdio.h>
  7365.             #include <softc.h>
  7366.             #include <sc_base.h>
  7367.  
  7368.             void main()
  7369.             {
  7370.               int dbf, fldno
  7371.  
  7372.               scdinit(20,0);
  7373.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7374.                 scddfnam2no(dbf,&fldno,"ATTRIBUTE");
  7375.                 printf("%d",fldno);
  7376.                 scddclose(dbf);
  7377.               }
  7378.               scdterm();
  7379.             }
  7380.  
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.  
  7387.                                          104
  7388.  
  7389.  
  7390.  
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7397.  
  7398.  
  7399.  
  7400.             scddfput  
  7401.  
  7402.             USAGE
  7403.                       signed int scddfput(
  7404.                            signed int handle,
  7405.                            signed int fieldno,
  7406.                            void *data );
  7407.  
  7408.  
  7409.             PROTOTYPE IN
  7410.                       sc_base.h
  7411.  
  7412.  
  7413.             DESCRIPTION
  7414.                       scddfput will  convert "data"  from 'c'  format to
  7415.                       dBASE format  and place  it in  the  proper  field
  7416.                       "fieldno" of the record I/O buffer.
  7417.  
  7418.  
  7419.                       dBASE field type   returned data type
  7420.                       'C'                signed char *
  7421.                       'D'                signed char [9]
  7422.                       'F'                double (dBASE IV)
  7423.                       'L'                signed char
  7424.                       'M'                unsigned long
  7425.                       'N'                double
  7426.  
  7427.  
  7428.             NOTES
  7429.                       Fields are numbered from zero (0).
  7430.  
  7431.  
  7432.                       scddfput uses the global variable sc_date_style to
  7433.                       control date  string formatting. The initial value
  7434.                       of this variable is SC_GREGOR.
  7435.  
  7436.  
  7437.             SEE ALSO
  7438.                       scddfget, scddfputs.
  7439.  
  7440.  
  7441.  
  7442.  
  7443.             EXAMPLE
  7444.  
  7445.             #include <stdio.h>
  7446.             #include <softc.h>
  7447.             #include <sc_base.h>
  7448.  
  7449.             void main()
  7450.  
  7451.  
  7452.  
  7453.                                          105
  7454.  
  7455.  
  7456.  
  7457.  
  7458.  
  7459.  
  7460.  
  7461.  
  7462.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7463.  
  7464.  
  7465.             {
  7466.               int dbf;
  7467.               double length = 1200.0L, attribute = 1.0L;
  7468.               long recno;
  7469.  
  7470.               scdinit(20,0);
  7471.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7472.                 scddfput(dbf,0,"ABC.XYZ");
  7473.                 scddfput(dbf,1,&length);
  7474.                 scddfput(dbf,2,"07/21/90");
  7475.                 scddfput(dbf,3,"20:01:45");
  7476.                 scddfput(dbf,4,&attribute);
  7477.                 scddrput(dbf,&recno,SC_ADD);
  7478.                 scddclose(dbf);
  7479.               }
  7480.               scdterm();
  7481.             }
  7482.  
  7483.  
  7484.  
  7485.  
  7486.  
  7487.  
  7488.  
  7489.  
  7490.  
  7491.  
  7492.  
  7493.  
  7494.  
  7495.  
  7496.  
  7497.  
  7498.  
  7499.  
  7500.  
  7501.  
  7502.  
  7503.  
  7504.  
  7505.  
  7506.  
  7507.  
  7508.  
  7509.  
  7510.  
  7511.  
  7512.  
  7513.  
  7514.  
  7515.  
  7516.  
  7517.  
  7518.  
  7519.                                          106
  7520.  
  7521.  
  7522.  
  7523.  
  7524.  
  7525.  
  7526.  
  7527.  
  7528.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7529.  
  7530.  
  7531.  
  7532.             scddfputs 
  7533.  
  7534.             USAGE
  7535.                       signed int scddfputs(
  7536.                            signed int handle,
  7537.                            signed int fieldno,
  7538.                            char *data );
  7539.  
  7540.  
  7541.             PROTOTYPE IN
  7542.                       sc_base.h
  7543.  
  7544.  
  7545.             DESCRIPTION
  7546.                       scddfputs will  place "data"  in the  proper field
  7547.                       "fieldno" of  the record  I/O buffer.  It  is  the
  7548.                       user's responsibility  to provide a properly sized
  7549.                       and formatted ASCIIZ string to scddfputs.
  7550.  
  7551.  
  7552.             NOTES
  7553.                       Fields are numbered from zero (0).
  7554.  
  7555.  
  7556.                       scddfputs follows  the date formatting conventions
  7557.                       of  scddfgets.   Also  be   aware  that  the  date
  7558.                       formatting conventions  of  scddfget/scddfput  are
  7559.                       not the same as scddfgets/scddfputs.
  7560.  
  7561.  
  7562.             SEE ALSO
  7563.                       scddfgets, scddfput.
  7564.  
  7565.  
  7566.  
  7567.  
  7568.             EXAMPLE
  7569.  
  7570.             #include <stdio.h>
  7571.             #include <softc.h>
  7572.             #include <sc_base.h>
  7573.  
  7574.             void main()
  7575.             {
  7576.               int dbf;
  7577.               long recno;
  7578.  
  7579.               scdinit(20,0);
  7580.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7581.                 scddfputs(dbf,0,"ABC.XYZ");
  7582.  
  7583.  
  7584.  
  7585.                                          107
  7586.  
  7587.  
  7588.  
  7589.  
  7590.  
  7591.  
  7592.  
  7593.  
  7594.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7595.  
  7596.  
  7597.                 scddfputs(dbf,1,"    1234.0");
  7598.                 scddfputs(dbf,2,"19900721");
  7599.                 scddfputs(dbf,3,"20:01:45");
  7600.                 scddfputs(dbf,4,"  1");
  7601.                 scddrput(dbf,&recno,SC_ADD);
  7602.                 scddclose(dbf);
  7603.               }
  7604.               scdterm();
  7605.             }
  7606.  
  7607.  
  7608.  
  7609.  
  7610.  
  7611.  
  7612.  
  7613.  
  7614.  
  7615.  
  7616.  
  7617.  
  7618.  
  7619.  
  7620.  
  7621.  
  7622.  
  7623.  
  7624.  
  7625.  
  7626.  
  7627.  
  7628.  
  7629.  
  7630.  
  7631.  
  7632.  
  7633.  
  7634.  
  7635.  
  7636.  
  7637.  
  7638.  
  7639.  
  7640.  
  7641.  
  7642.  
  7643.  
  7644.  
  7645.  
  7646.  
  7647.  
  7648.  
  7649.  
  7650.  
  7651.                                          108
  7652.  
  7653.  
  7654.  
  7655.  
  7656.  
  7657.  
  7658.  
  7659.  
  7660.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7661.  
  7662.  
  7663.  
  7664.             scddinfo  
  7665.  
  7666.             USAGE
  7667.                       signed int scddinfo(
  7668.                            signed int handle,
  7669.                            SC_DBFINFO *info );
  7670.  
  7671.  
  7672.             PROTOTYPE IN
  7673.                       sc_base.h
  7674.  
  7675.  
  7676.             DESCRIPTION
  7677.                       scddinfo returns  an information structure for the
  7678.                       file associated with "handle".
  7679.  
  7680.  
  7681.                       typedef struct {
  7682.                         signed char fname[80]; /* file name */
  7683.                         signed char style;     /* file type */
  7684.                                        /* (dBASE 3 or 4) */
  7685.                         signed char memo; /* memo file used */
  7686.                         signed char mdx;  /* MDX file used */
  7687.                         signed char trans;     /* transaction */
  7688.                                        /* in progress */
  7689.                         signed char encrypt;   /* data encrypted */
  7690.                         signed char lockt;     /* lock status */
  7691.                         unsigned long ladrs;   /* address of lock */
  7692.                         unsigned long lsize;   /* locked length */
  7693.                         SC_FLAGS flags;   /* misc. flags */
  7694.                       } SC_DBFINFO;
  7695.  
  7696.  
  7697.             SEE ALSO
  7698.                       scddopenx
  7699.  
  7700.  
  7701.  
  7702.  
  7703.             EXAMPLE
  7704.  
  7705.             #include <stdio.h>
  7706.             #include <softc.h>
  7707.             #include <sc_base.h>
  7708.  
  7709.             void main()
  7710.             {
  7711.               int dbf;
  7712.               SC_DBFINFO info;
  7713.  
  7714.  
  7715.  
  7716.  
  7717.                                          109
  7718.  
  7719.  
  7720.  
  7721.  
  7722.  
  7723.  
  7724.  
  7725.  
  7726.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7727.  
  7728.  
  7729.               scdinit(20,0);
  7730.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7731.                 scddinfo(dbf,&info);
  7732.                 puts(info.fname);
  7733.                 if (info.style == SC_DB3)
  7734.                   puts("dBASE III data file");
  7735.                 else {
  7736.                   puts("dBASE IV data file");
  7737.                   if (info.memo)
  7738.                     puts("memo file attached");
  7739.                   else
  7740.                     puts("no memo file attached");
  7741.                   if (info.mdx)
  7742.                     puts(".MDX file used")
  7743.                   else
  7744.                     puts("No .MDX file used");
  7745.                   if (info.trans)
  7746.                     puts("Transaction in progress");
  7747.                   if (info.encrypt)
  7748.                     puts("File encrypted");
  7749.                 }
  7750.                 scddclose(dbf);
  7751.               }
  7752.               scdterm();
  7753.             }
  7754.  
  7755.  
  7756.  
  7757.  
  7758.  
  7759.  
  7760.  
  7761.  
  7762.  
  7763.  
  7764.  
  7765.  
  7766.  
  7767.  
  7768.  
  7769.  
  7770.  
  7771.  
  7772.  
  7773.  
  7774.  
  7775.  
  7776.  
  7777.  
  7778.  
  7779.  
  7780.  
  7781.  
  7782.  
  7783.                                          110
  7784.  
  7785.  
  7786.  
  7787.  
  7788.  
  7789.  
  7790.  
  7791.  
  7792.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7793.  
  7794.  
  7795.  
  7796.             scddlock  
  7797.  
  7798.             USAGE
  7799.                       signed int scddlock(
  7800.                            signed int handle );
  7801.  
  7802.  
  7803.             PROTOTYPE IN
  7804.                       sc_base.h
  7805.  
  7806.  
  7807.             DESCRIPTION
  7808.                       scddlock  will  lock  the  entire  data  file  for
  7809.                       exclusive use  by this  station.    This  function
  7810.                       should be used immediately prior to adding records
  7811.                       to the  data file,  or writing to the index and/or
  7812.                       memo  files.     A   call  to   scddunlock  should
  7813.                       immediately follow  the write  so that  others may
  7814.                       again access the data, memo, and index files.
  7815.  
  7816.  
  7817.                       File sharing  is enabled  by opening the data file
  7818.                       with  SC_SHARED   in  the  command  switch.    Any
  7819.                       associated index  and memo  files should  also  be
  7820.                       opened with SC_SHARED in the command switch.
  7821.  
  7822.  
  7823.             SEE ALSO
  7824.                       scddopenx, scddrlock,scddunlock.
  7825.  
  7826.  
  7827.  
  7828.  
  7829.             EXAMPLE
  7830.  
  7831.             #include <softc.h>
  7832.             #include <sc_base.h>
  7833.  
  7834.             void main()
  7835.             {
  7836.               int dbf;
  7837.               long record;
  7838.               double length = 1305, attribute = 1;
  7839.  
  7840.               scdinit(20,0);
  7841.               if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) == SC_SUCCESS) {
  7842.                 scddfput(dbf,0,"MNO.XYZ");
  7843.                 scddfput(dbf,1,&length);
  7844.                 scddfput(dbf,2,"07/22/90");
  7845.                 scddfput(dbf,3,"20:10:45");
  7846.  
  7847.  
  7848.  
  7849.                                          111
  7850.  
  7851.  
  7852.  
  7853.  
  7854.  
  7855.  
  7856.  
  7857.  
  7858.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7859.  
  7860.  
  7861.                 scddfput(dbf,4,&attribute);
  7862.                 scddlock(dbf);
  7863.                 scddrput(dbf,&record,SC_ADD);
  7864.                 scddunlock(dbf);
  7865.                 scddclose(dbf);
  7866.               }
  7867.               scdterm();
  7868.             }
  7869.  
  7870.  
  7871.  
  7872.  
  7873.  
  7874.  
  7875.  
  7876.  
  7877.  
  7878.  
  7879.  
  7880.  
  7881.  
  7882.  
  7883.  
  7884.  
  7885.  
  7886.  
  7887.  
  7888.  
  7889.  
  7890.  
  7891.  
  7892.  
  7893.  
  7894.  
  7895.  
  7896.  
  7897.  
  7898.  
  7899.  
  7900.  
  7901.  
  7902.  
  7903.  
  7904.  
  7905.  
  7906.  
  7907.  
  7908.  
  7909.  
  7910.  
  7911.  
  7912.  
  7913.  
  7914.  
  7915.                                          112
  7916.  
  7917.  
  7918.  
  7919.  
  7920.  
  7921.  
  7922.  
  7923.  
  7924.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7925.  
  7926.  
  7927.  
  7928.             scddlud   
  7929.  
  7930.             USAGE
  7931.                       signed int scddlud(
  7932.                            signed int handle,
  7933.                            signed char *datestr,
  7934.                            signed int format );
  7935.  
  7936.  
  7937.             PROTOTYPE IN
  7938.                       sc_base.h
  7939.  
  7940.  
  7941.             DESCRIPTION
  7942.                       scddlud returns the ASCIIZ date string ("datestr")
  7943.                       of when the last update to the data file was made.
  7944.                       The date  string will  be  under  control  of  the
  7945.                       "format" command.  This date will be updated after
  7946.                       the data file has been closed.
  7947.  
  7948.  
  7949.                       Date string styles:
  7950.                       SC_GREGOR   mm/dd/yy
  7951.                       SC_GREGORL  mm/dd/yyyy
  7952.                       SC_JULIAN   yyyy/ddd
  7953.                       SC_YMD      yyyymmdd
  7954.                       SC_DMY      ddmmyy
  7955.  
  7956.  
  7957.  
  7958.             EXAMPLE
  7959.  
  7960.             #include <stdio.h>
  7961.             #include <softc.h>
  7962.             #include <sc_base.h>
  7963.  
  7964.             void main()
  7965.             {
  7966.               int dbf;
  7967.               char date[9];
  7968.  
  7969.               scdinit(20,0);
  7970.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7971.                 scddlud(dbf,&date,SC_YMD);
  7972.                 puts(date);
  7973.                 scddclose(dbf);
  7974.               }
  7975.               scdterm();
  7976.             }
  7977.  
  7978.  
  7979.  
  7980.  
  7981.                                          113
  7982.  
  7983.  
  7984.  
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7991.  
  7992.  
  7993.  
  7994.             scddopenx 
  7995.  
  7996.             USAGE
  7997.                       signed int scddopenx(
  7998.                            signed int *handle,
  7999.                            signed char *filename,
  8000.                            signed int command );
  8001.  
  8002.  
  8003.             PROTOTYPE IN
  8004.                       sc_base.h
  8005.  
  8006.  
  8007.             DESCRIPTION
  8008.                       scddopenx opens  a data  file.    Memory  will  be
  8009.                       allocated for  a file  packet and  I/O buffers for
  8010.                       use internally  by the SoftC Database Library file
  8011.                       manager.   The data file will be tested as much as
  8012.                       possible to  insure that  it is a legitimate dBASE
  8013.                       data file.
  8014.  
  8015.  
  8016.                       The file  will be  opened  under  control  of  the
  8017.                       "command" parameter.  Using SC_RDWR opens the file
  8018.                       for  both   read  and  write  access.    SC_RDONLY
  8019.                       overrides SC_RDWR and causes the file to be opened
  8020.                       for read  access only.   Any attempt to write to a
  8021.                       read  only   file  will   result   in   an   error
  8022.                       (SC_READOLY).
  8023.  
  8024.  
  8025.                       Using SC_EXCLUDE  opens the file for exclusive use
  8026.                       of  this   station  (single   user).     SC_SHARED
  8027.                       overrides SC_EXCLUDE  and opens the file in multi-
  8028.                       user mode.   This  mode is used when a LAN file is
  8029.                       to be shared with other stations.
  8030.  
  8031.  
  8032.                       Using SC_BUFFER  opens the  file with  I/O caching
  8033.                       enabled.   A buffer  of at  least 512 bytes but no
  8034.                       more than 16384 will be allocated during the open.
  8035.                       Caching of  record I/O greatly increases the speed
  8036.                       of sequential file access.  Typically this mode is
  8037.                       used with  single user  files.  SC_FLUSH overrides
  8038.                       SC_BUFFER and causes the file to be opened with no
  8039.                       caching.   This mode  is generally  used with file
  8040.                       sharing, although it is not required.
  8041.  
  8042.  
  8043.  
  8044.  
  8045.  
  8046.  
  8047.                                          114
  8048.  
  8049.  
  8050.  
  8051.  
  8052.  
  8053.  
  8054.  
  8055.  
  8056.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8057.  
  8058.  
  8059.             NOTES
  8060.                       All field  names and types, and the file name will
  8061.                       be converted to upper case after the file has been
  8062.                       opened.
  8063.  
  8064.  
  8065.             SEE ALSO
  8066.                       scddopenx
  8067.  
  8068.  
  8069.  
  8070.  
  8071.             EXAMPLE
  8072.  
  8073.             #include <softc.h>
  8074.             #include <sc_base.h>
  8075.  
  8076.             void main()
  8077.             {
  8078.               int dbf;
  8079.  
  8080.               scdinit(20,0);
  8081.                scddopenx(&dbf, "TOC.DBF", SC_SHARED|SC_FLUSH|SC_RDWR);
  8082.               scdterm();
  8083.             }
  8084.  
  8085.  
  8086.  
  8087.  
  8088.  
  8089.  
  8090.  
  8091.  
  8092.  
  8093.  
  8094.  
  8095.  
  8096.  
  8097.  
  8098.  
  8099.  
  8100.  
  8101.  
  8102.  
  8103.  
  8104.  
  8105.  
  8106.  
  8107.  
  8108.  
  8109.  
  8110.  
  8111.  
  8112.  
  8113.                                          115
  8114.  
  8115.  
  8116.  
  8117.  
  8118.  
  8119.  
  8120.  
  8121.  
  8122.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8123.  
  8124.  
  8125.  
  8126.             scddpack  
  8127.  
  8128.             USAGE
  8129.                       signed int scddpack(
  8130.                            signed int *handle );
  8131.  
  8132.  
  8133.             PROTOTYPE IN
  8134.                       sc_base.h
  8135.  
  8136.  
  8137.             DESCRIPTION
  8138.                       scddpack will  remove all  data file records which
  8139.                       have been  flagged as  deleted (SC_NOTUSED).   The
  8140.                       data file  will be  compressed so  that all active
  8141.                       records will  be contiguous after the pack.  Files
  8142.                       opened with  the read only flag (SC_RDONLY) cannot
  8143.                       be packed.
  8144.  
  8145.  
  8146.             SEE ALSO
  8147.                       scddopenx,scdnindex,scdtpack
  8148.  
  8149.  
  8150.  
  8151.  
  8152.             EXAMPLE
  8153.  
  8154.             #include <softc.h>
  8155.             #include <sc_base.h>
  8156.  
  8157.             void main()
  8158.             {
  8159.               int dbf;
  8160.  
  8161.               scdinit(20,0);
  8162.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8163.                 scddpack(dbf);
  8164.                 scddclose(dbf);
  8165.               }
  8166.               scdterm();
  8167.             }
  8168.  
  8169.  
  8170.  
  8171.  
  8172.  
  8173.  
  8174.  
  8175.  
  8176.  
  8177.  
  8178.  
  8179.                                          116
  8180.  
  8181.  
  8182.  
  8183.  
  8184.  
  8185.  
  8186.  
  8187.  
  8188.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8189.  
  8190.  
  8191.  
  8192.             scddrclear     
  8193.  
  8194.             USAGE
  8195.                       signed int scddrclear(
  8196.                            signed int handle );
  8197.  
  8198.  
  8199.             PROTOTYPE IN
  8200.                       sc_base.h
  8201.  
  8202.  
  8203.             DESCRIPTION
  8204.                       scddrclear clears  the record  buffer. The  buffer
  8205.                       will be written with spaces (" ") NOT zeros (0).
  8206.  
  8207.  
  8208.  
  8209.  
  8210.             EXAMPLE
  8211.  
  8212.             #include <stdio.h>
  8213.             #include <softc.h>
  8214.             #include <sc_base.h>
  8215.  
  8216.             void main()
  8217.             {
  8218.               int dbf;
  8219.               char name[65];
  8220.  
  8221.               scdinit(20,0);
  8222.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8223.                 scddfput(dbf,0,"Now is the time for all...");
  8224.                 scddrclear(dbf);
  8225.                 scddfget(dbf,0,name);
  8226.                 puts(name);
  8227.               }
  8228.               scdterm();
  8229.             }
  8230.  
  8231.  
  8232.  
  8233.  
  8234.  
  8235.  
  8236.  
  8237.  
  8238.  
  8239.  
  8240.  
  8241.  
  8242.  
  8243.  
  8244.  
  8245.                                          117
  8246.  
  8247.  
  8248.  
  8249.  
  8250.  
  8251.  
  8252.  
  8253.  
  8254.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8255.  
  8256.  
  8257.  
  8258.             scddrdel  
  8259.  
  8260.             USAGE
  8261.                       signed int scddrdel(
  8262.                            signed int handle,
  8263.                            signed long recno );
  8264.  
  8265.  
  8266.             PROTOTYPE IN
  8267.                       sc_base.h
  8268.  
  8269.  
  8270.             DESCRIPTION
  8271.                       scddrdel will  flag a  record specified by "recno"
  8272.                       as 'deleted'. To maintain compatibility with dBASE
  8273.                       the data  record cannot  be reused,  but it can be
  8274.                       recovered by scddrundel.
  8275.  
  8276.  
  8277.             SEE ALSO
  8278.                       scddrundel.
  8279.  
  8280.  
  8281.  
  8282.  
  8283.             EXAMPLE
  8284.  
  8285.             #include <stdio.h>
  8286.             #include <softc.h>
  8287.             #include <sc_base.h>
  8288.  
  8289.             void main()
  8290.             {
  8291.               int dbf;
  8292.  
  8293.               scdinit(20,0);
  8294.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8295.                 scddrdel(dbf,1L);
  8296.                 scddrget(dbf,1L);
  8297.                 puts(scemsg()); /* WARNING - record read is marked
  8298.             deleted */
  8299.                 scddclose(dbf);
  8300.               }
  8301.               scdterm();
  8302.             }
  8303.  
  8304.  
  8305.  
  8306.  
  8307.  
  8308.  
  8309.  
  8310.  
  8311.                                          118
  8312.  
  8313.  
  8314.  
  8315.  
  8316.  
  8317.  
  8318.  
  8319.  
  8320.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8321.  
  8322.  
  8323.  
  8324.             scddrget  
  8325.  
  8326.             USAGE
  8327.                       signed int scddrget(
  8328.                            signed int handle,
  8329.                            signed long recno );
  8330.  
  8331.  
  8332.             PROTOTYPE IN
  8333.                       sc_base.h
  8334.  
  8335.  
  8336.             DESCRIPTION
  8337.                       scddrget will  read the  data record  specified by
  8338.                       "recno"  from   the  data   file  associated  with
  8339.                       "handle" into the internal record buffer.
  8340.  
  8341.  
  8342.             SEE ALSO
  8343.                       scddfget, scddfput, scddrput.
  8344.  
  8345.  
  8346.  
  8347.  
  8348.             EXAMPLE
  8349.  
  8350.             #include <stdio.h>
  8351.             #include <softc.h>
  8352.             #include <sc_base.h>
  8353.  
  8354.             void main()
  8355.             {
  8356.               int dbf;
  8357.               char name[65], time[9], date[9];
  8358.               double length, attribute;
  8359.  
  8360.               scdinit(20,0);
  8361.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8362.                 scddrget(dbf,1L);
  8363.                 scddfget(dbf,0,name);
  8364.                 scddfget(dbf,1,&length);
  8365.                 scddfget(dbf,2,date);
  8366.                 scddfget(dbf,3,time);
  8367.                 scddfget(dbf,4,&attribute);
  8368.                 printf("%s %lf %s %s %lf\n",
  8369.             name,length,date,time,attribute);
  8370.                 scddclose(dbf);
  8371.               }
  8372.               scdterm();
  8373.             }
  8374.  
  8375.  
  8376.  
  8377.                                          119
  8378.  
  8379.  
  8380.  
  8381.  
  8382.  
  8383.  
  8384.  
  8385.  
  8386.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8387.  
  8388.  
  8389.  
  8390.             scddrinfo 
  8391.  
  8392.             USAGE
  8393.                       signed int scddrinfo(
  8394.                            signed int handle,
  8395.                            SC_DBFRINFO *rinfo );
  8396.  
  8397.  
  8398.             PROTOTYPE IN
  8399.                       sc_base.h
  8400.  
  8401.  
  8402.             DESCRIPTION
  8403.                       scddrinfo gets  the data record length, the number
  8404.                       of data  fields per record, and the address of the
  8405.                       record buffer.
  8406.  
  8407.  
  8408.                       typedef struct {
  8409.                         signed int reclen;     /* record length */
  8410.                         signed int numflds;    /* number of */
  8411.                                        /* fields */
  8412.                         unsigned char *bfr;    /* buffer address */
  8413.                       } SC_DBFRINFO;
  8414.  
  8415.  
  8416.             EXAMPLE
  8417.  
  8418.             #include <stdio.h>
  8419.             #include <softc.h>
  8420.             #include <sc_base.h>
  8421.  
  8422.             void main()
  8423.             {
  8424.               int dbf;
  8425.               SC_DBFRINFO rinfo;
  8426.  
  8427.               scdinit(20,0);
  8428.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8429.                 scddrinfo(dbf,&rinfo);
  8430.                 printf("Record length = %d\n",rinfo.reclen);
  8431.                 printf("Number of fields = %d\n",rinfo.numflds);
  8432.                 printf("Record buffer = %p\n",rinfo.bfr);
  8433.                 scddclose(dbf);
  8434.               }
  8435.               scdterm();
  8436.             }
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.                                          120
  8444.  
  8445.  
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8453.  
  8454.  
  8455.  
  8456.             scddrlock 
  8457.  
  8458.             USAGE
  8459.                       signed int scddrlock(
  8460.                            signed int handle,
  8461.                            signed long record );
  8462.  
  8463.  
  8464.             PROTOTYPE IN
  8465.                       sc_base.h
  8466.  
  8467.  
  8468.             DESCRIPTION
  8469.                       scddrlock will  lock the specified "record" in the
  8470.                       data file for exclusive use by this station.  This
  8471.                       function  should  be  used  immediately  prior  to
  8472.                       updating a data file record.  A call to scddunlock
  8473.                       should immediately follow the write so that others
  8474.                       may again access the data record.
  8475.  
  8476.  
  8477.                       File sharing  is enabled  by opening the data file
  8478.                       with SC_SHARED in the command switch.
  8479.  
  8480.  
  8481.             SEE ALSO
  8482.                       scddopenx, scddlock,scddunlock.
  8483.  
  8484.  
  8485.  
  8486.  
  8487.             EXAMPLE
  8488.  
  8489.             #include <stdio.h>
  8490.             #include <softc.h>
  8491.             #include <sc_base.h>
  8492.  
  8493.             void main()
  8494.             {
  8495.               int dbf;
  8496.               long record = 1L;
  8497.               double length = 1936, attribute = 1;
  8498.  
  8499.               scdinit(20,0);
  8500.               if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) == SC_SUCCESS) {
  8501.                 scddfput(dbf,0,"MNO.XYZ");
  8502.                 scddfput(dbf,1,&length);
  8503.                 scddfput(dbf,2,"07/22/90");
  8504.                 scddfput(dbf,3,"20:10:45");
  8505.                 scddfput(dbf,4,&attribute);
  8506.  
  8507.  
  8508.  
  8509.                                          121
  8510.  
  8511.  
  8512.  
  8513.  
  8514.  
  8515.  
  8516.  
  8517.  
  8518.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8519.  
  8520.  
  8521.                 scdnkmake(dbf,ndx,&key);
  8522.                 scdrlock(dbf,record);
  8523.                 scddrput(dbf,&record,SC_UPDATE);
  8524.                 scddunlock(dbf);
  8525.                 free(key);
  8526.                 scddclose(dbf);
  8527.               }
  8528.               scdterm();
  8529.             }
  8530.  
  8531.  
  8532.  
  8533.  
  8534.  
  8535.  
  8536.  
  8537.  
  8538.  
  8539.  
  8540.  
  8541.  
  8542.  
  8543.  
  8544.  
  8545.  
  8546.  
  8547.  
  8548.  
  8549.  
  8550.  
  8551.  
  8552.  
  8553.  
  8554.  
  8555.  
  8556.  
  8557.  
  8558.  
  8559.  
  8560.  
  8561.  
  8562.  
  8563.  
  8564.  
  8565.  
  8566.  
  8567.  
  8568.  
  8569.  
  8570.  
  8571.  
  8572.  
  8573.  
  8574.  
  8575.                                          122
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8585.  
  8586.  
  8587.  
  8588.             scddrnum  
  8589.  
  8590.             USAGE
  8591.                       signed int scddrnum(
  8592.                            signed int handle,
  8593.                            signed long *position );
  8594.  
  8595.  
  8596.             PROTOTYPE IN
  8597.                       sc_base.h
  8598.  
  8599.  
  8600.             DESCRIPTION
  8601.                       scddrnum  returns  the  current  position  (record
  8602.                       number) in the data file.
  8603.  
  8604.  
  8605.             SEE ALSO
  8606.                       scddbof, scddeof.
  8607.  
  8608.  
  8609.  
  8610.  
  8611.             EXAMPLE
  8612.  
  8613.             #include <stdio.h>
  8614.             #include <softc.h>
  8615.             #include <sc_base.h>
  8616.  
  8617.             void main()
  8618.             {
  8619.               int dbf;
  8620.               long position;
  8621.  
  8622.               scdinit(20,0);
  8623.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8624.                 scddrget(dbf,4L);
  8625.                 scddrnum(dbf,&position);
  8626.                 printf("%ld\n",position);
  8627.                 scddclose(dbf);
  8628.               }
  8629.               scdterm();
  8630.             }
  8631.  
  8632.  
  8633.  
  8634.  
  8635.  
  8636.  
  8637.  
  8638.  
  8639.  
  8640.  
  8641.                                          123
  8642.  
  8643.  
  8644.  
  8645.  
  8646.  
  8647.  
  8648.  
  8649.  
  8650.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8651.  
  8652.  
  8653.  
  8654.             scddrput  
  8655.  
  8656.             USAGE
  8657.                       signed int scddrput(
  8658.                            signed int handle,
  8659.                            signed long *recno,
  8660.                            signed int howto );
  8661.  
  8662.  
  8663.             PROTOTYPE IN
  8664.                       sc_base.h
  8665.  
  8666.  
  8667.             DESCRIPTION
  8668.                       scddrput will  write the  data record specified by
  8669.                       "recno" to  the data file associated with "handle"
  8670.                       from   the   internal   record   buffer.   "howto"
  8671.                       determines how the data record is to be written:
  8672.  
  8673.  
  8674.                       "howto" =      action
  8675.                       SC_ADD         append to end of file
  8676.                       SC_UPDATE      update current record
  8677.  
  8678.  
  8679.                       If a  record update  is occurring  the data record
  8680.                       number passed  in "recno"  will be  written in the
  8681.                       disk file.
  8682.  
  8683.  
  8684.                       Use scddrget/scddrcopy  to load  a data  record or
  8685.                       scddfput or  scddfputs to  fill  the  data  record
  8686.                       field by field.
  8687.  
  8688.  
  8689.             SEE ALSO
  8690.                       scddfput, scddfputs, scddrget.
  8691.  
  8692.  
  8693.  
  8694.  
  8695.             EXAMPLE
  8696.  
  8697.             #include <stdio.h>
  8698.             #include <softc.h>
  8699.             #include <sc_base.h>
  8700.  
  8701.             void main()
  8702.             {
  8703.               int dbf;
  8704.  
  8705.  
  8706.  
  8707.                                          124
  8708.  
  8709.  
  8710.  
  8711.  
  8712.  
  8713.  
  8714.  
  8715.  
  8716.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8717.  
  8718.  
  8719.               double length = 1200.0L, attribute = 1.0L;
  8720.               long recno;
  8721.  
  8722.               scdinit(20,0);
  8723.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8724.                 scddfput(dbf,0,"ABC.XYZ");
  8725.                 scddfput(dbf,1,&length);
  8726.                 scddfput(dbf,2,"07/21/90");
  8727.                 scddfput(dbf,3,"20:01:45");
  8728.                 scddfput(dbf,4,&attribute);
  8729.                 scddrput(dbf,&recno,SC_ADD);
  8730.                 scddclose(dbf);
  8731.               }
  8732.               scdterm();
  8733.             }
  8734.  
  8735.  
  8736.  
  8737.  
  8738.  
  8739.  
  8740.  
  8741.  
  8742.  
  8743.  
  8744.  
  8745.  
  8746.  
  8747.  
  8748.  
  8749.  
  8750.  
  8751.  
  8752.  
  8753.  
  8754.  
  8755.  
  8756.  
  8757.  
  8758.  
  8759.  
  8760.  
  8761.  
  8762.  
  8763.  
  8764.  
  8765.  
  8766.  
  8767.  
  8768.  
  8769.  
  8770.  
  8771.  
  8772.  
  8773.                                          125
  8774.  
  8775.  
  8776.  
  8777.  
  8778.  
  8779.  
  8780.  
  8781.  
  8782.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8783.  
  8784.  
  8785.  
  8786.             scddrstat 
  8787.  
  8788.             USAGE
  8789.                       signed int scddrstat(
  8790.                            signed int handle );
  8791.  
  8792.  
  8793.             PROTOTYPE IN
  8794.                       sc_base.h
  8795.  
  8796.  
  8797.             DESCRIPTION
  8798.                       scddrstat returns  an indicator  as to  whether or
  8799.                       not  the   current  record  loaded  is  active  or
  8800.                       inactive (flagged as deleted).
  8801.  
  8802.  
  8803.             RETURN VALUES
  8804.                       SC_DELREC   record inactive
  8805.                       SC_SUCCESS  active record
  8806.  
  8807.             SEE ALSO
  8808.                       scddrget
  8809.  
  8810.  
  8811.  
  8812.  
  8813.             EXAMPLE
  8814.  
  8815.             #include <stdio.h>
  8816.             #include <softc.h>
  8817.             #include <sc_base.h>
  8818.  
  8819.             void main()
  8820.             {
  8821.               int dbf;
  8822.  
  8823.               scdinit(20,0);
  8824.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8825.                 scddrget(dbf,1L);
  8826.                 if (scddrstat(dbf) == SC_DELREC)
  8827.                   puts("Record is inactive.");
  8828.                 else
  8829.                   puts("Record is active.");
  8830.                 scddclose(dbf);
  8831.               }
  8832.               scdterm();
  8833.             }
  8834.  
  8835.  
  8836.  
  8837.  
  8838.  
  8839.                                          126
  8840.  
  8841.  
  8842.  
  8843.  
  8844.  
  8845.  
  8846.  
  8847.  
  8848.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8849.  
  8850.  
  8851.  
  8852.             scddrundel     
  8853.  
  8854.             USAGE
  8855.                       signed int scddrundel(
  8856.                            signed int handle,
  8857.                            signed long recno );
  8858.  
  8859.  
  8860.             PROTOTYPE IN
  8861.                       sc_base.h
  8862.  
  8863.  
  8864.             DESCRIPTION
  8865.                       scddrundel will remove the 'deleted' flag from the
  8866.                       data record specified by "recno".
  8867.  
  8868.  
  8869.             SEE ALSO
  8870.                       scddrdel.
  8871.  
  8872.  
  8873.  
  8874.  
  8875.             EXAMPLE
  8876.  
  8877.             #include <stdio.h>
  8878.             #include <softc.h>
  8879.             #include <sc_base.h>
  8880.  
  8881.             void main()
  8882.             {
  8883.               int dbf;
  8884.  
  8885.               scdinit(20,0);
  8886.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8887.                 scddrundel(dbf,1L);
  8888.                 scddrget(dbf,1L);
  8889.                 puts(scemsg());
  8890.                 scddclose(dbf);
  8891.               }
  8892.               scdterm();
  8893.             }
  8894.  
  8895.  
  8896.  
  8897.  
  8898.  
  8899.  
  8900.  
  8901.  
  8902.  
  8903.  
  8904.  
  8905.                                          127
  8906.  
  8907.  
  8908.  
  8909.  
  8910.  
  8911.  
  8912.  
  8913.  
  8914.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8915.  
  8916.  
  8917.  
  8918.             scddsize  
  8919.  
  8920.             USAGE
  8921.                       signed int scddsize(
  8922.                            signed int handle,
  8923.                            signed long *recsused );
  8924.  
  8925.  
  8926.             PROTOTYPE IN
  8927.                       sc_base.h
  8928.  
  8929.  
  8930.             DESCRIPTION
  8931.                       scddsize gets  the number of records "recsused" in
  8932.                       the  data  file.  This  number  will  include  all
  8933.                       records inactive as well as active records.
  8934.  
  8935.  
  8936.  
  8937.  
  8938.             EXAMPLE
  8939.  
  8940.             #include <stdio.h>
  8941.             #include <softc.h>
  8942.             #include <sc_base.h>
  8943.  
  8944.             void main()
  8945.             {
  8946.               int dbf;
  8947.               long recsused;
  8948.  
  8949.               scdinit(20,0);
  8950.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  8951.                 scddsize(dbf,&recsused);
  8952.                 printf("%ld",recsused);
  8953.                 scddclose(dbf);
  8954.               }
  8955.               scdterm();
  8956.             }
  8957.  
  8958.  
  8959.  
  8960.  
  8961.  
  8962.  
  8963.  
  8964.  
  8965.  
  8966.  
  8967.  
  8968.  
  8969.  
  8970.  
  8971.                                          128
  8972.  
  8973.  
  8974.  
  8975.  
  8976.  
  8977.  
  8978.  
  8979.  
  8980.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8981.  
  8982.  
  8983.  
  8984.             scddunlock     
  8985.  
  8986.             USAGE
  8987.                       signed int scddunlock(
  8988.                            signed int handle );
  8989.  
  8990.  
  8991.             PROTOTYPE IN
  8992.                       sc_base.h
  8993.  
  8994.  
  8995.             DESCRIPTION
  8996.                       scddunlock will  unlock the  data file/record  for
  8997.                       shared use  by  other  stations.    This  function
  8998.                       should be  used immediately  after writing  to all
  8999.                       required data, index and memo files.
  9000.  
  9001.  
  9002.                       File sharing  is enabled  by opening the data file
  9003.                       with  SC_SHARED   in  the  command  switch.    Any
  9004.                       associated index  and memo  files should  also  be
  9005.                       opened with SC_SHARED in the command switch.
  9006.  
  9007.  
  9008.             SEE ALSO
  9009.                       scddopenx, scddlock,scddrlock.
  9010.  
  9011.  
  9012.  
  9013.  
  9014.             EXAMPLE
  9015.  
  9016.             #include <stdio.h>
  9017.             #include <softc.h>
  9018.             #include <sc_base.h>
  9019.  
  9020.             void main()
  9021.             {
  9022.               int dbf, ndx;
  9023.               char *key;
  9024.               long record;
  9025.               double length = 2367, attribute = 1;
  9026.  
  9027.               scdinit(20,0);
  9028.               if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) == SC_SUCCESS) {
  9029.                 if (scdnopenx(&ndx,"TOCNAME.NDX",SC_SHARED) ==
  9030.             SC_SUCCESS) {
  9031.                   scddfput(dbf,0,"ABC.XYZ");
  9032.                   scddfput(dbf,1,&length);
  9033.                   scddfput(dbf,2,"07/21/90");
  9034.  
  9035.  
  9036.  
  9037.                                          129
  9038.  
  9039.  
  9040.  
  9041.  
  9042.  
  9043.  
  9044.  
  9045.  
  9046.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9047.  
  9048.  
  9049.                   scddfput(dbf,3,"20:01:45");
  9050.                   scddfput(dbf,4,&attribute);
  9051.                   scdnkmake(dbf,ndx,&key);
  9052.                   scddlock(dbf);
  9053.                   scddrput(dbf,&record,SC_ADD);
  9054.                   scdnkadd(ndx,key,record);
  9055.                   scddunlock(dbf);
  9056.                   free(key);
  9057.                   scdnclose(ndx);
  9058.                 }
  9059.                 scddclose(dbf);
  9060.               }
  9061.               scdterm();
  9062.             }
  9063.  
  9064.  
  9065.  
  9066.  
  9067.  
  9068.  
  9069.  
  9070.  
  9071.  
  9072.  
  9073.  
  9074.  
  9075.  
  9076.  
  9077.  
  9078.  
  9079.  
  9080.  
  9081.  
  9082.  
  9083.  
  9084.  
  9085.  
  9086.  
  9087.  
  9088.  
  9089.  
  9090.  
  9091.  
  9092.  
  9093.  
  9094.  
  9095.  
  9096.  
  9097.  
  9098.  
  9099.  
  9100.  
  9101.  
  9102.  
  9103.                                          130
  9104.  
  9105.  
  9106.  
  9107.  
  9108.  
  9109.  
  9110.  
  9111.  
  9112.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9113.  
  9114.  
  9115.  
  9116.             scdibfrsz 
  9117.  
  9118.             USAGE
  9119.                       signed int scdibfrsz(
  9120.                            signed int handle,
  9121.                            signed int *numpgs,
  9122.                            signed int command );
  9123.  
  9124.  
  9125.             PROTOTYPE IN
  9126.                       sc_base.h
  9127.  
  9128.  
  9129.             DESCRIPTION
  9130.                       scdibfrsz  will   either  get  (SC_GETSZ)  or  set
  9131.                       (SC_SETSZ) the  maximum number  of index pages the
  9132.                       library  file  manager  can  keep  in  memory  and
  9133.                       returns it via "numpgs".  This is under control of
  9134.                       "command".
  9135.  
  9136.  
  9137.  
  9138.  
  9139.             EXAMPLE
  9140.  
  9141.             /* Get Size */
  9142.             #include <stdio.h>
  9143.             #include <softc.h>
  9144.             #include <sc_base.h>
  9145.  
  9146.             void main()
  9147.             {
  9148.               int idx, numpgs;
  9149.  
  9150.               scdinit(20,0);
  9151.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  9152.             SC_SUCCESS) {
  9153.                 scdibfrsz(idx,&numpgs,SC_GETSZ) == SC_SUCCESS)
  9154.                 printf("Maximum number of pages = %d\n",numpgs);
  9155.                 scdiclose(idx);
  9156.               }
  9157.               scdterm();
  9158.             }
  9159.  
  9160.             /* Set Size */
  9161.             #include <stdio.h>
  9162.             #include <softc.h>
  9163.             #include <sc_base.h>
  9164.  
  9165.             void main()
  9166.  
  9167.  
  9168.  
  9169.                                          131
  9170.  
  9171.  
  9172.  
  9173.  
  9174.  
  9175.  
  9176.  
  9177.  
  9178.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9179.  
  9180.  
  9181.             {
  9182.               char idx, numpgs = 5;
  9183.  
  9184.               scdinit(20,0);
  9185.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  9186.             SC_SUCCESS) {
  9187.                 scdibfrsz(idx,&numpgs,SC_SETSZ);
  9188.                 printf("New max = %d\n",numpgs);
  9189.                 scdiclose(idx);
  9190.               }
  9191.               scdterm();
  9192.             }
  9193.  
  9194.  
  9195.  
  9196.  
  9197.  
  9198.  
  9199.  
  9200.  
  9201.  
  9202.  
  9203.  
  9204.  
  9205.  
  9206.  
  9207.  
  9208.  
  9209.  
  9210.  
  9211.  
  9212.  
  9213.  
  9214.  
  9215.  
  9216.  
  9217.  
  9218.  
  9219.  
  9220.  
  9221.  
  9222.  
  9223.  
  9224.  
  9225.  
  9226.  
  9227.  
  9228.  
  9229.  
  9230.  
  9231.  
  9232.  
  9233.  
  9234.  
  9235.                                          132
  9236.  
  9237.  
  9238.  
  9239.  
  9240.  
  9241.  
  9242.  
  9243.  
  9244.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9245.  
  9246.  
  9247.  
  9248.             scdiclose 
  9249.  
  9250.             USAGE
  9251.                       signed int scdiclose(
  9252.                            signed int handle );
  9253.  
  9254.  
  9255.             PROTOTYPE IN
  9256.                       sc_base.h
  9257.  
  9258.  
  9259.             DESCRIPTION
  9260.                       scdiclose closes  an  index  file  and  frees  all
  9261.                       allocated memory  associated with  the index  file
  9262.                       specified by "handle".
  9263.  
  9264.  
  9265.  
  9266.  
  9267.             EXAMPLE
  9268.  
  9269.             #include <stdio.h>
  9270.             #include <softc.h>
  9271.             #include <sc_base.h>
  9272.  
  9273.             void main()
  9274.             {
  9275.               int idx;
  9276.  
  9277.               scdinit(20,0);
  9278.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  9279.             SC_SUCCESS)
  9280.                 scdiclose(idx);
  9281.               scdterm();
  9282.             }
  9283.  
  9284.  
  9285.  
  9286.  
  9287.  
  9288.  
  9289.  
  9290.  
  9291.  
  9292.  
  9293.  
  9294.  
  9295.  
  9296.  
  9297.  
  9298.  
  9299.  
  9300.  
  9301.                                          133
  9302.  
  9303.  
  9304.  
  9305.  
  9306.  
  9307.  
  9308.  
  9309.  
  9310.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9311.  
  9312.  
  9313.  
  9314.             scdicreate     
  9315.  
  9316.             USAGE
  9317.                       signed int scdicreate(
  9318.                            signed char *filename,
  9319.                            signed int keytype,
  9320.                            signed char *keyexpr,
  9321.                            signed int keylen );
  9322.  
  9323.  
  9324.             PROTOTYPE IN
  9325.                       sc_base.h
  9326.  
  9327.  
  9328.             DESCRIPTION
  9329.                       scdicreate creates  an index  file. "keyexpr" will
  9330.                       be translated  to all  upper case  when the  index
  9331.                       file is created.
  9332.  
  9333.  
  9334.                       If "keytype" is SC_CKEY, then "keyexpr" must be an
  9335.                       ASCIIZ string  consisting of  one  or  more  field
  9336.                       names from the data record. All fields included in
  9337.                       the  expression   must  be   of  type  'c'  or  be
  9338.                       translated into  type 'c'.  No check  is  made  to
  9339.                       verify this.  "keyexpr" cannot  be longer that 220
  9340.                       characters. "keylen" cannot exceed 100.
  9341.  
  9342.  
  9343.                       If "keytype" is SC_DKEY or SC_NKEY, then "keyexpr"
  9344.                       should consist  of only  one data  field. "keylen"
  9345.                       will automatically  be set  to 8 (numeric and date
  9346.                       keys are stored as modified doubles).
  9347.  
  9348.  
  9349.                       If "keytype"  is SC_LKEY,  then  "keyexpr"  should
  9350.                       consist of  only one  data  field.  "keylen"  will
  9351.                       automatically be set to 1 (logical keys are stored
  9352.                       as characters).
  9353.  
  9354.  
  9355.                       When unique  keys are  required, OR SC_UNIQUE with
  9356.                       "keytype".
  9357.  
  9358.  
  9359.             NOTES
  9360.                       scdicreate will  create a  new index  file even if
  9361.                       one had already existed.
  9362.  
  9363.  
  9364.  
  9365.  
  9366.  
  9367.                                          134
  9368.  
  9369.  
  9370.  
  9371.  
  9372.  
  9373.  
  9374.  
  9375.  
  9376.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9377.  
  9378.  
  9379.                       "keyexpr" is  NOT checked  for validity during the
  9380.                       file  creation   process.   Currently   only   the
  9381.                       scdikmake function uses "keyexpr".
  9382.  
  9383.  
  9384.             SEE ALSO
  9385.                       scdikmake.
  9386.  
  9387.  
  9388.  
  9389.  
  9390.             EXAMPLE
  9391.  
  9392.             #include <sc_base.h>
  9393.  
  9394.             void main()
  9395.             {
  9396.               scdinit(20,0);
  9397.               scdicreate("TOCDATE.IDX",SC_CKEY,"dtoc(date) + time",16);
  9398.               scdterm();
  9399.             }
  9400.  
  9401.  
  9402.  
  9403.  
  9404.  
  9405.  
  9406.  
  9407.  
  9408.  
  9409.  
  9410.  
  9411.  
  9412.  
  9413.  
  9414.  
  9415.  
  9416.  
  9417.  
  9418.  
  9419.  
  9420.  
  9421.  
  9422.  
  9423.  
  9424.  
  9425.  
  9426.  
  9427.  
  9428.  
  9429.  
  9430.  
  9431.  
  9432.  
  9433.                                          135
  9434.  
  9435.  
  9436.  
  9437.  
  9438.  
  9439.  
  9440.  
  9441.  
  9442.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9443.  
  9444.  
  9445.  
  9446.             scdiexpr  
  9447.  
  9448.             USAGE
  9449.                       signed int scdiexpr(
  9450.                            signed int handle,
  9451.                            signed char *keyexpr );
  9452.  
  9453.  
  9454.             PROTOTYPE IN
  9455.                       sc_base.h
  9456.  
  9457.  
  9458.             DESCRIPTION
  9459.                       scdiexpr gets the index key expression and returns
  9460.                       it as an ASCIIZ string into a user supplied buffer
  9461.                       "keyexpr". The user must ensure that the buffer is
  9462.                       large enough  (the key  expression length  can  be
  9463.                       determined via  a call  to scdiinfo)  to hold  the
  9464.                       entire key expression.
  9465.  
  9466.  
  9467.             NOTES
  9468.                       A NULL  byte will  be appended  to the  end of the
  9469.                       expression string returned. If you are dynamically
  9470.                       allocating memory be sure to make the buffer large
  9471.                       enough.
  9472.  
  9473.  
  9474.             SEE ALSO
  9475.                       scdiinfo.
  9476.  
  9477.  
  9478.  
  9479.  
  9480.             EXAMPLE
  9481.  
  9482.             #include <stdio.h>
  9483.             #include <softc.h>
  9484.             #include <sc_base.h>
  9485.  
  9486.             void main()
  9487.             {
  9488.               int idx;
  9489.               char buffer[512];
  9490.  
  9491.               scdinit(20,0);
  9492.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  9493.             SC_SUCCESS) {
  9494.                 scdiexpr(idx,buffer);
  9495.                 printf("key expression = %s",buffer);
  9496.  
  9497.  
  9498.  
  9499.                                          136
  9500.  
  9501.  
  9502.  
  9503.  
  9504.  
  9505.  
  9506.  
  9507.  
  9508.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9509.  
  9510.  
  9511.                 scdiclose(idx);
  9512.               }
  9513.               scdterm();
  9514.             }
  9515.  
  9516.  
  9517.  
  9518.  
  9519.  
  9520.  
  9521.  
  9522.  
  9523.  
  9524.  
  9525.  
  9526.  
  9527.  
  9528.  
  9529.  
  9530.  
  9531.  
  9532.  
  9533.  
  9534.  
  9535.  
  9536.  
  9537.  
  9538.  
  9539.  
  9540.  
  9541.  
  9542.  
  9543.  
  9544.  
  9545.  
  9546.  
  9547.  
  9548.  
  9549.  
  9550.  
  9551.  
  9552.  
  9553.  
  9554.  
  9555.  
  9556.  
  9557.  
  9558.  
  9559.  
  9560.  
  9561.  
  9562.  
  9563.  
  9564.  
  9565.                                          137
  9566.  
  9567.  
  9568.  
  9569.  
  9570.  
  9571.  
  9572.  
  9573.  
  9574.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9575.  
  9576.  
  9577.  
  9578.             scdiflush 
  9579.  
  9580.             USAGE
  9581.                       signed int scdiflush(
  9582.                            signed int handle );
  9583.  
  9584.  
  9585.             PROTOTYPE IN
  9586.                       sc_base.h
  9587.  
  9588.  
  9589.             DESCRIPTION
  9590.                       scdiflush will  write the  contents  of  the  page
  9591.                       cache to  disk.  A page cache will be used only if
  9592.                       the index  file was  opened with  SC_BUFFER in the
  9593.                       command field.
  9594.  
  9595.  
  9596.             SEE ALSO
  9597.                       scdiopenx
  9598.  
  9599.  
  9600.  
  9601.  
  9602.             EXAMPLE
  9603.  
  9604.             #include <string.h>
  9605.             #include <softc.h>
  9606.             #include <sc_base.h>
  9607.  
  9608.             void main()
  9609.             {
  9610.               int dbf, idx;
  9611.               char *key, name[65];
  9612.               long record;
  9613.  
  9614.               scdinit(20,0);
  9615.               if (scddopenx(&dbf, "TOC.DBF", SC_BUFFER) == SC_SUCCESS) {
  9616.                 if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  9617.             SC_SUCCESS) {
  9618.                   strcpy(name,"TOC.DBF");
  9619.                   scddfput(dbf,0,name);
  9620.                   scddrput(dbf,&record,SC_ADD);
  9621.                   scdikmake(dbf,idx,&key);
  9622.                   scdikadd(idx,key,record);
  9623.                   free(key);
  9624.                   scdiflush(idx);
  9625.                   scdiclose(idx);
  9626.                 }
  9627.                 scddclose(dbf);
  9628.  
  9629.  
  9630.  
  9631.                                          138
  9632.  
  9633.  
  9634.  
  9635.  
  9636.  
  9637.  
  9638.  
  9639.  
  9640.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9641.  
  9642.  
  9643.               }
  9644.               scdterm();
  9645.             }
  9646.  
  9647.  
  9648.  
  9649.  
  9650.  
  9651.  
  9652.  
  9653.  
  9654.  
  9655.  
  9656.  
  9657.  
  9658.  
  9659.  
  9660.  
  9661.  
  9662.  
  9663.  
  9664.  
  9665.  
  9666.  
  9667.  
  9668.  
  9669.  
  9670.  
  9671.  
  9672.  
  9673.  
  9674.  
  9675.  
  9676.  
  9677.  
  9678.  
  9679.  
  9680.  
  9681.  
  9682.  
  9683.  
  9684.  
  9685.  
  9686.  
  9687.  
  9688.  
  9689.  
  9690.  
  9691.  
  9692.  
  9693.  
  9694.  
  9695.  
  9696.  
  9697.                                          139
  9698.  
  9699.  
  9700.  
  9701.  
  9702.  
  9703.  
  9704.  
  9705.  
  9706.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9707.  
  9708.  
  9709.  
  9710.             scdiindex 
  9711.  
  9712.             USAGE
  9713.                       signed int scdiindex(
  9714.                            signed int datafile,
  9715.                            signed char filename,
  9716.                            signed char keytype,
  9717.                            signed char keyexpr,
  9718.                            signed int keylen );
  9719.  
  9720.  
  9721.             PROTOTYPE IN
  9722.                       sc_base.h
  9723.  
  9724.  
  9725.             DESCRIPTION
  9726.                       scdiindex will  create and  build a FoxBASE+ index
  9727.                       file.  A   blank  file   will  be   created  using
  9728.                       "filename", "keytype",  "keyexpr",  and  "keylen".
  9729.                       The  resultant   file  will  be  opened,  and  the
  9730.                       "datafile" will be read sequentially building keys
  9731.                       from each  data record.   The  index file  will be
  9732.                       closed at exit.  The "datafile" must be open prior
  9733.                       to the function call.
  9734.  
  9735.  
  9736.  
  9737.  
  9738.             EXAMPLE
  9739.  
  9740.             #include <softc.h>
  9741.             #include <sc_base.h>
  9742.  
  9743.             void main()
  9744.             {
  9745.               int dbf;
  9746.  
  9747.               scdinit(20,0);
  9748.               if (scddopenx(&dbf, "TOC.DBF", SC_BUFFER) == SC_SUCCESS) {
  9749.                 scdiindex(dbf, "TOCNAME.IDX", SC_CKEY, "NAME", 64);
  9750.                 scddclose(dbf);
  9751.               }
  9752.               scdterm();
  9753.             }
  9754.  
  9755.  
  9756.  
  9757.  
  9758.  
  9759.  
  9760.  
  9761.  
  9762.  
  9763.                                          140
  9764.  
  9765.  
  9766.  
  9767.  
  9768.  
  9769.  
  9770.  
  9771.  
  9772.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9773.  
  9774.  
  9775.  
  9776.             scdiinfo  
  9777.  
  9778.             USAGE
  9779.                       signed int scdiinfo(
  9780.                            signed int handle,
  9781.                            SC_IDXINFO *info );
  9782.  
  9783.  
  9784.             PROTOTYPE IN
  9785.                       sc_base.h
  9786.  
  9787.  
  9788.             DESCRIPTION
  9789.                       scdiinfo gets  the  filename  of  the  index  file
  9790.                       associated with  "handle", the index key type, the
  9791.                       maximum index  key length,  and the  length of the
  9792.                       index key expression and returns in "info":
  9793.  
  9794.  
  9795.                       typedef struct {
  9796.                         signed char fname[80]; /* file name */
  9797.                         signed char keytype;   /* key type */
  9798.                                        /* (C,D,L,N) */
  9799.                         signed char keylen;    /* key length */
  9800.                         signed char exprlen;   /* expression */
  9801.                                        /* length */
  9802.                         SC_FLAGS flags;   /* misc. flags */
  9803.                       } SC_IDXINFO;
  9804.  
  9805.  
  9806.             NOTES
  9807.                       If  you   are  using   the  expression  length  to
  9808.                       dynamically  allocate   memory  to  hold  the  key
  9809.                       expression be sure to add one to the length before
  9810.                       allocation.
  9811.  
  9812.  
  9813.             SEE ALSO
  9814.                       scdiopenx.
  9815.  
  9816.  
  9817.  
  9818.  
  9819.             EXAMPLE
  9820.  
  9821.             #include <stdio.h>
  9822.             #include <softc.h>
  9823.             #include <sc_base.h>
  9824.  
  9825.             void main()
  9826.  
  9827.  
  9828.  
  9829.                                          141
  9830.  
  9831.  
  9832.  
  9833.  
  9834.  
  9835.  
  9836.  
  9837.  
  9838.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9839.  
  9840.  
  9841.             {
  9842.               int idx;
  9843.               SC_IDXINFO info;
  9844.  
  9845.               scdinit(20,0);
  9846.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  9847.             SC_SUCCESS) {
  9848.                 scdiinfo(idx,&info);
  9849.                 printf("File name = %s\n",info.fname);
  9850.                 printf("Index key type = %c\n",info.keytype);
  9851.                 printf("Maximum key length = %d\n",info.keylen);
  9852.                 printf("Key expression length = %d\n",info.exprlen);
  9853.                 scdiclose(idx);
  9854.               }
  9855.               scdterm();
  9856.             }
  9857.  
  9858.  
  9859.  
  9860.  
  9861.  
  9862.  
  9863.  
  9864.  
  9865.  
  9866.  
  9867.  
  9868.  
  9869.  
  9870.  
  9871.  
  9872.  
  9873.  
  9874.  
  9875.  
  9876.  
  9877.  
  9878.  
  9879.  
  9880.  
  9881.  
  9882.  
  9883.  
  9884.  
  9885.  
  9886.  
  9887.  
  9888.  
  9889.  
  9890.  
  9891.  
  9892.  
  9893.  
  9894.  
  9895.                                          142
  9896.  
  9897.  
  9898.  
  9899.  
  9900.  
  9901.  
  9902.  
  9903.  
  9904.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9905.  
  9906.  
  9907.  
  9908.             scdikadd  
  9909.  
  9910.             USAGE
  9911.                       signed int scdikadd(
  9912.                            signed int handle,
  9913.                            void *key,
  9914.                            signed long recno );
  9915.  
  9916.  
  9917.             PROTOTYPE IN
  9918.                       sc_base.h
  9919.  
  9920.  
  9921.             DESCRIPTION
  9922.                       scdikadd  will   add  "key"   to  the  index  file
  9923.                       specified by  "handle". "recno" is the data record
  9924.                       number to  be  associated  with  "key"  (the  data
  9925.                       record pointed  to by  "recno" must exist prior to
  9926.                       calling scdikadd).
  9927.  
  9928.  
  9929.             NOTES
  9930.                       When adding  character keys  it is  necessary   to
  9931.                       pad  the key string to size with spaces (" "), the
  9932.                       function will  not automatically  do this for you.
  9933.                       This  differs   from   the   dBASE   and   Clipper
  9934.                       corresponding functions.
  9935.  
  9936.  
  9937.             SEE ALSO
  9938.                       scdikdate, scdikmake,scdiknum.
  9939.  
  9940.  
  9941.  
  9942.  
  9943.             EXAMPLE
  9944.  
  9945.             #include <softc.h>
  9946.             #include <sc_base.h>
  9947.  
  9948.             void main()
  9949.             {
  9950.               int dbf, idx;
  9951.               long recno;
  9952.               unsigned char key[8]
  9953.               double length = 123.67L
  9954.  
  9955.               scdinit(20,0);
  9956.               if (scddopenx(&dbf, "TOC.DBF",0) == SC_SUCCESS) {
  9957.                 if (scdiopenx(&idx, "TOCLNGTH.IDX", SC_BUFFER) ==
  9958.  
  9959.  
  9960.  
  9961.                                          143
  9962.  
  9963.  
  9964.  
  9965.  
  9966.  
  9967.  
  9968.  
  9969.  
  9970.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9971.  
  9972.  
  9973.             SC_SUCCESS) {
  9974.                   scddfput(dbf,1,&length);
  9975.                   if (scddrput(dbf,&recno,SC_ADD) == SC_SUCCESS) {
  9976.                     scdiknum(key,length);
  9977.                     scdikadd(idx,key,recno);
  9978.                   }
  9979.                   scdiclose(idx);
  9980.                 }
  9981.                 scddclose(dbf)
  9982.               }
  9983.               scdterm();
  9984.             }
  9985.  
  9986.  
  9987.  
  9988.  
  9989.  
  9990.  
  9991.  
  9992.  
  9993.  
  9994.  
  9995.  
  9996.  
  9997.  
  9998.  
  9999.  
  10000.  
  10001.  
  10002.  
  10003.  
  10004.  
  10005.  
  10006.  
  10007.  
  10008.  
  10009.  
  10010.  
  10011.  
  10012.  
  10013.  
  10014.  
  10015.  
  10016.  
  10017.  
  10018.  
  10019.  
  10020.  
  10021.  
  10022.  
  10023.  
  10024.  
  10025.  
  10026.  
  10027.                                          144
  10028.  
  10029.  
  10030.  
  10031.  
  10032.  
  10033.  
  10034.  
  10035.  
  10036.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10037.  
  10038.  
  10039.  
  10040.             scdikbot  
  10041.  
  10042.             USAGE
  10043.                       signed int scdikbot(
  10044.                            signed int handle,
  10045.                            void *key,
  10046.                            signed long *recno );
  10047.  
  10048.  
  10049.             PROTOTYPE IN
  10050.                       sc_base.h
  10051.  
  10052.  
  10053.             DESCRIPTION
  10054.                       scdikbot will  set the  current key pointer to the
  10055.                       last logical  key in  the index and return the key
  10056.                       value  "key"   and  data   record  number  "recno"
  10057.                       associated with the new current key.
  10058.  
  10059.  
  10060.             NOTES
  10061.                       The user  must ensure  that  the  buffer  used  to
  10062.                       return the  key is large enough to hold the entire
  10063.                       key.  The   maximum  length  of  the  key  can  be
  10064.                       determined via a call to scdiinfo.
  10065.  
  10066.  
  10067.                       Numeric  keys   are  returned   as  doubles,   and
  10068.                       character keys are returned as strings.
  10069.  
  10070.  
  10071.             SEE ALSO
  10072.                       scdiinfo.
  10073.  
  10074.  
  10075.  
  10076.  
  10077.             EXAMPLE
  10078.  
  10079.             #include <stdio.h>
  10080.             #include <softc.h>
  10081.             #include <sc_base.h>
  10082.  
  10083.             void main()
  10084.             {
  10085.               int idx;
  10086.               char name[65];
  10087.               long recno;
  10088.  
  10089.               scdinit(20,0);
  10090.  
  10091.  
  10092.  
  10093.                                          145
  10094.  
  10095.  
  10096.  
  10097.  
  10098.  
  10099.  
  10100.  
  10101.  
  10102.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10103.  
  10104.  
  10105.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  10106.             SC_SUCCESS) {
  10107.                 name[64] = 0;
  10108.                 scdikbot(idx,name,&recno);
  10109.                 printf("%s %ld\n",name,recno);
  10110.                 scdiclose(idx);
  10111.               }
  10112.               scdterm();
  10113.             }
  10114.  
  10115.  
  10116.  
  10117.  
  10118.  
  10119.  
  10120.  
  10121.  
  10122.  
  10123.  
  10124.  
  10125.  
  10126.  
  10127.  
  10128.  
  10129.  
  10130.  
  10131.  
  10132.  
  10133.  
  10134.  
  10135.  
  10136.  
  10137.  
  10138.  
  10139.  
  10140.  
  10141.  
  10142.  
  10143.  
  10144.  
  10145.  
  10146.  
  10147.  
  10148.  
  10149.  
  10150.  
  10151.  
  10152.  
  10153.  
  10154.  
  10155.  
  10156.  
  10157.  
  10158.  
  10159.                                          146
  10160.  
  10161.  
  10162.  
  10163.  
  10164.  
  10165.  
  10166.  
  10167.  
  10168.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10169.  
  10170.  
  10171.  
  10172.             scdikcur  
  10173.  
  10174.             USAGE
  10175.                       signed int scdikcur(
  10176.                            signed int handle,
  10177.                            void *key,
  10178.                            signed long *recno );
  10179.  
  10180.  
  10181.             PROTOTYPE IN
  10182.                       sc_base.h
  10183.  
  10184.  
  10185.             DESCRIPTION
  10186.                       scdikcur will  return the key value "key" and data
  10187.                       record number  "recno" associated with the current
  10188.                       key in the index file.
  10189.  
  10190.  
  10191.                       The current  key pointer  must be set by a call to
  10192.                       either scdikfind,  scdiktop, scdikbot,  scdiknext,
  10193.                       or scdikprev before calling scdikcur.
  10194.  
  10195.  
  10196.             NOTES
  10197.                       The user  must ensure  that  the  buffer  used  to
  10198.                       return the  key is large enough to hold the entire
  10199.                       key.  The   maximum  length  of  the  key  can  be
  10200.                       determined via a call to scdiinfo.
  10201.  
  10202.  
  10203.             SEE ALSO
  10204.                       scdiinfo, scdikfind, scdiktop, scdikbot,
  10205.                       scdiknext, scdikprev.
  10206.  
  10207.  
  10208.  
  10209.  
  10210.             EXAMPLE
  10211.  
  10212.             #include <stdio.h>
  10213.             #include <softc.h>
  10214.             #include <sc_base.h>
  10215.  
  10216.             void main()
  10217.             {
  10218.               int idx;
  10219.               char date[17], dat[17];
  10220.               long recno, recn;
  10221.  
  10222.  
  10223.  
  10224.  
  10225.                                          147
  10226.  
  10227.  
  10228.  
  10229.  
  10230.  
  10231.  
  10232.  
  10233.  
  10234.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10235.  
  10236.  
  10237.               scdinit(20,0);
  10238.               if (scdiopenx(&idx, "TOCDATE.IDX", SC_BUFFER) ==
  10239.             SC_SUCCESS) {
  10240.                 date[16] = 0;
  10241.                 dat[16] = 0;
  10242.                 scdiktop(idx,date,&recno);
  10243.                 scdikcur(idx,dat,&recn);
  10244.                 printf("%s %s %ld %ld\n",      date,dat,recno,recn);
  10245.                 scdiclose(idx);
  10246.               }
  10247.               scdterm();
  10248.             }
  10249.  
  10250.  
  10251.  
  10252.  
  10253.  
  10254.  
  10255.  
  10256.  
  10257.  
  10258.  
  10259.  
  10260.  
  10261.  
  10262.  
  10263.  
  10264.  
  10265.  
  10266.  
  10267.  
  10268.  
  10269.  
  10270.  
  10271.  
  10272.  
  10273.  
  10274.  
  10275.  
  10276.  
  10277.  
  10278.  
  10279.  
  10280.  
  10281.  
  10282.  
  10283.  
  10284.  
  10285.  
  10286.  
  10287.  
  10288.  
  10289.  
  10290.  
  10291.                                          148
  10292.  
  10293.  
  10294.  
  10295.  
  10296.  
  10297.  
  10298.  
  10299.  
  10300.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10301.  
  10302.  
  10303.  
  10304.             scdikdate 
  10305.  
  10306.             USAGE
  10307.                       signed int scdikdate(
  10308.                            unsigned char *key,
  10309.                            signed char *string,
  10310.                            signed int format );
  10311.  
  10312.  
  10313.             PROTOTYPE IN
  10314.                       sc_base.h
  10315.  
  10316.  
  10317.             DESCRIPTION
  10318.                       scdikdate will  translate an  ASCIIZ  date  string
  10319.                       "string" of  style "format"  into a valid FoxBASE+
  10320.                       date key "key".
  10321.  
  10322.  
  10323.                       Date string styles:
  10324.                       SC_GREGOR   mm/dd/yy
  10325.                       SC_GREGORL  mm/dd/yyyy
  10326.                       SC_JULIAN   yyyy/ddd
  10327.                       SC_YMD      yyyymmdd
  10328.                       SC_DMY      ddmmyy
  10329.  
  10330.             SEE ALSO
  10331.                       scdikmake, scdiknum.
  10332.  
  10333.  
  10334.  
  10335.  
  10336.             EXAMPLE
  10337.  
  10338.             #include <softc.h>
  10339.             #include <sc_base.h>
  10340.  
  10341.             void main()
  10342.             {
  10343.               int dbf, idx;
  10344.               long recno;
  10345.               unsigned char key[8]
  10346.  
  10347.               scdinit(20,0);
  10348.               if (scddopenx(&dbf, "TOC.DBF",0) == SC_SUCCESS) {
  10349.                 if (scdiopenx(&idx, "TOCFDATE.IDX", SC_BUFFER) ==
  10350.             SC_SUCCESS) {
  10351.                   scddfput(dbf,2,"07/21/90);
  10352.                   .
  10353.                   .
  10354.  
  10355.  
  10356.  
  10357.                                          149
  10358.  
  10359.  
  10360.  
  10361.  
  10362.  
  10363.  
  10364.  
  10365.  
  10366.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10367.  
  10368.  
  10369.                   .
  10370.                   if (scddrput(dbf,&recno,SC_ADD) == SC_SUCCESS) {
  10371.                     scdikdate(key, "07/21/90", SC_GREGOR);
  10372.                     scdikadd(idx,key,recno);
  10373.                   }
  10374.                   scdiclose(idx);
  10375.                 }
  10376.                 scddclose(dbf)
  10377.               }
  10378.               scdterm();
  10379.             }
  10380.  
  10381.  
  10382.  
  10383.  
  10384.  
  10385.  
  10386.  
  10387.  
  10388.  
  10389.  
  10390.  
  10391.  
  10392.  
  10393.  
  10394.  
  10395.  
  10396.  
  10397.  
  10398.  
  10399.  
  10400.  
  10401.  
  10402.  
  10403.  
  10404.  
  10405.  
  10406.  
  10407.  
  10408.  
  10409.  
  10410.  
  10411.  
  10412.  
  10413.  
  10414.  
  10415.  
  10416.  
  10417.  
  10418.  
  10419.  
  10420.  
  10421.  
  10422.  
  10423.                                          150
  10424.  
  10425.  
  10426.  
  10427.  
  10428.  
  10429.  
  10430.  
  10431.  
  10432.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10433.  
  10434.  
  10435.  
  10436.             scdikdel  
  10437.  
  10438.             USAGE
  10439.                       signed int scdikdel(
  10440.                            signed char handle,
  10441.                            void *key,
  10442.                            signed long recno );
  10443.  
  10444.  
  10445.             PROTOTYPE IN
  10446.                       sc_base.h
  10447.  
  10448.  
  10449.             DESCRIPTION
  10450.                       scdikdel will  remove "key"  from the  index  file
  10451.                       specified by  "handle". "recno" is used along with
  10452.                       "key" to  ensure that  the  proper  key  has  been
  10453.                       removed from the index file.
  10454.  
  10455.  
  10456.             NOTES
  10457.                       When deleting  character keys  it is necessary  to
  10458.                       pad  the key string to size with spaces (" "), the
  10459.                       function will  not automatically  do this for you.
  10460.                       This differs  from  the  corresponding  dBASE  and
  10461.                       Clipper functions.
  10462.  
  10463.  
  10464.             SEE ALSO
  10465.                       scdikadd.
  10466.  
  10467.  
  10468.  
  10469.  
  10470.             EXAMPLE
  10471.  
  10472.             #include <string.h>
  10473.             #include <sc_base.h>
  10474.  
  10475.             void main()
  10476.             {
  10477.               int idx;
  10478.               char name[65];
  10479.  
  10480.               scdinit(20,0);
  10481.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  10482.             SC_SUCCESS) {
  10483.                 strcpy(name,"ABC.DEF");
  10484.                 scdikdel(idx,name,3L);
  10485.                 scdiclose(idx);
  10486.  
  10487.  
  10488.  
  10489.                                          151
  10490.  
  10491.  
  10492.  
  10493.  
  10494.  
  10495.  
  10496.  
  10497.  
  10498.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10499.  
  10500.  
  10501.               }
  10502.               scdterm();
  10503.             }
  10504.  
  10505.  
  10506.  
  10507.  
  10508.  
  10509.  
  10510.  
  10511.  
  10512.  
  10513.  
  10514.  
  10515.  
  10516.  
  10517.  
  10518.  
  10519.  
  10520.  
  10521.  
  10522.  
  10523.  
  10524.  
  10525.  
  10526.  
  10527.  
  10528.  
  10529.  
  10530.  
  10531.  
  10532.  
  10533.  
  10534.  
  10535.  
  10536.  
  10537.  
  10538.  
  10539.  
  10540.  
  10541.  
  10542.  
  10543.  
  10544.  
  10545.  
  10546.  
  10547.  
  10548.  
  10549.  
  10550.  
  10551.  
  10552.  
  10553.  
  10554.  
  10555.                                          152
  10556.  
  10557.  
  10558.  
  10559.  
  10560.  
  10561.  
  10562.  
  10563.  
  10564.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10565.  
  10566.  
  10567.  
  10568.             scdikfind 
  10569.  
  10570.             USAGE
  10571.                       signed int scdikfind(
  10572.                            signed int handle,
  10573.                            void *key,
  10574.                            signed long *recno,
  10575.                            signed int method );
  10576.  
  10577.  
  10578.             PROTOTYPE IN
  10579.                       sc_base.h
  10580.  
  10581.  
  10582.             DESCRIPTION
  10583.                       scdikfind  supports   two   key   search   methods
  10584.                       (determined by "method"): SC_EXACT - find an exact
  10585.                       match with  "key" and "recno", and SC_FIRST - find
  10586.                       the first logical occurrence of "key" in the index
  10587.                       and return the associated record number "recno" if
  10588.                       found.
  10589.  
  10590.  
  10591.                       If a  match cannot  be found, the current key will
  10592.                       be  the   physical  key  which  would  immediately
  10593.                       precede "key".  The current  key's value  and data
  10594.                       record  number  will  be  returned  in  "key"  and
  10595.                       "recno".
  10596.  
  10597.  
  10598.             NOTES
  10599.                       The user  must ensure  that  the  buffer  used  to
  10600.                       return the  key is large enough to hold the entire
  10601.                       key.  The   maximum  length  of  the  key  can  be
  10602.                       determined via a call to scdiinfo.
  10603.  
  10604.  
  10605.                       When  searching   using  character   keys  it   is
  10606.                       necessary   to   pad   the key string to size with
  10607.                       spaces ("  "), the function will not automatically
  10608.                       do this for you. Because of the above restriction,
  10609.                       searching  for   partial  keys  is  not  currently
  10610.                       supported.
  10611.  
  10612.  
  10613.                       Numeric  keys   are  returned   as  doubles,   and
  10614.                       character keys are returned as strings.
  10615.  
  10616.  
  10617.  
  10618.  
  10619.  
  10620.  
  10621.                                          153
  10622.  
  10623.  
  10624.  
  10625.  
  10626.  
  10627.  
  10628.  
  10629.  
  10630.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10631.  
  10632.  
  10633.             SEE ALSO
  10634.                       scdiinfo.
  10635.  
  10636.  
  10637.  
  10638.  
  10639.             EXAMPLE
  10640.  
  10641.             #include <stdio.h>
  10642.             #include <string.h>
  10643.             #include <softc.h>
  10644.             #include <sc_base.h>
  10645.  
  10646.             void main()
  10647.             {
  10648.               int idx;
  10649.               char name[65];
  10650.               long recno;
  10651.  
  10652.               scdinit(20,0);
  10653.               if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  10654.             SC_SUCCESS) {
  10655.                 strcpy(name,"ABCDE");
  10656.                 recno = 7L;
  10657.                 if (scdikfind(idx, name, &recno, SC_FIRST) !=
  10658.             SC_SUCCESS)
  10659.                   puts(scemsg());
  10660.                 scdiclose(idx);
  10661.               }
  10662.               scdterm();
  10663.             }
  10664.  
  10665.  
  10666.  
  10667.  
  10668.  
  10669.  
  10670.  
  10671.  
  10672.  
  10673.  
  10674.  
  10675.  
  10676.  
  10677.  
  10678.  
  10679.  
  10680.  
  10681.  
  10682.  
  10683.  
  10684.  
  10685.  
  10686.  
  10687.                                          154
  10688.  
  10689.  
  10690.  
  10691.  
  10692.  
  10693.  
  10694.  
  10695.  
  10696.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10697.  
  10698.  
  10699.  
  10700.             scdikmake 
  10701.  
  10702.             USAGE
  10703.                       signed int scdikmake(
  10704.                            signed int datahandle,
  10705.                            signed int indexhandle,
  10706.                            void **key );
  10707.  
  10708.  
  10709.             PROTOTYPE IN
  10710.                       sc_base.h
  10711.  
  10712.  
  10713.             DESCRIPTION
  10714.                       scdikmake will  build an  index key  using the key
  10715.                       expression  of   the  index   file  specified   by
  10716.                       "indexhandle" and  the data  found in  the  record
  10717.                       buffer of the data file "datahandle". Memory space
  10718.                       for the "key" will be allocated and the address of
  10719.                       this block will be returned.
  10720.  
  10721.  
  10722.                       The key  expression can consist of either the data
  10723.                       field name  or one of five FoxBASE+ functions or a
  10724.                       combination thereof.  Data field  types  of  date,
  10725.                       numeric,  character   or  logical   are   allowed.
  10726.                       FoxBASE+ functions:  dtoc, left,  right, str,  and
  10727.                       substr are currently supported by scdikmake.
  10728.  
  10729.  
  10730.                       Following is  a  brief  description  of  the  five
  10731.                       expression functions:
  10732.  
  10733.  
  10734.                       dtoc will  convert data  from a  date field  to an
  10735.                       ASCIIZ string of the format mm/dd/yy. Syntax is:
  10736.  
  10737.  
  10738.                       dtoc(field_name)
  10739.  
  10740.  
  10741.                       left will  return the  left portion of a character
  10742.                       field  as   an  ASCIIZ   string.  The   number  of
  10743.                       characters returned  is specified  after the field
  10744.                       name. Syntax is:
  10745.  
  10746.  
  10747.                       left(field_name,number)
  10748.  
  10749.  
  10750.  
  10751.  
  10752.  
  10753.                                          155
  10754.  
  10755.  
  10756.  
  10757.  
  10758.  
  10759.  
  10760.  
  10761.  
  10762.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10763.  
  10764.  
  10765.                       right will return the right portion of a character
  10766.                       field  as   an  ASCIIZ   string.  The   number  of
  10767.                       characters returned  is specified  after the field
  10768.                       name. This  is a  count from the right side of the
  10769.                       field. Syntax is:
  10770.  
  10771.  
  10772.                       right(field_name,number)
  10773.  
  10774.  
  10775.                       str will  convert a  numeric field  to  an  ASCIIZ
  10776.                       string. The  total length  of the  string and  the
  10777.                       number of  decimal places are optional parameters.
  10778.                       The default  string length is 10 and the number of
  10779.                       decimal places is 0. Syntax is:
  10780.  
  10781.  
  10782.                       str(field_name,length,decimal_places)
  10783.  
  10784.  
  10785.                       substr  will   return  the  middle  portion  of  a
  10786.                       character field.  The  starting  offset  into  the
  10787.                       field is  a  required  parameter.  The  number  of
  10788.                       characters to  be used  is an  optional  parameter
  10789.                       whose default value is the remainder of the field.
  10790.                       Syntax is:
  10791.  
  10792.  
  10793.                       substr(field_name,start,count)
  10794.  
  10795.  
  10796.                       An example of a more complex key expression:
  10797.  
  10798.  
  10799.                       right(dtoc(date),2)+left(dtoc(date,2)
  10800.  
  10801.  
  10802.                       This expression would cause scdikmake to create an
  10803.                       index key  string consisting of the year and month
  10804.                       ("yymm"). For example if date equals "2/13/89" the
  10805.                       resultant key would be "8902".
  10806.  
  10807.  
  10808.             NOTES
  10809.                       For key  expressions consisting  of only  one data
  10810.                       field scdikmake  is probably  an overkill. You can
  10811.                       easily generate these keys yourself. See scdikdate
  10812.                       for information on date string to key translation,
  10813.                       and scdiknum for numeric field to key translation.
  10814.                       scdikmake is  a fairly  large module  and  if  not
  10815.                       needed probably  should not be used. This function
  10816.  
  10817.  
  10818.  
  10819.                                          156
  10820.  
  10821.  
  10822.  
  10823.  
  10824.  
  10825.  
  10826.  
  10827.  
  10828.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10829.  
  10830.  
  10831.                       is best  used when  the  key  expression  is  more
  10832.                       complex.
  10833.  
  10834.  
  10835.                       Memory is  allocated for  the generated key and it
  10836.                       is the  responsibility of  the caller to free this
  10837.                       memory when finished.
  10838.  
  10839.  
  10840.             SEE ALSO
  10841.                       scdicreate, scdikdate, scdiknum.
  10842.  
  10843.  
  10844.  
  10845.  
  10846.             EXAMPLE
  10847.  
  10848.             #include <sc_base.h>
  10849.  
  10850.             void main()
  10851.             {
  10852.               int idx, dbf;
  10853.               char *key, name[65];
  10854.               long recno;
  10855.  
  10856.               scdinit(20,0);
  10857.               if (scddopenx(&dbf, "TOC.DBF", 0) == SC_SUCCESS) {
  10858.                 if (scdiopenx(&idx, "TOCNAME.IDX", SC_BUFFER) ==
  10859.             SC_SUCCESS) {
  10860.                   scddfput(dbf,0,name);
  10861.                   scddrput(dbf,&recno,SC_ADD);
  10862.                   scdikmake(dbf,idx,(void **) &key);
  10863.                   scdikadd(idx,key,recno);
  10864.                   free(key);         /* free memory allocated for key */
  10865.                   scdiclose(idx);
  10866.                 }
  10867.                 scddclose(dbf);
  10868.               }
  10869.               scdterm();
  10870.             }
  10871.  
  10872.  
  10873.  
  10874.  
  10875.  
  10876.  
  10877.  
  10878.  
  10879.  
  10880.  
  10881.  
  10882.  
  10883.  
  10884.  
  10885.                                          157
  10886.  
  10887.  
  10888.  
  10889.  
  10890.  
  10891.  
  10892.  
  10893.  
  10894.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10895.  
  10896.  
  10897.  
  10898.             scdiknext 
  10899.  
  10900.             USAGE
  10901.                       signed int scdiknext(
  10902.                            signed int handle,
  10903.                            void *key,
  10904.                            signed long *recno );
  10905.  
  10906.  
  10907.             PROTOTYPE IN
  10908.                       sc_base.h
  10909.  
  10910.  
  10911.             DESCRIPTION
  10912.                       scdiknext  will  increment  the  key  pointer  and
  10913.                       return the  key value "key" and data record number
  10914.                       "recno" associated with the new current key.
  10915.  
  10916.  
  10917.                       If scdiknext  is called  immediately after opening
  10918.                       the index  file the  first  logical  key  will  be
  10919.                       returned.
  10920.  
  10921.  
  10922.             NOTES
  10923.                       The user  must ensure  that  the  buffer  used  to
  10924.                       return the  key is large enough to hold the entire
  10925.                       key.  The   maximum  length  of  the  key  can  be
  10926.                       determined via a call to scdiinfo.
  10927.  
  10928.  
  10929.                       Numeric  keys   are  returned   as  doubles,   and
  10930.                       character keys are returned as strings.
  10931.  
  10932.  
  10933.             SEE ALSO
  10934.                       scdiinfo.
  10935.  
  10936.  
  10937.  
  10938.  
  10939.             EXAMPLE
  10940.  
  10941.             /* Character Key Example */
  10942.             #include <stdio.h>
  10943.             #include <softc.h>
  10944.             #include <sc_base.h>
  10945.  
  10946.             void main()
  10947.             {
  10948.  
  10949.  
  10950.  
  10951.                                          158
  10952.  
  10953.  
  10954.  
  10955.  
  10956.  
  10957.  
  10958.  
  10959.  
  10960.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10961.  
  10962.  
  10963.               int idx;
  10964.               char name[65];
  10965.               long recno;
  10966.  
  10967.               scdinit(20,0);
  10968.               if (scdiopenx(&idx,"TOCNAME.IDX",SC_BUFFER) == SC_SUCCESS)
  10969.             {
  10970.                 scdiknext(idx,name,&recno);    /* return first key */
  10971.                 printf("%s %ld\n",name,recno);
  10972.                 scdiclose(idx);
  10973.               }
  10974.               scdterm();
  10975.             }
  10976.  
  10977.             /*  Numeric Key Example */
  10978.             #include <stdio.h>
  10979.             #include <softc.h>
  10980.             #include <sc_base.h>
  10981.  
  10982.             void main()
  10983.             {
  10984.               int idx;
  10985.               double numeric;
  10986.               long recno;
  10987.  
  10988.               scdinit(20,0);
  10989.               if (scdiopenx(&idx,"TOCLNGTH.IDX",SC_BUFFER) ==
  10990.             SC_SUCCESS) {
  10991.                 scdiknext(idx,&numeric,&recno);     /* return first key
  10992.             */
  10993.                 printf("%lf %ld\n",numeric,recno);
  10994.                 scdiclose(idx);
  10995.               }
  10996.               scdterm();
  10997.             }
  10998.  
  10999.  
  11000.  
  11001.  
  11002.  
  11003.  
  11004.  
  11005.  
  11006.  
  11007.  
  11008.  
  11009.  
  11010.  
  11011.  
  11012.  
  11013.  
  11014.  
  11015.  
  11016.  
  11017.                                          159
  11018.  
  11019.  
  11020.  
  11021.  
  11022.  
  11023.  
  11024.  
  11025.  
  11026.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11027.  
  11028.  
  11029.  
  11030.             scdiknum  
  11031.  
  11032.             USAGE
  11033.                       signed int scdiknum(
  11034.                            unsigned char *key,
  11035.                            double value );
  11036.  
  11037.  
  11038.             PROTOTYPE IN
  11039.                       sc_base.h
  11040.  
  11041.  
  11042.             DESCRIPTION
  11043.                       scdiknum will  translate a 'C' double "value" to a
  11044.                       FoxBASE+ numeric "key".
  11045.  
  11046.  
  11047.             SEE ALSO
  11048.                       scdicreate, scdikdate, scdikmake.
  11049.  
  11050.  
  11051.  
  11052.  
  11053.             EXAMPLE
  11054.  
  11055.             #include <softc.h>
  11056.             #include <sc_base.h>
  11057.  
  11058.             void main()
  11059.             {
  11060.               int dbf, idx;
  11061.               long recno;
  11062.               unsigned char key[8]
  11063.               double length = 123.67L
  11064.  
  11065.               scdinit(20,0);
  11066.               if (scddopenx(&dbf, "TOC.DBF",0) == SC_SUCCESS) {
  11067.                 if (scdiopenx(&idx, "TOCLNGTH.IDX", SC_BUFFER) ==
  11068.             SC_SUCCESS) {
  11069.                   scddfput(dbf,1,&length);
  11070.                   if (scddrput(dbf,&recno,SC_ADD) == SC_SUCCESS) {
  11071.                     scdiknum(key,length);
  11072.                     scdikadd(idx,key,recno);
  11073.                   }
  11074.                   scdiclose(idx);
  11075.                 }
  11076.                 scddclose(dbf)
  11077.               }
  11078.               scdterm();
  11079.             }
  11080.  
  11081.  
  11082.  
  11083.                                          160
  11084.  
  11085.  
  11086.  
  11087.  
  11088.  
  11089.  
  11090.  
  11091.  
  11092.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11093.  
  11094.  
  11095.  
  11096.             scdikprev 
  11097.  
  11098.             USAGE
  11099.                       signed int scdikprev(
  11100.                            signed int handle,
  11101.                            void *key,
  11102.                            signed long *recno );
  11103.  
  11104.  
  11105.             PROTOTYPE IN
  11106.                       sc_base.h
  11107.  
  11108.  
  11109.             DESCRIPTION
  11110.                       scdikprev  will  decrement  the  key  pointer  and
  11111.                       return the  key value "key" and data record number
  11112.                       "recno" associated with the new current key.
  11113.  
  11114.  
  11115.                       If scdikprev  is called  immediately after opening
  11116.                       the index  file  the  last  logical  key  will  be
  11117.                       returned.
  11118.  
  11119.  
  11120.             NOTES
  11121.                       The user  must ensure  that  the  buffer  used  to
  11122.                       return the  key is large enough to hold the entire
  11123.                       key.  The   maximum  length  of  the  key  can  be
  11124.                       determined via a call to scdiinfo.
  11125.  
  11126.  
  11127.                       Numeric  keys   are  returned   as  doubles,   and
  11128.                       character keys are returned as strings.
  11129.  
  11130.  
  11131.             SEE ALSO
  11132.                       scdiinfo.
  11133.  
  11134.  
  11135.  
  11136.  
  11137.             EXAMPLE
  11138.  
  11139.             /*  Character Key Example */
  11140.             #include <stdio.h>
  11141.             #include <softc.h>
  11142.             #include <sc_base.h>
  11143.  
  11144.             void main()
  11145.             {
  11146.  
  11147.  
  11148.  
  11149.                                          161
  11150.  
  11151.  
  11152.  
  11153.  
  11154.  
  11155.  
  11156.  
  11157.  
  11158.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11159.  
  11160.  
  11161.               int idx;
  11162.               char name[65];
  11163.               long recno;
  11164.  
  11165.               scdinit(20,0);
  11166.               if (scdiopenx(&idx,"TOCNAME.IDX",SC_BUFFER) == SC_SUCCESS)
  11167.             {
  11168.                 scdikprev(idx, name, &recno);  /* get last key */
  11169.                 printf("%s %ld\n",name,recno);
  11170.                 scdiclose(idx);
  11171.               }
  11172.               scdterm();
  11173.             }
  11174.  
  11175.             /*  Numeric Key Example */
  11176.             #include <stdio.h>
  11177.             #include <softc.h>
  11178.             #include <sc_base.h>
  11179.  
  11180.             void main()
  11181.             {
  11182.               int idx;
  11183.               double length;
  11184.               long recno;
  11185.  
  11186.               scdinit(20,0);
  11187.               if (scdiopenx(&idx,"TOCLNGTH.IDX",SC_BUFFER) ==
  11188.             SC_SUCCESS) {
  11189.                 scdikprev(idx,&length,&recno); /* get last key */
  11190.                 printf("%lf %ld\n",length,recno);
  11191.                 scdiclose(idx);
  11192.               }
  11193.               scdterm();
  11194.             }
  11195.  
  11196.  
  11197.  
  11198.  
  11199.  
  11200.  
  11201.  
  11202.  
  11203.  
  11204.  
  11205.  
  11206.  
  11207.  
  11208.  
  11209.  
  11210.  
  11211.  
  11212.  
  11213.  
  11214.  
  11215.                                          162
  11216.  
  11217.  
  11218.  
  11219.  
  11220.  
  11221.  
  11222.  
  11223.  
  11224.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11225.  
  11226.  
  11227.  
  11228.             scdiktop  
  11229.  
  11230.             USAGE
  11231.                       signed int scdiktop(
  11232.                            signed int handle,
  11233.                            void *key,
  11234.                            signed long *recno );
  11235.  
  11236.  
  11237.             PROTOTYPE IN
  11238.                       sc_base.h
  11239.  
  11240.  
  11241.             DESCRIPTION
  11242.                       scdiktop will  set the  current key pointer to the
  11243.                       first logical  key in the index and return the key
  11244.                       value  "key"   and  data   record  number  "recno"
  11245.                       associated with the new current key.
  11246.  
  11247.  
  11248.             NOTES
  11249.                       The user  must ensure  that  the  buffer  used  to
  11250.                       return the  key is large enough to hold the entire
  11251.                       key.  The   maximum  length  of  the  key  can  be
  11252.                       determined via a call to scdiinfo.
  11253.  
  11254.  
  11255.                       Numeric  keys   are  returned   as  doubles,   and
  11256.                       character keys are returned as strings.
  11257.  
  11258.  
  11259.             SEE ALSO
  11260.                       scdiinfo.
  11261.  
  11262.  
  11263.  
  11264.  
  11265.             EXAMPLE
  11266.  
  11267.             /*  Character Key Example */
  11268.             #include <stdio.h>
  11269.             #include <softc.h>
  11270.             #include <sc_base.h>
  11271.  
  11272.             void main()
  11273.             {
  11274.               int idx;
  11275.               char name[65];
  11276.               long recno;
  11277.  
  11278.  
  11279.  
  11280.  
  11281.                                          163
  11282.  
  11283.  
  11284.  
  11285.  
  11286.  
  11287.  
  11288.  
  11289.  
  11290.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11291.  
  11292.  
  11293.               scdinit(20,0);
  11294.               if (scdiopenx(&idx,"TOCNAME.IDX",SC_BUFFER) == SC_SUCCESS)
  11295.             {
  11296.                 name[64] = 0;
  11297.                 scdiktop(idx,name,&recno);
  11298.                 printf("%s %ld\n",name,recno);
  11299.                 scdiclose(idx);
  11300.               }
  11301.               scdterm();
  11302.             }
  11303.  
  11304.             /*  Numeric Key Example */
  11305.             #include <stdio.h>
  11306.             #include <softc.h>
  11307.             #include <sc_base.h>
  11308.  
  11309.             void main()
  11310.             {
  11311.               int idx;
  11312.               double length;
  11313.               long recno;
  11314.  
  11315.               scdinit(20,0);
  11316.               if (scdiopenx(&idx,"TOCLNGTH.IDX",SC_BUFFER) ==
  11317.             SC_SUCCESS) {
  11318.                 scdiktop(idx,&length,&recno);
  11319.                 printf("%lf %ld\n",length,recno);
  11320.                 scdiclose(idx);
  11321.               }
  11322.               scdterm();
  11323.             }
  11324.  
  11325.  
  11326.  
  11327.  
  11328.  
  11329.  
  11330.  
  11331.  
  11332.  
  11333.  
  11334.  
  11335.  
  11336.  
  11337.  
  11338.  
  11339.  
  11340.  
  11341.  
  11342.  
  11343.  
  11344.  
  11345.  
  11346.  
  11347.                                          164
  11348.  
  11349.  
  11350.  
  11351.  
  11352.  
  11353.  
  11354.  
  11355.  
  11356.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11357.  
  11358.  
  11359.  
  11360.             scdinit   
  11361.  
  11362.             USAGE
  11363.                       signed int scdinit(
  11364.                            signed int files,
  11365.                            signed int command );
  11366.  
  11367.  
  11368.             PROTOTYPE IN
  11369.                       sc_base.h
  11370.  
  11371.  
  11372.             DESCRIPTION
  11373.                       scdinit should be called once and only once at the
  11374.                       beginning of  the program.  The maximum  number of
  11375.                       simultaneously  open   "files"  is   passed.  This
  11376.                       function sets  up the  SoftC Database Library file
  11377.                       manager environment for processing. Memory will be
  11378.                       allocated for a variety of control structures used
  11379.                       internally by the file manager.
  11380.  
  11381.  
  11382.                       If the  "command" switch  SC_USEXHNDLS is  passed,
  11383.                       more than  20 (the default) open files per program
  11384.                       is  allowed.   A  larger   handle  table  will  be
  11385.                       allocated and the DOS PSP will be changed.
  11386.  
  11387.  
  11388.             NOTES
  11389.                       The first  five file handles per program are taken
  11390.                       up with  printer, console,  auxiliary  port,  etc.
  11391.                       leaving only 15 file handles available per program
  11392.                       in the default state.
  11393.  
  11394.  
  11395.                       Neither  Microsoft  C  5.x/6.0  nor  Turbo  C  2.0
  11396.                       support more than 20 open files. In other words if
  11397.                       you want to open more than 20 files you have to go
  11398.                       directly to DOS.
  11399.  
  11400.  
  11401.             SEE ALSO
  11402.                       scdterm.
  11403.  
  11404.  
  11405.  
  11406.  
  11407.  
  11408.  
  11409.  
  11410.  
  11411.  
  11412.  
  11413.                                          165
  11414.  
  11415.  
  11416.  
  11417.  
  11418.  
  11419.  
  11420.  
  11421.  
  11422.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11423.  
  11424.  
  11425.             EXAMPLE
  11426.  
  11427.             #include <sc_base.h>
  11428.  
  11429.             void main()
  11430.             {
  11431.               scdinit(20,0);
  11432.               scdterm();
  11433.             }
  11434.  
  11435.  
  11436.  
  11437.  
  11438.  
  11439.  
  11440.  
  11441.  
  11442.  
  11443.  
  11444.  
  11445.  
  11446.  
  11447.  
  11448.  
  11449.  
  11450.  
  11451.  
  11452.  
  11453.  
  11454.  
  11455.  
  11456.  
  11457.  
  11458.  
  11459.  
  11460.  
  11461.  
  11462.  
  11463.  
  11464.  
  11465.  
  11466.  
  11467.  
  11468.  
  11469.  
  11470.  
  11471.  
  11472.  
  11473.  
  11474.  
  11475.  
  11476.  
  11477.  
  11478.  
  11479.                                          166
  11480.  
  11481.  
  11482.  
  11483.  
  11484.  
  11485.  
  11486.  
  11487.  
  11488.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11489.  
  11490.  
  11491.  
  11492.             scdiopenx 
  11493.  
  11494.             USAGE
  11495.                       signed int scdiopenx(
  11496.                            signed int *handle,
  11497.                            signed char *filename,
  11498.                            signed int command );
  11499.  
  11500.  
  11501.             PROTOTYPE IN
  11502.                       sc_base.h
  11503.  
  11504.  
  11505.             DESCRIPTION
  11506.                       scdiopenx opens  a FoxBASE+   index  file.  Memory
  11507.                       will be  allocated for a file packet, I/O buffers,
  11508.                       and  other   miscellaneous  structures   for   use
  11509.                       internally by  the  SoftC  Database  Library  file
  11510.                       manager. The  index file will be tested as much as
  11511.                       possible  to   insure  that  it  is  a  legitimate
  11512.                       FoxBASE+ index file.
  11513.  
  11514.  
  11515.                       A block  of memory large enough to hold at least 4
  11516.                       pages (2048  bytes) will  be allocated  during the
  11517.                       open. Four  pages is the minimum number of buffers
  11518.                       required to add or delete index keys.
  11519.  
  11520.  
  11521.                       The file  will be  opened  under  control  of  the
  11522.                       "command" parameter.  Using SC_RDWR opens the file
  11523.                       for  both   read  and  write  access.    SC_RDONLY
  11524.                       overrides SC_RDWR and causes the file to be opened
  11525.                       for read  access only.   Any attempt to write to a
  11526.                       read  only   file  will   result   in   an   error
  11527.                       (SC_READOLY).
  11528.  
  11529.  
  11530.                       Using SC_BUFFER  opens the  file with  I/O caching
  11531.                       enabled.   Memory for  up   to 10  pages  will  be
  11532.                       allocated during  the open.   Caching  of page I/O
  11533.                       greatly  increases   the  speed  of  file  access.
  11534.                       Typically this  mode  is  used  with  single  user
  11535.                       files.   SC_FLUSH overrides  SC_BUFFER and  causes
  11536.                       the file  to be opened with no caching.  This mode
  11537.                       is generally  used with  file sharing, although it
  11538.                       is not required.
  11539.  
  11540.  
  11541.  
  11542.  
  11543.  
  11544.  
  11545.                                          167
  11546.  
  11547.  
  11548.  
  11549.  
  11550.  
  11551.  
  11552.  
  11553.  
  11554.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11555.  
  11556.  
  11557.                       Using SC_EXCLUDE  opens the file for exclusive use
  11558.                       of  this   station  (single   user).     SC_SHARED
  11559.                       overrides SC_EXCLUDE  and opens the file in multi-
  11560.                       user mode.   This  mode is used when a LAN file is
  11561.                       to be shared with other stations.
  11562.  
  11563.  
  11564.             NOTES
  11565.                       The index  expression will  be translated to upper
  11566.                       case after being read from the index file.
  11567.  
  11568.  
  11569.  
  11570.  
  11571.             EXAMPLE
  11572.  
  11573.             #include <softc.h>
  11574.             #include <sc_base.h>
  11575.  
  11576.             void main()
  11577.             {
  11578.               int idx;
  11579.  
  11580.               scdinit(20,0);
  11581.               if (scdiopenx(&idx, "UNKNOWN.IDX", SC_BUFFER) ==
  11582.             SC_SUCCESS) {
  11583.                 scdiclose(idx);
  11584.               }
  11585.               scdterm();
  11586.             }
  11587.  
  11588.  
  11589.  
  11590.  
  11591.  
  11592.  
  11593.  
  11594.  
  11595.  
  11596.  
  11597.  
  11598.  
  11599.  
  11600.  
  11601.  
  11602.  
  11603.  
  11604.  
  11605.  
  11606.  
  11607.  
  11608.  
  11609.  
  11610.  
  11611.                                          168
  11612.  
  11613.  
  11614.  
  11615.  
  11616.  
  11617.  
  11618.  
  11619.  
  11620.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11621.  
  11622.  
  11623.  
  11624.             scdnbfrsz
  11625.  
  11626.             USAGE
  11627.                       signed int scdnbfrsz(
  11628.                            signed int handle,
  11629.                            signed int *numpgs,
  11630.                            signed int command );
  11631.  
  11632.  
  11633.             PROTOTYPE IN
  11634.                       sc_base.h
  11635.  
  11636.  
  11637.             DESCRIPTION
  11638.                       scdnbfrsz  will   either  get  (SC_GETSZ)  or  set
  11639.                       (SC_SETSZ) the  maximum number  of index pages the
  11640.                       library  file  manager  can  keep  in  memory  and
  11641.                       returns it via "numpgs".  This is under control of
  11642.                       "command".
  11643.  
  11644.  
  11645.  
  11646.  
  11647.             EXAMPLE
  11648.  
  11649.             /* Get Size */
  11650.             #include <stdio.h>
  11651.             #include <softc.h>
  11652.             #include <sc_base.h>
  11653.  
  11654.             void main()
  11655.             {
  11656.               int ndx, numpgs;
  11657.  
  11658.               scdinit(20,0);
  11659.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  11660.             SC_SUCCESS) {
  11661.                 scdnbfrsz(ndx,&numpgs,SC_GETSZ) == SC_SUCCESS)
  11662.                 printf("Maximum number of pages = %d\n",numpgs);
  11663.                 scdnclose(ndx);
  11664.               }
  11665.               scdterm();
  11666.             }
  11667.  
  11668.             /* Set Size */
  11669.             #include <stdio.h>
  11670.             #include <softc.h>
  11671.             #include <sc_base.h>
  11672.  
  11673.             void main()
  11674.  
  11675.  
  11676.  
  11677.                                          169
  11678.  
  11679.  
  11680.  
  11681.  
  11682.  
  11683.  
  11684.  
  11685.  
  11686.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11687.  
  11688.  
  11689.             {
  11690.               int ndx, numpgs = 5;
  11691.  
  11692.               scdinit(20,0);
  11693.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  11694.             SC_SUCCESS) {
  11695.                 scdnbfrsz(ndx,&numpgs,SC_SETSZ);
  11696.                 printf("New max = %d\n",numpgs);
  11697.                 scdnclose(ndx);
  11698.               }
  11699.               scdterm();
  11700.             }
  11701.  
  11702.  
  11703.  
  11704.  
  11705.  
  11706.  
  11707.  
  11708.  
  11709.  
  11710.  
  11711.  
  11712.  
  11713.  
  11714.  
  11715.  
  11716.  
  11717.  
  11718.  
  11719.  
  11720.  
  11721.  
  11722.  
  11723.  
  11724.  
  11725.  
  11726.  
  11727.  
  11728.  
  11729.  
  11730.  
  11731.  
  11732.  
  11733.  
  11734.  
  11735.  
  11736.  
  11737.  
  11738.  
  11739.  
  11740.  
  11741.  
  11742.  
  11743.                                          170
  11744.  
  11745.  
  11746.  
  11747.  
  11748.  
  11749.  
  11750.  
  11751.  
  11752.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11753.  
  11754.  
  11755.  
  11756.             scdnclose 
  11757.  
  11758.             USAGE
  11759.                       signed int scdnclose(
  11760.                            signed int handle );
  11761.  
  11762.  
  11763.             PROTOTYPE IN
  11764.                       sc_base.h
  11765.  
  11766.  
  11767.             DESCRIPTION
  11768.                       scdnclose closes  an  index  file  and  frees  all
  11769.                       allocated memory associated with index file.
  11770.  
  11771.  
  11772.  
  11773.  
  11774.             EXAMPLE
  11775.  
  11776.             #include <softc.h>
  11777.             #include <sc_base.h>
  11778.  
  11779.             void main()
  11780.             {
  11781.               int ndx;
  11782.  
  11783.               scdinit(20,0);
  11784.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  11785.             SC_SUCCESS)
  11786.                 scdnclose(ndx);
  11787.               scdterm();
  11788.             }
  11789.  
  11790.  
  11791.  
  11792.  
  11793.  
  11794.  
  11795.  
  11796.  
  11797.  
  11798.  
  11799.  
  11800.  
  11801.  
  11802.  
  11803.  
  11804.  
  11805.  
  11806.  
  11807.  
  11808.  
  11809.                                          171
  11810.  
  11811.  
  11812.  
  11813.  
  11814.  
  11815.  
  11816.  
  11817.  
  11818.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11819.  
  11820.  
  11821.  
  11822.             scdncreate     
  11823.  
  11824.             USAGE
  11825.                       signed int scdncreate(
  11826.                            signed char *filename,
  11827.                            signed char keytype,
  11828.                            signed char *keyexpr,
  11829.                            signed int keylen );
  11830.  
  11831.  
  11832.             PROTOTYPE IN
  11833.                       sc_base.h
  11834.  
  11835.  
  11836.             DESCRIPTION
  11837.                       scdncreate creates  an index  file. "keyexpr" will
  11838.                       be translated  to all  upper case  when the  index
  11839.                       file is created.
  11840.  
  11841.  
  11842.                       If "keytype" is SC_CKEY, then "keyexpr" must be an
  11843.                       ASCIIZ string  consisting of  one  or  more  field
  11844.                       names from the data record. All fields included in
  11845.                       the  expression   must  be   of  type  'c'  or  be
  11846.                       translated into  type 'c'.  No check  is  made  to
  11847.                       verify this.  "keyexpr" cannot  be longer that 220
  11848.                       characters. "keylen" cannot exceed 100.
  11849.  
  11850.  
  11851.                       If "keytype" is SC_DKEY or SC_NKEY, then "keyexpr"
  11852.                       should consist  of only  one data  field. "keylen"
  11853.                       will automatically  be set  to 8 (numeric and date
  11854.                       keys are  stored as  doubles). For  both date  and
  11855.                       numeric keys "keytype" will be forced to 'n'.
  11856.  
  11857.  
  11858.                       When unique  keys are  required, OR SC_UNIQUE with
  11859.                       "keytype".
  11860.  
  11861.  
  11862.             NOTES
  11863.                       scdncreate will  create a  new index  file even if
  11864.                       one had already existed.
  11865.  
  11866.  
  11867.                       "keyexpr" is  used  by  dBASE.  "keyexpr"  is  NOT
  11868.                       checked for  validity  during  the  file  creation
  11869.                       process. Currently  only  the  scdnkmake  function
  11870.                       uses "keyexpr".
  11871.  
  11872.  
  11873.  
  11874.  
  11875.                                          172
  11876.  
  11877.  
  11878.  
  11879.  
  11880.  
  11881.  
  11882.  
  11883.  
  11884.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11885.  
  11886.  
  11887.             SEE ALSO
  11888.                       scdnkmake.
  11889.  
  11890.  
  11891.  
  11892.  
  11893.             EXAMPLE
  11894.  
  11895.             #include <sc_base.h>
  11896.  
  11897.             void main()
  11898.             {
  11899.               scdinit(20,0);
  11900.               scdncreate("TOCDATE.NDX",'c',"dtoc(date) + time",16);
  11901.               scdterm();
  11902.             }
  11903.  
  11904.  
  11905.  
  11906.  
  11907.  
  11908.  
  11909.  
  11910.  
  11911.  
  11912.  
  11913.  
  11914.  
  11915.  
  11916.  
  11917.  
  11918.  
  11919.  
  11920.  
  11921.  
  11922.  
  11923.  
  11924.  
  11925.  
  11926.  
  11927.  
  11928.  
  11929.  
  11930.  
  11931.  
  11932.  
  11933.  
  11934.  
  11935.  
  11936.  
  11937.  
  11938.  
  11939.  
  11940.  
  11941.                                          173
  11942.  
  11943.  
  11944.  
  11945.  
  11946.  
  11947.  
  11948.  
  11949.  
  11950.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11951.  
  11952.  
  11953.  
  11954.             scdnexpr  
  11955.  
  11956.             USAGE
  11957.                       signed int scdnexpr(
  11958.                            signed int handle,
  11959.                            signed char *keyexpr );
  11960.  
  11961.  
  11962.             PROTOTYPE IN
  11963.                       sc_base.h
  11964.  
  11965.  
  11966.             DESCRIPTION
  11967.                       scdnexpr gets the index key expression and returns
  11968.                       it as an ASCIIZ string into a user supplied buffer
  11969.                       "keyexpr". The user must ensure that the buffer is
  11970.                       large enough  (the key  expression length  can  be
  11971.                       determined via  a call  to scdninfo)  to hold  the
  11972.                       entire key expression.
  11973.  
  11974.  
  11975.             NOTES
  11976.                       A NULL  byte will  be appended  to the  end of the
  11977.                       expression string returned. If you are dynamically
  11978.                       allocating memory be sure to make the buffer large
  11979.                       enough.
  11980.  
  11981.  
  11982.             SEE ALSO
  11983.                       scdninfo.
  11984.  
  11985.  
  11986.  
  11987.  
  11988.             EXAMPLE
  11989.  
  11990.             #include <stdio.h>
  11991.             #include <softc.h>
  11992.             #include <sc_base.h>
  11993.  
  11994.             void main()
  11995.             {
  11996.               int ndx;
  11997.               char buffer[512];
  11998.  
  11999.               scdinit(20,0);
  12000.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  12001.             SC_SUCCESS) {
  12002.                 scdnexpr(ndx,buffer);
  12003.                 printf("key expression = %s",buffer);
  12004.  
  12005.  
  12006.  
  12007.                                          174
  12008.  
  12009.  
  12010.  
  12011.  
  12012.  
  12013.  
  12014.  
  12015.  
  12016.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12017.  
  12018.  
  12019.                 scdnclose(ndx);
  12020.               }
  12021.               scdterm();
  12022.             }
  12023.  
  12024.  
  12025.  
  12026.  
  12027.  
  12028.  
  12029.  
  12030.  
  12031.  
  12032.  
  12033.  
  12034.  
  12035.  
  12036.  
  12037.  
  12038.  
  12039.  
  12040.  
  12041.  
  12042.  
  12043.  
  12044.  
  12045.  
  12046.  
  12047.  
  12048.  
  12049.  
  12050.  
  12051.  
  12052.  
  12053.  
  12054.  
  12055.  
  12056.  
  12057.  
  12058.  
  12059.  
  12060.  
  12061.  
  12062.  
  12063.  
  12064.  
  12065.  
  12066.  
  12067.  
  12068.  
  12069.  
  12070.  
  12071.  
  12072.  
  12073.                                          175
  12074.  
  12075.  
  12076.  
  12077.  
  12078.  
  12079.  
  12080.  
  12081.  
  12082.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12083.  
  12084.  
  12085.  
  12086.             scdnflush
  12087.  
  12088.             USAGE
  12089.                       signed int scdnflush(
  12090.                            signed int handle );
  12091.  
  12092.  
  12093.             PROTOTYPE IN
  12094.                       sc_base.h
  12095.  
  12096.  
  12097.             DESCRIPTION
  12098.                       scdnflush will write the contents of the I/O cache
  12099.                       to disk.   An  I/O cache  will be used only if the
  12100.                       index  file  was  opened  with  SC_BUFFER  in  the
  12101.                       command field.
  12102.  
  12103.  
  12104.             SEE ALSO
  12105.                       scdnopenx
  12106.  
  12107.  
  12108.  
  12109.  
  12110.             EXAMPLE
  12111.  
  12112.             #include <string.h>
  12113.             #include <softc.h>
  12114.             #include <sc_base.h>
  12115.  
  12116.             void main()
  12117.             {
  12118.               int dbf, ndx;
  12119.               char *key;
  12120.               long record;
  12121.  
  12122.               scdinit(20,0);
  12123.               if (scddopenx(&dbf, "TOC.DBF", SC_BUFFER) == SC_SUCCESS) {
  12124.                 if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  12125.             SC_SUCCESS) {
  12126.                   scddfput(dbf,0,"TOC.DBF");
  12127.                   scddrput(dbf,&record,SC_ADD);
  12128.                   scdnkmake(dbf,ndx,&key);
  12129.                   scdnkadd(ndx,key,record);
  12130.                   free(key);
  12131.                   scdnflush(ndx);
  12132.                   scdnclose(ndx);
  12133.                 }
  12134.                 scddclose(dbf);
  12135.               }
  12136.  
  12137.  
  12138.  
  12139.                                          176
  12140.  
  12141.  
  12142.  
  12143.  
  12144.  
  12145.  
  12146.  
  12147.  
  12148.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12149.  
  12150.  
  12151.               scdterm();
  12152.             }
  12153.  
  12154.  
  12155.  
  12156.  
  12157.  
  12158.  
  12159.  
  12160.  
  12161.  
  12162.  
  12163.  
  12164.  
  12165.  
  12166.  
  12167.  
  12168.  
  12169.  
  12170.  
  12171.  
  12172.  
  12173.  
  12174.  
  12175.  
  12176.  
  12177.  
  12178.  
  12179.  
  12180.  
  12181.  
  12182.  
  12183.  
  12184.  
  12185.  
  12186.  
  12187.  
  12188.  
  12189.  
  12190.  
  12191.  
  12192.  
  12193.  
  12194.  
  12195.  
  12196.  
  12197.  
  12198.  
  12199.  
  12200.  
  12201.  
  12202.  
  12203.  
  12204.  
  12205.                                          177
  12206.  
  12207.  
  12208.  
  12209.  
  12210.  
  12211.  
  12212.  
  12213.  
  12214.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12215.  
  12216.  
  12217.  
  12218.             scdnindex
  12219.  
  12220.             USAGE
  12221.                       signed int scdnindex(
  12222.                            signed int datafile,
  12223.                            signed char filename,
  12224.                            signed char keytype,
  12225.                            signed char keyexpr,
  12226.                            signed char keylen );
  12227.  
  12228.  
  12229.             PROTOTYPE IN
  12230.                       sc_base.h
  12231.  
  12232.  
  12233.             DESCRIPTION
  12234.                       scdnindex will  create and  build an  dBASE  index
  12235.                       file.  A   blank  file   will  be   created  using
  12236.                       "filename", "keytype",  "keyexpr",  and  "keylen".
  12237.                       The  resultant   file  will  be  opened,  and  the
  12238.                       "datafile" will be read sequentially building keys
  12239.                       from each  data record.   The  index file  will be
  12240.                       closed at exit.  The "datafile" must be open prior
  12241.                       to the function call.
  12242.  
  12243.  
  12244.  
  12245.  
  12246.             EXAMPLE
  12247.  
  12248.             #include <sc_base.h>
  12249.  
  12250.             void main()
  12251.             {
  12252.               int dbf;
  12253.  
  12254.               scdinit(20,0);
  12255.               if (scddopenx(&dbf, "TOC.DBF", SC_BUFFER) == SC_SUCCESS) {
  12256.                 scdnindex(dbf, "TOCNAME.NDX", SC_CKEY, "NAME", 64);
  12257.                 scddclose(dbf);
  12258.               }
  12259.               scdterm();
  12260.             }
  12261.  
  12262.  
  12263.  
  12264.  
  12265.  
  12266.  
  12267.  
  12268.  
  12269.  
  12270.  
  12271.                                          178
  12272.  
  12273.  
  12274.  
  12275.  
  12276.  
  12277.  
  12278.  
  12279.  
  12280.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12281.  
  12282.  
  12283.  
  12284.             scdninfo  
  12285.  
  12286.             USAGE
  12287.                       signed int scdninfo(
  12288.                            signed int handle,
  12289.                            SC_NDXINFO *info );
  12290.  
  12291.  
  12292.             PROTOTYPE IN
  12293.                       sc_base.h
  12294.  
  12295.  
  12296.             DESCRIPTION
  12297.                       scdninfo gets  the  filename  of  the  index  file
  12298.                       associated with  "handle", the index key type, the
  12299.                       maximum index  key length,  and the  length of the
  12300.                       index key expression.
  12301.  
  12302.  
  12303.                       typedef struct {
  12304.                         signed char fname[80]; /* file name */
  12305.                         signed char keytype;   /* key type */
  12306.                                        /* (C or N) */
  12307.                         signed char keylen;    /* key length */
  12308.                         signed char exprlen;   /* expression */
  12309.                                        /* length */
  12310.                         SC_FLAGS flags;   /* misc. flags */
  12311.                       } SC_NDXINFO;
  12312.  
  12313.  
  12314.             NOTES
  12315.                       If  you   are  using   the  expression  length  to
  12316.                       dynamically  allocate   memory  to  hold  the  key
  12317.                       expression be sure to add one to the length before
  12318.                       allocation.
  12319.  
  12320.  
  12321.             SEE ALSO
  12322.                       scdnopenx.
  12323.  
  12324.  
  12325.  
  12326.  
  12327.             EXAMPLE
  12328.  
  12329.             #include <stdio.h>
  12330.             #include <softc.h>
  12331.             #include <sc_base.h>
  12332.  
  12333.             void main()
  12334.  
  12335.  
  12336.  
  12337.                                          179
  12338.  
  12339.  
  12340.  
  12341.  
  12342.  
  12343.  
  12344.  
  12345.  
  12346.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12347.  
  12348.  
  12349.             {
  12350.               int ndx;
  12351.               SC_NDXINFO info;
  12352.  
  12353.               scdinit(20,0);
  12354.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  12355.             SC_SUCCESS) {
  12356.                 scdninfo(ndx,&info);
  12357.                 printf("File name = %s\n",info.fname);
  12358.                 printf("Index key type = %c\n",info.keytype);
  12359.                 printf("Maximum key length = %d\n",info.keylen);
  12360.                 printf("Key expression length = %d\n",info.exprlen);
  12361.                 scdnclose(ndx);
  12362.               }
  12363.               scdterm();
  12364.             }
  12365.  
  12366.  
  12367.  
  12368.  
  12369.  
  12370.  
  12371.  
  12372.  
  12373.  
  12374.  
  12375.  
  12376.  
  12377.  
  12378.  
  12379.  
  12380.  
  12381.  
  12382.  
  12383.  
  12384.  
  12385.  
  12386.  
  12387.  
  12388.  
  12389.  
  12390.  
  12391.  
  12392.  
  12393.  
  12394.  
  12395.  
  12396.  
  12397.  
  12398.  
  12399.  
  12400.  
  12401.  
  12402.  
  12403.                                          180
  12404.  
  12405.  
  12406.  
  12407.  
  12408.  
  12409.  
  12410.  
  12411.  
  12412.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12413.  
  12414.  
  12415.  
  12416.             scdnkadd  
  12417.  
  12418.             USAGE
  12419.                       signed int scdnkadd(
  12420.                            signed int handle,
  12421.                            void *key,
  12422.                            signed long recno );
  12423.  
  12424.  
  12425.             PROTOTYPE IN
  12426.                       sc_base.h
  12427.  
  12428.  
  12429.             DESCRIPTION
  12430.                       scdnkadd  will   add  "key"   to  the  index  file
  12431.                       specified by  "handle". "recno" is the data record
  12432.                       number to  be  associated  with  "key"  (the  data
  12433.                       record pointed  to by  "recno" must exist prior to
  12434.                       calling scdnkadd).
  12435.  
  12436.  
  12437.             NOTES
  12438.                       When adding character keys it is not necessary  to
  12439.                       pad  the key string to size with spaces (" "), the
  12440.                       function will automatically do this for you.
  12441.  
  12442.  
  12443.             SEE ALSO
  12444.                       scdnkdate, scdnkmake.
  12445.  
  12446.  
  12447.  
  12448.  
  12449.             EXAMPLE
  12450.  
  12451.             #include <string.h>
  12452.             #include <softc.h>
  12453.             #include <sc_base.h>
  12454.  
  12455.             void main()
  12456.             {
  12457.               int dbf, ndx;
  12458.               char name[65];
  12459.               long recno;
  12460.  
  12461.               scdinit(20,0);
  12462.               if (scddopenx(&dbf, "TOC.DBF", 0) == SC_SUCCESS) {
  12463.                 if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  12464.             SC_SUCCESS) {
  12465.                   strcpy(name,"XYZ.BAK");
  12466.  
  12467.  
  12468.  
  12469.                                          181
  12470.  
  12471.  
  12472.  
  12473.  
  12474.  
  12475.  
  12476.  
  12477.  
  12478.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12479.  
  12480.  
  12481.                   scddfput(dbf,0,name);
  12482.                   if (scddrput(dbf, &recno, SC_ADD) == SC_SUCCESS)
  12483.                     scdnkadd(ndx,name,recno);
  12484.                   scdnclose(ndx);
  12485.                 }
  12486.                 scddclose(dbf)
  12487.               }
  12488.               scdterm();
  12489.             }
  12490.  
  12491.  
  12492.  
  12493.  
  12494.  
  12495.  
  12496.  
  12497.  
  12498.  
  12499.  
  12500.  
  12501.  
  12502.  
  12503.  
  12504.  
  12505.  
  12506.  
  12507.  
  12508.  
  12509.  
  12510.  
  12511.  
  12512.  
  12513.  
  12514.  
  12515.  
  12516.  
  12517.  
  12518.  
  12519.  
  12520.  
  12521.  
  12522.  
  12523.  
  12524.  
  12525.  
  12526.  
  12527.  
  12528.  
  12529.  
  12530.  
  12531.  
  12532.  
  12533.  
  12534.  
  12535.                                          182
  12536.  
  12537.  
  12538.  
  12539.  
  12540.  
  12541.  
  12542.  
  12543.  
  12544.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12545.  
  12546.  
  12547.  
  12548.             scdnkbot  
  12549.  
  12550.             USAGE
  12551.                       signed int scdnkbot(
  12552.                            signed int handle,
  12553.                            void *key,
  12554.                            signed long *recno );
  12555.  
  12556.  
  12557.             PROTOTYPE IN
  12558.                       sc_base.h
  12559.  
  12560.  
  12561.             DESCRIPTION
  12562.                       scdnkbot will  set the  current key pointer to the
  12563.                       last logical  key in  the index and return the key
  12564.                       value  "key"   and  data   record  number  "recno"
  12565.                       associated with the new current key.
  12566.  
  12567.  
  12568.             NOTES
  12569.                       The user  must ensure  that  the  buffer  used  to
  12570.                       return the  key is large enough to hold the entire
  12571.                       key.  The   maximum  length  of  the  key  can  be
  12572.                       determined via a call to scdninfo.
  12573.  
  12574.  
  12575.                       Numeric  keys   are  returned   as  doubles,   and
  12576.                       character keys are returned as strings.
  12577.  
  12578.  
  12579.             SEE ALSO
  12580.                       scdninfo.
  12581.  
  12582.  
  12583.  
  12584.  
  12585.             EXAMPLE
  12586.  
  12587.             /*  Character Key Example */
  12588.             #include <stdio.h>
  12589.             #include <softc.h>
  12590.             #include <sc_base.h>
  12591.  
  12592.             void main()
  12593.             {
  12594.               int ndx;
  12595.               char name[65];
  12596.               long recno;
  12597.  
  12598.  
  12599.  
  12600.  
  12601.                                          183
  12602.  
  12603.  
  12604.  
  12605.  
  12606.  
  12607.  
  12608.  
  12609.  
  12610.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12611.  
  12612.  
  12613.               scdinit(20,0);
  12614.               if (scdnopenx(&ndx,"TOCNAME.NDX",SC_BUFFER) == SC_SUCCESS)
  12615.             {
  12616.                 name[64] = 0;
  12617.                 scdnkbot(ndx,name,&recno);
  12618.                 printf("%s %ld\n",name,recno);
  12619.                 scdnclose(ndx);
  12620.               }
  12621.               scdterm();
  12622.             }
  12623.  
  12624.             /*  Numeric Key Example  */
  12625.             #include <stdio.h>
  12626.             #include <softc.h>
  12627.             #include <sc_base.h>
  12628.  
  12629.             void main()
  12630.             {
  12631.               int ndx;
  12632.               double length;
  12633.               long recno;
  12634.  
  12635.               scdinit(20,0);
  12636.               if (scdnopenx(&ndx,"TOCLNGTH.NDX",SC_BUFFER) ==
  12637.             SC_SUCCESS) {
  12638.                 scdnkbot(ndx,&length,&recno);
  12639.                 printf("%lf %ld\n",length,recno);
  12640.                 scdnclose(ndx);
  12641.               }
  12642.               scdterm();
  12643.             }
  12644.  
  12645.  
  12646.  
  12647.  
  12648.  
  12649.  
  12650.  
  12651.  
  12652.  
  12653.  
  12654.  
  12655.  
  12656.  
  12657.  
  12658.  
  12659.  
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665.  
  12666.  
  12667.                                          184
  12668.  
  12669.  
  12670.  
  12671.  
  12672.  
  12673.  
  12674.  
  12675.  
  12676.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12677.  
  12678.  
  12679.  
  12680.             scdnkcur  
  12681.  
  12682.             USAGE
  12683.                       signed int scdnkcur(
  12684.                            signed int handle,
  12685.                            void *key,
  12686.                            signed long *recno );
  12687.  
  12688.  
  12689.             PROTOTYPE IN
  12690.                       sc_base.h
  12691.  
  12692.  
  12693.             DESCRIPTION
  12694.                       scdnkcur will  return the key value "key" and data
  12695.                       record number  "recno" associated with the current
  12696.                       key in the index file.
  12697.  
  12698.  
  12699.                       The current  key pointer  must be set by a call to
  12700.                       either scdnkfind,  scdnktop, scdnkbot,  scdnknext,
  12701.                       or scdnkprev before calling scdnkcur.
  12702.  
  12703.  
  12704.             NOTES
  12705.                       The user  must ensure  that  the  buffer  used  to
  12706.                       return the  key is large enough to hold the entire
  12707.                       key.  The   maximum  length  of  the  key  can  be
  12708.                       determined via a call to scdninfo.
  12709.  
  12710.  
  12711.             SEE ALSO
  12712.                       scdninfo, scdnkfind, scdnktop, scdnkbot,
  12713.                       scdnknext, scdnkprev.
  12714.  
  12715.  
  12716.  
  12717.  
  12718.             EXAMPLE
  12719.  
  12720.             #include <stdio.h>
  12721.             #include <softc.h>
  12722.             #include <sc_base.h>
  12723.  
  12724.             void main()
  12725.             {
  12726.               int ndx;
  12727.               char name[65], nam[65];
  12728.               long recno, recn;
  12729.  
  12730.  
  12731.  
  12732.  
  12733.                                          185
  12734.  
  12735.  
  12736.  
  12737.  
  12738.  
  12739.  
  12740.  
  12741.  
  12742.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12743.  
  12744.  
  12745.               scdinit(20,0);
  12746.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  12747.             SC_SUCCESS) {
  12748.                 name[64] = 0;
  12749.                 nam[64] = 0;
  12750.                 scdnktop(ndx,name,&recno);
  12751.                 scdnkcur(ndx,nam,&recn);
  12752.                 printf("%s %s %ld %ld\n",name,nam,recno,recn);
  12753.                 scdnclose(ndx);
  12754.               }
  12755.               scdterm();
  12756.             }
  12757.  
  12758.  
  12759.  
  12760.  
  12761.  
  12762.  
  12763.  
  12764.  
  12765.  
  12766.  
  12767.  
  12768.  
  12769.  
  12770.  
  12771.  
  12772.  
  12773.  
  12774.  
  12775.  
  12776.  
  12777.  
  12778.  
  12779.  
  12780.  
  12781.  
  12782.  
  12783.  
  12784.  
  12785.  
  12786.  
  12787.  
  12788.  
  12789.  
  12790.  
  12791.  
  12792.  
  12793.  
  12794.  
  12795.  
  12796.  
  12797.  
  12798.  
  12799.                                          186
  12800.  
  12801.  
  12802.  
  12803.  
  12804.  
  12805.  
  12806.  
  12807.  
  12808.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12809.  
  12810.  
  12811.  
  12812.             scdnkdate 
  12813.  
  12814.             USAGE
  12815.                       signed int scdnkdate(
  12816.                            double *key,
  12817.                            signed char *string,
  12818.                            signed int format );
  12819.  
  12820.  
  12821.             PROTOTYPE IN
  12822.                       sc_base.h
  12823.  
  12824.  
  12825.             DESCRIPTION
  12826.                       scdnkdate will  translate an  ASCIIZ  date  string
  12827.                       "string" of style "format" into a valid dBASE date
  12828.                       key "key".
  12829.  
  12830.  
  12831.                       Date string styles:
  12832.                       SC_GREGOR   mm/dd/yy
  12833.                       SC_GREGORL  mm/dd/yyyy
  12834.                       SC_JULIAN   yyyy/ddd
  12835.                       SC_YMD      yyyymmdd
  12836.                       SC_DMY      ddmmyy
  12837.  
  12838.  
  12839.  
  12840.             EXAMPLE
  12841.  
  12842.             #include <stdio.h>
  12843.             #include <softc.h>
  12844.             #include <sc_base.h>
  12845.  
  12846.             void main()
  12847.             {
  12848.               double key;
  12849.  
  12850.               scdinit(20,0);
  12851.               scdnkdate(&key,"19890801");
  12852.               printf("%lf",key);
  12853.               scdterm();
  12854.             }
  12855.  
  12856.  
  12857.  
  12858.  
  12859.  
  12860.  
  12861.  
  12862.  
  12863.  
  12864.  
  12865.                                          187
  12866.  
  12867.  
  12868.  
  12869.  
  12870.  
  12871.  
  12872.  
  12873.  
  12874.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12875.  
  12876.  
  12877.  
  12878.             scdnkdel  
  12879.  
  12880.             USAGE
  12881.                       signed int scdnkdel(
  12882.                            signed int handle,
  12883.                            void *key,
  12884.                            signed long recno );
  12885.  
  12886.  
  12887.             PROTOTYPE IN
  12888.                       sc_base.h
  12889.  
  12890.  
  12891.             DESCRIPTION
  12892.                       scdnkdel will  remove "key"  from the  index  file
  12893.                       specified by  "handle". "recno" is used along with
  12894.                       "key" to  ensure that  the  proper  key  has  been
  12895.                       removed from the index file.
  12896.  
  12897.  
  12898.             NOTES
  12899.                       When deleting  character keys  it is not necessary
  12900.                       to  pad  the key string to size with spaces (" "),
  12901.                       the function will automatically do this for you.
  12902.  
  12903.  
  12904.             SEE ALSO
  12905.                       scdnkadd.
  12906.  
  12907.  
  12908.  
  12909.  
  12910.             EXAMPLE
  12911.  
  12912.             #include <string.h>
  12913.             #include <softc.h>
  12914.             #include <sc_base.h>
  12915.  
  12916.             void main()
  12917.             {
  12918.               int ndx;
  12919.               char date[16];
  12920.               long recno;
  12921.  
  12922.               scdinit(20,0);
  12923.               if (scdnopenx(&ndx, "TOCDATE.NDX", SC_BUFFER) ==
  12924.             SC_SUCCESS) {
  12925.                 strcpy(date,"12/02/8809:33:01");
  12926.                 recno = 71L;
  12927.                 scdnkdel(ndx,date,recno);
  12928.  
  12929.  
  12930.  
  12931.                                          188
  12932.  
  12933.  
  12934.  
  12935.  
  12936.  
  12937.  
  12938.  
  12939.  
  12940.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  12941.  
  12942.  
  12943.                 scdnclose(ndx);
  12944.               }
  12945.               scdterm();
  12946.             }
  12947.  
  12948.  
  12949.  
  12950.  
  12951.  
  12952.  
  12953.  
  12954.  
  12955.  
  12956.  
  12957.  
  12958.  
  12959.  
  12960.  
  12961.  
  12962.  
  12963.  
  12964.  
  12965.  
  12966.  
  12967.  
  12968.  
  12969.  
  12970.  
  12971.  
  12972.  
  12973.  
  12974.  
  12975.  
  12976.  
  12977.  
  12978.  
  12979.  
  12980.  
  12981.  
  12982.  
  12983.  
  12984.  
  12985.  
  12986.  
  12987.  
  12988.  
  12989.  
  12990.  
  12991.  
  12992.  
  12993.  
  12994.  
  12995.  
  12996.  
  12997.                                          189
  12998.  
  12999.  
  13000.  
  13001.  
  13002.  
  13003.  
  13004.  
  13005.  
  13006.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13007.  
  13008.  
  13009.  
  13010.             scdnkfind 
  13011.  
  13012.             USAGE
  13013.                       signed int scdnkfind(
  13014.                            signed int handle,
  13015.                            void *key,
  13016.                            signed long *recno,
  13017.                            signed int method );
  13018.  
  13019.  
  13020.             PROTOTYPE IN
  13021.                       sc_base.h
  13022.  
  13023.  
  13024.             DESCRIPTION
  13025.                       scdnkfind  supports   two   key   search   methods
  13026.                       (determined by "method"): SC_EXACT - find an exact
  13027.                       match with "key" and "recno", and SC_FIRST - finds
  13028.                       the first logical occurrence of "key" in the index
  13029.                       and returns  the associated  record number "recno"
  13030.                       if found.
  13031.  
  13032.  
  13033.                       If a  match cannot  be found, the current key will
  13034.                       be  the   physical  key  which  would  immediately
  13035.                       precede "key".  The current  key's value  and data
  13036.                       record  number  will  be  returned  in  "key"  and
  13037.                       "recno".
  13038.  
  13039.  
  13040.             NOTES
  13041.                       The user  must ensure  that  the  buffer  used  to
  13042.                       return the  key is large enough to hold the entire
  13043.                       key.  The   maximum  length  of  the  key  can  be
  13044.                       determined via a call to scdninfo.
  13045.  
  13046.  
  13047.                       When searching  using character  keys  it  is  not
  13048.                       necessary   to   pad   the key string to size with
  13049.                       spaces ("  "), the  function will automatically do
  13050.                       this for you.
  13051.  
  13052.  
  13053.                       Searching for  partial keys can be accomplished by
  13054.                       using the  SC_FIRST method.  For example,  you are
  13055.                       using a fifteen character key size and you want to
  13056.                       find  the   first  entry   where  the  first  five
  13057.                       characters are  "ABCDE". All  you need  do is copy
  13058.                       that five  character ASCIIZ  string into  your key
  13059.                       buffer and  then call scdnkfind. The function will
  13060.  
  13061.  
  13062.  
  13063.                                          190
  13064.  
  13065.  
  13066.  
  13067.  
  13068.  
  13069.  
  13070.  
  13071.  
  13072.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13073.  
  13074.  
  13075.                       space pad  to  length  and  then  find  the  first
  13076.                       matching entry.
  13077.  
  13078.  
  13079.                       Numeric  keys   are  returned   as  doubles,   and
  13080.                       character keys are returned as strings.
  13081.  
  13082.  
  13083.             SEE ALSO
  13084.                       scdninfo.
  13085.  
  13086.  
  13087.  
  13088.  
  13089.             EXAMPLE
  13090.  
  13091.             #include <string.h>
  13092.             #include <softc.h>
  13093.             #include <sc_base.h>
  13094.  
  13095.             void main()
  13096.             {
  13097.               int ndx;
  13098.               char key[16];
  13099.               long recno;
  13100.  
  13101.               scdinit(20,0);
  13102.               if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  13103.             SC_SUCCESS) {
  13104.                 strcpy(key,"ABCDE");
  13105.                 recno = 7L;
  13106.                 if (scdnkfind(ndx,key,&recno,SC_FIRST) != SC_SUCCESS
  13107.                   puts(scemsg());
  13108.                 scddclose(ndx);
  13109.               }
  13110.               scdterm();
  13111.             }
  13112.  
  13113.  
  13114.  
  13115.  
  13116.  
  13117.  
  13118.  
  13119.  
  13120.  
  13121.  
  13122.  
  13123.  
  13124.  
  13125.  
  13126.  
  13127.  
  13128.  
  13129.                                          191
  13130.  
  13131.  
  13132.  
  13133.  
  13134.  
  13135.  
  13136.  
  13137.  
  13138.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13139.  
  13140.  
  13141.  
  13142.             scdnkmake 
  13143.  
  13144.             USAGE
  13145.                       signed int scdnkmake(
  13146.                            signed int datahandle,
  13147.                            signed int indexhandle,
  13148.                            void **key );
  13149.  
  13150.  
  13151.             PROTOTYPE IN
  13152.                       sc_base.h
  13153.  
  13154.  
  13155.             DESCRIPTION
  13156.                       scdnkmake will  build an  index key  using the key
  13157.                       expression  of   the  index   file  specified   by
  13158.                       "indexhandle" and  the data  found in  the  output
  13159.                       buffer of the data file "datahandle". Memory space
  13160.                       for the "key" will be allocated and the address of
  13161.                       this block will be returned.
  13162.  
  13163.  
  13164.                       The key  expression can consist of either the data
  13165.                       field name  or one  of five  dBASE functions  or a
  13166.                       combination thereof.  Data field  types  of  date,
  13167.                       numeric, or character are allowed. dBASE functions
  13168.                       dtoc, left,  right, str,  and substr are currently
  13169.                       supported by scdnkmake.
  13170.  
  13171.  
  13172.                       Following is  a  brief  description  of  the  five
  13173.                       expression functions:
  13174.  
  13175.  
  13176.                       dtoc will  convert data  from a  date field  to an
  13177.                       ASCIIZ string of the format mm/dd/yy. Syntax is:
  13178.  
  13179.  
  13180.                       dtoc(field_name)
  13181.  
  13182.  
  13183.                       left will  return the  left portion of a character
  13184.                       field  as   an  ASCIIZ   string.  The   number  of
  13185.                       characters returned  is specified  after the field
  13186.                       name. Syntax is:
  13187.  
  13188.  
  13189.                       left(field_name,number)
  13190.  
  13191.  
  13192.  
  13193.  
  13194.  
  13195.                                          192
  13196.  
  13197.  
  13198.  
  13199.  
  13200.  
  13201.  
  13202.  
  13203.  
  13204.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13205.  
  13206.  
  13207.                       right will return the right portion of a character
  13208.                       field  as   an  ASCIIZ   string.  The   number  of
  13209.                       characters returned  is specified  after the field
  13210.                       name. This  is a  count from the right side of the
  13211.                       field. Syntax is:
  13212.  
  13213.  
  13214.                       right(field_name,number)
  13215.  
  13216.  
  13217.                       str will  convert a  numeric field  to  an  ASCIIZ
  13218.                       string. The  total length  of the  string and  the
  13219.                       number of  decimal places are optional parameters.
  13220.                       The default  string length is 10 and the number of
  13221.                       decimal places is 0. Syntax is:
  13222.  
  13223.  
  13224.                       str(field_name,length,decimal_places)
  13225.  
  13226.  
  13227.                       substr  will   return  the  middle  portion  of  a
  13228.                       character field.  The  starting  offset  into  the
  13229.                       field is  a  required  parameter.  The  number  of
  13230.                       characters to  be used  is an  optional  parameter
  13231.                       whose default value is the remainder of the field.
  13232.                       Syntax is:
  13233.  
  13234.  
  13235.                       substr(field_name,start,count)
  13236.  
  13237.  
  13238.                       An example of a more complex key expression:
  13239.  
  13240.  
  13241.                       right(dtoc(date),2)+left(dtoc(date,2)
  13242.  
  13243.  
  13244.                       This expression would cause scdnkmake to create an
  13245.                       index key  string consisting of the year and month
  13246.                       ("yymm"). For example if date equals "2/13/89" the
  13247.                       resultant key would be "8902".
  13248.  
  13249.  
  13250.             NOTES
  13251.                       For key  expressions consisting  of only  one data
  13252.                       field scdnkmake  is probably  an overkill. You can
  13253.                       easily generate these keys yourself. See scdnkdate
  13254.                       for information on date string to key translation.
  13255.                       scdnkmake is  a fairly  large module  and  if  not
  13256.                       needed probably  should not be used. This function
  13257.  
  13258.  
  13259.  
  13260.  
  13261.                                          193
  13262.  
  13263.  
  13264.  
  13265.  
  13266.  
  13267.  
  13268.  
  13269.  
  13270.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13271.  
  13272.  
  13273.                       is best  used when  the  key  expression  is  more
  13274.                       complex.
  13275.  
  13276.  
  13277.                       Memory is  allocated for  the generated key and it
  13278.                       is the  responsibility of  the caller to free this
  13279.                       memory when finished.
  13280.  
  13281.  
  13282.             SEE ALSO
  13283.                       scdncreate, scdnkdate.
  13284.  
  13285.  
  13286.  
  13287.  
  13288.             EXAMPLE
  13289.  
  13290.             #include <sc_base.h>
  13291.  
  13292.             void main()
  13293.             {
  13294.               int ndx, dbf;
  13295.               char *key;
  13296.               long recno;
  13297.  
  13298.               scdinit(20,0);
  13299.               if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  13300.                 if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) ==
  13301.             SC_SUCCESS) {
  13302.                   scddfput(dbf,0,"HELLO.C");
  13303.                   scddrput(dbf,&recno,SC_ADD);
  13304.                   scdnkmake(dbf,ndx,(void **) &key);
  13305.                   scdnkadd(ndx,key,recno);
  13306.                   free(key);         /* free memory allocated for key */
  13307.                   scdnclose(ndx);
  13308.                 }
  13309.                 scddclose(dbf);
  13310.               }
  13311.               scdterm();
  13312.             }
  13313.  
  13314.  
  13315.  
  13316.  
  13317.  
  13318.  
  13319.  
  13320.  
  13321.  
  13322.  
  13323.  
  13324.  
  13325.  
  13326.  
  13327.                                          194
  13328.  
  13329.  
  13330.  
  13331.  
  13332.  
  13333.  
  13334.  
  13335.  
  13336.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13337.  
  13338.  
  13339.  
  13340.             scdnknext 
  13341.  
  13342.             USAGE
  13343.                       signed int scdnknext(
  13344.                            signed int handle,
  13345.                            void *key,
  13346.                            signed long *recno );
  13347.  
  13348.  
  13349.             PROTOTYPE IN
  13350.                       sc_base.h
  13351.  
  13352.  
  13353.             DESCRIPTION
  13354.                       scdnknext  will  increment  the  key  pointer  and
  13355.                       return the  key value "key" and data record number
  13356.                       "recno" associated with the new current key.
  13357.  
  13358.  
  13359.                       If scdnknext  is called  immediately after opening
  13360.                       the index  file the  first  logical  key  will  be
  13361.                       returned.
  13362.  
  13363.  
  13364.             NOTES
  13365.                       The user  must ensure  that  the  buffer  used  to
  13366.                       return the  key is large enough to hold the entire
  13367.                       key.  The   maximum  length  of  the  key  can  be
  13368.                       determined via a call to scdninfo.
  13369.  
  13370.  
  13371.                       Numeric  keys   are  returned   as  doubles,   and
  13372.                       character keys are returned as strings.
  13373.  
  13374.  
  13375.             SEE ALSO
  13376.                       scdninfo.
  13377.  
  13378.  
  13379.  
  13380.  
  13381.             EXAMPLE
  13382.  
  13383.             /*  Character Key Example     */
  13384.             #include <stdio.h>
  13385.             #include <softc.h>
  13386.             #include <sc_base.h>
  13387.  
  13388.             void main()
  13389.             {
  13390.  
  13391.  
  13392.  
  13393.                                          195
  13394.  
  13395.  
  13396.  
  13397.  
  13398.  
  13399.  
  13400.  
  13401.  
  13402.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13403.  
  13404.  
  13405.               int ndx;
  13406.               char name[65];
  13407.               long recno;
  13408.  
  13409.               scdinit(20,0);
  13410.               if (scdnopenx(&ndx,"TOCNAME.NDX",SC_BUFFER) == SC_SUCCESS)
  13411.             {
  13412.                 scdnknext(ndx,name,&recno);    /* return first key */
  13413.                 printf("%s %ld\n",name,recno);
  13414.                 scdnclose(ndx);
  13415.               }
  13416.               scdterm();
  13417.             }
  13418.  
  13419.             /*  Numeric Key Example  */
  13420.             #include <stdio.h>
  13421.             #include <softc.h>
  13422.             #include <sc_base.h>
  13423.  
  13424.             void main()
  13425.             {
  13426.               int ndx;
  13427.               double length;
  13428.               long recno;
  13429.  
  13430.               scdinit(20,0);
  13431.               if (scdnopenx(&ndx,"TOCLNGTH.NDX",SC_BUFFER) ==
  13432.             SC_SUCCESS) {
  13433.                 scdnknext(ndx,&length,&recno); /* return first key */
  13434.                 printf("%lf %ld\n",length,recno);
  13435.                 scdnclose(ndx);
  13436.               }
  13437.               scdterm();
  13438.             }
  13439.  
  13440.  
  13441.  
  13442.  
  13443.  
  13444.  
  13445.  
  13446.  
  13447.  
  13448.  
  13449.  
  13450.  
  13451.  
  13452.  
  13453.  
  13454.  
  13455.  
  13456.  
  13457.  
  13458.  
  13459.                                          196
  13460.  
  13461.  
  13462.  
  13463.  
  13464.  
  13465.  
  13466.  
  13467.  
  13468.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13469.  
  13470.  
  13471.  
  13472.             scdnkprev 
  13473.  
  13474.             USAGE
  13475.                       signed int scdnkprev(
  13476.                            signed int handle,
  13477.                            void *key,
  13478.                            signed long *recno );
  13479.  
  13480.  
  13481.             PROTOTYPE IN
  13482.                       sc_base.h
  13483.  
  13484.  
  13485.             DESCRIPTION
  13486.                       scdnkprev  will  decrement  the  key  pointer  and
  13487.                       return the  key value "key" and data record number
  13488.                       "recno" associated with the new current key.
  13489.  
  13490.  
  13491.                       If scdnkprev  is called  immediately after opening
  13492.                       the index  file  the  last  logical  key  will  be
  13493.                       returned.
  13494.  
  13495.  
  13496.             NOTES
  13497.                       The user  must ensure  that  the  buffer  used  to
  13498.                       return the  key is large enough to hold the entire
  13499.                       key.  The   maximum  length  of  the  key  can  be
  13500.                       determined via a call to scdninfo.
  13501.  
  13502.  
  13503.                       Numeric  keys   are  returned   as  doubles,   and
  13504.                       character keys are returned as strings.
  13505.  
  13506.  
  13507.             SEE ALSO
  13508.                       scdninfo.
  13509.  
  13510.  
  13511.  
  13512.  
  13513.             EXAMPLE
  13514.  
  13515.             /*  Character Key Example  */
  13516.             #include <stdio.h>
  13517.             #include <softc.h>
  13518.             #include <sc_base.h>
  13519.  
  13520.             void main()
  13521.             {
  13522.  
  13523.  
  13524.  
  13525.                                          197
  13526.  
  13527.  
  13528.  
  13529.  
  13530.  
  13531.  
  13532.  
  13533.  
  13534.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13535.  
  13536.  
  13537.               int ndx;
  13538.               char name[65];
  13539.               long recno;
  13540.  
  13541.               scdinit(20,0);
  13542.               if (scdnopenx(&ndx,"TOCNAME.NDX",SC_BUFFER) == SC_SUCCESS)
  13543.             {
  13544.                 name[64] = 0;
  13545.                 scdnkprev(ndx,name,&recno);    /* get last key */
  13546.                 printf("%s %ld\n",name,recno);
  13547.                 scdnclose(ndx);
  13548.               }
  13549.               scdterm();
  13550.             }
  13551.  
  13552.             /*  Numeric Key Example  */
  13553.             #include <stdio.h>
  13554.             #include <softc.h>
  13555.             #include <sc_base.h>
  13556.  
  13557.             void main()
  13558.             {
  13559.               int ndx;
  13560.               double length;
  13561.               long recno;
  13562.  
  13563.               scdinit(20,0);
  13564.               if (scdnopenx(&ndx,"TOCLNGTH.NDX",SC_BUFFER) ==
  13565.             SC_SUCCESS) {
  13566.                 scdnkprev(ndx,&length,&recno); /* get last key */
  13567.                 printf("%lf %ld\n",length,recno);
  13568.                 scdnclose(ndx);
  13569.               }
  13570.               scdterm();
  13571.             }
  13572.  
  13573.  
  13574.  
  13575.  
  13576.  
  13577.  
  13578.  
  13579.  
  13580.  
  13581.  
  13582.  
  13583.  
  13584.  
  13585.  
  13586.  
  13587.  
  13588.  
  13589.  
  13590.  
  13591.                                          198
  13592.  
  13593.  
  13594.  
  13595.  
  13596.  
  13597.  
  13598.  
  13599.  
  13600.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13601.  
  13602.  
  13603.  
  13604.             scdnktop  
  13605.  
  13606.             USAGE
  13607.                       signed int scdnktop(
  13608.                            signed int handle,
  13609.                            void *key,
  13610.                            signed long *recno );
  13611.  
  13612.  
  13613.             PROTOTYPE IN
  13614.                       sc_base.h
  13615.  
  13616.  
  13617.             DESCRIPTION
  13618.                       scdnktop will  set the  current key pointer to the
  13619.                       first logical  key in the index and return the key
  13620.                       value  "key"   and  data   record  number  "recno"
  13621.                       associated with the new current key.
  13622.  
  13623.  
  13624.             NOTES
  13625.                       The user  must ensure  that  the  buffer  used  to
  13626.                       return the  key is large enough to hold the entire
  13627.                       key.  The   maximum  length  of  the  key  can  be
  13628.                       determined via a call to scdninfo.
  13629.  
  13630.  
  13631.                       Numeric  keys   are  returned   as  doubles,   and
  13632.                       character keys are returned as strings.
  13633.  
  13634.  
  13635.             SEE ALSO
  13636.                       scdninfo.
  13637.  
  13638.  
  13639.  
  13640.  
  13641.             EXAMPLE
  13642.  
  13643.             /*  Character Key Example  */
  13644.             #include <stdio.h>
  13645.             #include <softc.h>
  13646.             #include <sc_base.h>
  13647.  
  13648.             void main()
  13649.             {
  13650.               int ndx;
  13651.               char name[65];
  13652.               long recno;
  13653.  
  13654.  
  13655.  
  13656.  
  13657.                                          199
  13658.  
  13659.  
  13660.  
  13661.  
  13662.  
  13663.  
  13664.  
  13665.  
  13666.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13667.  
  13668.  
  13669.               scdinit(20,0);
  13670.               if (scdnopenx(&ndx,"TOCNAME.NDX",SC_BUFFER) == SC_SUCCESS)
  13671.             {
  13672.                 name[64] = 0;
  13673.                 scdnktop(ndx,name,&recno);
  13674.                 printf("%s %ld\n",name,recno);
  13675.                 scdnclose(ndx);
  13676.               }
  13677.               scdterm();
  13678.             }
  13679.  
  13680.             /*  Numeric Key Example  */
  13681.             #include <stdio.h>
  13682.             #include <softc.h>
  13683.             #include <sc_base.h>
  13684.  
  13685.             void main()
  13686.             {
  13687.               int ndx;
  13688.               double length;
  13689.               long recno;
  13690.  
  13691.               scdinit(20,0);
  13692.               if (scdnopenx(&ndx,"TOCLNGTH.NDX",SC_BUFFER) ==
  13693.             SC_SUCCESS) {
  13694.                 scdnktop(ndx,&length,&recno);
  13695.                 printf("%lf %ld\n",length,recno);
  13696.                 scdnclose(ndx);
  13697.               }
  13698.               scdterm();
  13699.             }
  13700.  
  13701.  
  13702.  
  13703.  
  13704.  
  13705.  
  13706.  
  13707.  
  13708.  
  13709.  
  13710.  
  13711.  
  13712.  
  13713.  
  13714.  
  13715.  
  13716.  
  13717.  
  13718.  
  13719.  
  13720.  
  13721.  
  13722.  
  13723.                                          200
  13724.  
  13725.  
  13726.  
  13727.  
  13728.  
  13729.  
  13730.  
  13731.  
  13732.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13733.  
  13734.  
  13735.  
  13736.             scdnopenx 
  13737.  
  13738.             USAGE
  13739.                       signed int scdnopenx(
  13740.                            signed int *handle,
  13741.                            signed char *filename,
  13742.                            signed int command );
  13743.  
  13744.  
  13745.             PROTOTYPE IN
  13746.                       sc_base.h
  13747.  
  13748.  
  13749.             DESCRIPTION
  13750.                       scdnopenx opens a dBASE index file. Memory will be
  13751.                       allocated for  a file  packet,  I/O  buffers,  and
  13752.                       other miscellaneous  structures for use internally
  13753.                       by the  SoftC Database  Library file  manager. The
  13754.                       index file  will be  tested as much as possible to
  13755.                       insure that it is a legitimate dBASE index file.
  13756.  
  13757.  
  13758.                       A block  of memory large enough to hold at least 3
  13759.                       pages (1536  bytes) will  be allocated  during the
  13760.                       open. Three pages is the minimum number of buffers
  13761.                       required to add or delete index keys.
  13762.  
  13763.  
  13764.                       The file  will be  opened  under  control  of  the
  13765.                       "command" parameter.  Using SC_RDWR opens the file
  13766.                       for  both   read  and  write  access.    SC_RDONLY
  13767.                       overrides SC_RDWR and causes the file to be opened
  13768.                       for read  access only.   Any attempt to write to a
  13769.                       read  only   file  will   result   in   an   error
  13770.                       (SC_READOLY).
  13771.  
  13772.  
  13773.                       Using SC_EXCLUDE  opens the file for exclusive use
  13774.                       of  this   station  (single   user).     SC_SHARED
  13775.                       overrides SC_EXCLUDE  and opens the file in multi-
  13776.                       user mode.   This  mode is used when a LAN file is
  13777.                       to be shared with other stations.
  13778.  
  13779.  
  13780.                       Using SC_BUFFER  opens the  file with  I/O caching
  13781.                       enabled.   Memory for  up   to 10  pages  will  be
  13782.                       allocated during  the open.   Caching  of page I/O
  13783.                       greatly  increases   the  speed  of  file  access.
  13784.                       Typically this  mode  is  used  with  single  user
  13785.                       files.   SC_FLUSH overrides  SC_BUFFER and  causes
  13786.  
  13787.  
  13788.  
  13789.                                          201
  13790.  
  13791.  
  13792.  
  13793.  
  13794.  
  13795.  
  13796.  
  13797.  
  13798.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13799.  
  13800.  
  13801.                       the file  to be opened with no caching.  This mode
  13802.                       is generally  used with  file sharing, although it
  13803.                       is not required.
  13804.  
  13805.  
  13806.             NOTES
  13807.                       The index  expression will  be translated to upper
  13808.                       case after being read from the index file.
  13809.  
  13810.  
  13811.  
  13812.  
  13813.             EXAMPLE
  13814.  
  13815.             #include <softc.h>
  13816.             #include <sc_base.h>
  13817.  
  13818.             void main()
  13819.             {
  13820.               int ndx;
  13821.  
  13822.               scdinit(20,0);
  13823.               if (scdnopenx(&ndx, "UNKNOWN.NDX", SC_BUFFER) ==
  13824.             SC_SUCCESS) {
  13825.                 scdnclose(ndx);
  13826.               }
  13827.               scdterm();
  13828.             }
  13829.  
  13830.  
  13831.  
  13832.  
  13833.  
  13834.  
  13835.  
  13836.  
  13837.  
  13838.  
  13839.  
  13840.  
  13841.  
  13842.  
  13843.  
  13844.  
  13845.  
  13846.  
  13847.  
  13848.  
  13849.  
  13850.  
  13851.  
  13852.  
  13853.  
  13854.  
  13855.                                          202
  13856.  
  13857.  
  13858.  
  13859.  
  13860.  
  13861.  
  13862.  
  13863.  
  13864.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13865.  
  13866.  
  13867.  
  13868.             scdtclose 
  13869.  
  13870.             USAGE
  13871.                       signed int scdtclose(
  13872.                            signed int handle );
  13873.  
  13874.  
  13875.             PROTOTYPE IN
  13876.                       sc_base.h
  13877.  
  13878.  
  13879.             DESCRIPTION
  13880.                       scdtclose  closes   a  memo  file  and  frees  all
  13881.                       allocated  memory   associated  with   memo   file
  13882.                       "handle".
  13883.  
  13884.  
  13885.             SEE ALSO
  13886.                       scdtopenx.
  13887.  
  13888.  
  13889.  
  13890.  
  13891.             EXAMPLE
  13892.  
  13893.             #include <sc_base.h>
  13894.  
  13895.             void main()
  13896.             {
  13897.               int dbt;
  13898.  
  13899.               scdinit(20,0);
  13900.               if (scdtopenx(&dbt,"TOC.DBT",SC_SHARED) == SC_SUCCESS)
  13901.                 scdtclose(dbt);
  13902.               scdterm();
  13903.             }
  13904.  
  13905.  
  13906.  
  13907.  
  13908.  
  13909.  
  13910.  
  13911.  
  13912.  
  13913.  
  13914.  
  13915.  
  13916.  
  13917.  
  13918.  
  13919.  
  13920.  
  13921.                                          203
  13922.  
  13923.  
  13924.  
  13925.  
  13926.  
  13927.  
  13928.  
  13929.  
  13930.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13931.  
  13932.  
  13933.  
  13934.             scdtcreate     
  13935.  
  13936.             USAGE
  13937.                       signed int scdtcreate(
  13938.                            signed char *filename );
  13939.  
  13940.  
  13941.             PROTOTYPE IN
  13942.                       sc_base.h
  13943.  
  13944.  
  13945.             DESCRIPTION
  13946.                       scdtcreate creates a memo file. This function will
  13947.                       create a  new memo  file even  if one  had already
  13948.                       existed.
  13949.  
  13950.  
  13951.  
  13952.  
  13953.             EXAMPLE
  13954.  
  13955.             #include <sc_base.h>
  13956.  
  13957.             void main()
  13958.             {
  13959.               scdinit(20,0);
  13960.               scdtcreate("TOC.DBT");
  13961.               scdterm();
  13962.             }
  13963.  
  13964.  
  13965.  
  13966.  
  13967.  
  13968.  
  13969.  
  13970.  
  13971.  
  13972.  
  13973.  
  13974.  
  13975.  
  13976.  
  13977.  
  13978.  
  13979.  
  13980.  
  13981.  
  13982.  
  13983.  
  13984.  
  13985.  
  13986.  
  13987.                                          204
  13988.  
  13989.  
  13990.  
  13991.  
  13992.  
  13993.  
  13994.  
  13995.  
  13996.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  13997.  
  13998.  
  13999.  
  14000.             scdterm   
  14001.  
  14002.             USAGE
  14003.                       signed int scdterm( void );
  14004.  
  14005.  
  14006.             PROTOTYPE IN
  14007.                       sc_base.h
  14008.  
  14009.  
  14010.             DESCRIPTION
  14011.                       scdterm is  called once at the end of the program.
  14012.                       Memory allocated  by scdinit  for internal control
  14013.                       structures will  be freed.  All files open will be
  14014.                       closed, any  locks applied  will be  released, and
  14015.                       any memory  allocated for  them will be freed. Any
  14016.                       errors encountered will be returned in sc_code.
  14017.  
  14018.  
  14019.             NOTES
  14020.                       It is  probably a  good idea  to call  atexit with
  14021.                       scdterm at the very beginning of your application.
  14022.                       This will ensure that all buffered data is written
  14023.                       to disk  before the  program terminates.  Be aware
  14024.                       that scdterm can encounter errors which you may or
  14025.                       may not be able to display if atexit is used.
  14026.  
  14027.  
  14028.             SEE ALSO
  14029.                       scdinit.
  14030.  
  14031.  
  14032.  
  14033.  
  14034.             EXAMPLE
  14035.  
  14036.             #include <stdio.h>
  14037.             #include <sc_base.h>
  14038.  
  14039.             void main()
  14040.             {
  14041.               atexit(scdterm());
  14042.               scdinit(20,0);
  14043.               .
  14044.               . body of application
  14045.               .
  14046.               puts("Terminating...");
  14047.             }
  14048.  
  14049.  
  14050.  
  14051.  
  14052.  
  14053.                                          205
  14054.  
  14055.  
  14056.  
  14057.  
  14058.  
  14059.  
  14060.  
  14061.  
  14062.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14063.  
  14064.  
  14065.  
  14066.             scdtinfo  
  14067.  
  14068.             USAGE
  14069.                       signed int scdtinfo(
  14070.                            signed int handle,
  14071.                            SC_DBTINFO *info );
  14072.  
  14073.  
  14074.             PROTOTYPE IN
  14075.                       sc_base.h
  14076.  
  14077.  
  14078.             DESCRIPTION
  14079.                       scdtinfo gets the name of the memo file associated
  14080.                       with "handle" and returns it in a structure:
  14081.  
  14082.  
  14083.                       typdef struct {
  14084.                         signed char fname[80]; /* file name */
  14085.                         SC_FLAGS flags;   /* misc. flags */
  14086.                       } SC_DBTINFO;
  14087.  
  14088.  
  14089.             SEE ALSO
  14090.                       scdtopenx.
  14091.  
  14092.  
  14093.  
  14094.  
  14095.             EXAMPLE
  14096.  
  14097.             #include <softc.h>
  14098.             #include <sc_base.h>
  14099.  
  14100.             void main()
  14101.             {
  14102.               int dbt;
  14103.               SC_DBTINFO info;
  14104.  
  14105.               scdinit(20,0);
  14106.               if (scdtopenx(&dbt,"TOC.DBT",SC_SHARED) == SC_SUCCESS) {
  14107.                 scdtinfo(dbt,&info);
  14108.                 puts(info.fname);
  14109.                 scdtclose(dbt);
  14110.               }
  14111.               scdterm();
  14112.             }
  14113.  
  14114.  
  14115.  
  14116.  
  14117.  
  14118.  
  14119.                                          206
  14120.  
  14121.  
  14122.  
  14123.  
  14124.  
  14125.  
  14126.  
  14127.  
  14128.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14129.  
  14130.  
  14131.  
  14132.             scdtopenx 
  14133.  
  14134.             USAGE
  14135.                       signed int scdtopenx(
  14136.                            signed int *handle,
  14137.                            signed char *filename,
  14138.                            signed int command );
  14139.  
  14140.  
  14141.             PROTOTYPE IN
  14142.                       sc_base.h
  14143.  
  14144.  
  14145.             DESCRIPTION
  14146.                       scdtopenx  opens  a  memo  file.  Memory  will  be
  14147.                       allocated for  a file  packet and  I/O buffers for
  14148.                       use internally  by the  library file  manager. The
  14149.                       memo file  will be  tested as  much as possible to
  14150.                       insure that  it is  a  legitimate  dBASEIII+  memo
  14151.                       file.
  14152.  
  14153.  
  14154.                       The file  will be  opened  under  control  of  the
  14155.                       "command" parameter.  Using SC_RDWR opens the file
  14156.                       for  both   read  and  write  access.    SC_RDONLY
  14157.                       overrides SC_RDWR and causes the file to be opened
  14158.                       for read  access only.   Any attempt to write to a
  14159.                       read  only   file  will   result   in   an   error
  14160.                       (SC_READOLY).
  14161.  
  14162.  
  14163.                       Using SC_EXCLUDE  opens the file for exclusive use
  14164.                       of  this   station  (single   user).     SC_SHARED
  14165.                       overrides SC_EXCLUDE  and opens the file in multi-
  14166.                       user mode.   This  mode is used when a LAN file is
  14167.                       to be shared with other stations.
  14168.  
  14169.  
  14170.                       SC_BUFFER is not used.
  14171.  
  14172.  
  14173.                       "command"  =  0  is  equivalent  to  SC_EXCLUDE  |
  14174.                       SC_RDWR.
  14175.  
  14176.  
  14177.  
  14178.  
  14179.  
  14180.  
  14181.  
  14182.  
  14183.  
  14184.  
  14185.                                          207
  14186.  
  14187.  
  14188.  
  14189.  
  14190.  
  14191.  
  14192.  
  14193.  
  14194.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14195.  
  14196.  
  14197.             EXAMPLE
  14198.  
  14199.             #include <softc.h>
  14200.             #include <sc_base.h>
  14201.  
  14202.             void main()
  14203.             {
  14204.               int dbt;
  14205.  
  14206.               scdinit(20,0);
  14207.               if (scdtopenx(&dbt, "TOC.DBT", SC_SHARED) == SC_SUCCESS)
  14208.                 scdtclose(dbt);
  14209.               scdterm();
  14210.             }
  14211.  
  14212.  
  14213.  
  14214.  
  14215.  
  14216.  
  14217.  
  14218.  
  14219.  
  14220.  
  14221.  
  14222.  
  14223.  
  14224.  
  14225.  
  14226.  
  14227.  
  14228.  
  14229.  
  14230.  
  14231.  
  14232.  
  14233.  
  14234.  
  14235.  
  14236.  
  14237.  
  14238.  
  14239.  
  14240.  
  14241.  
  14242.  
  14243.  
  14244.  
  14245.  
  14246.  
  14247.  
  14248.  
  14249.  
  14250.  
  14251.                                          208
  14252.  
  14253.  
  14254.  
  14255.  
  14256.  
  14257.  
  14258.  
  14259.  
  14260.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14261.  
  14262.  
  14263.  
  14264.             scdtpack  
  14265.  
  14266.             USAGE
  14267.                       signed int scdtpack(
  14268.                            signed int datafile,
  14269.                            signed int *memofile );
  14270.  
  14271.  
  14272.             PROTOTYPE IN
  14273.                       sc_base.h
  14274.  
  14275.  
  14276.             DESCRIPTION
  14277.                       scdtpack will  remove all "memofile" records which
  14278.                       are not  referenced by  records in the "datafile".
  14279.                       The "memofile"  will be  compressed  so  that  all
  14280.                       active records  will be contiguous after the pack.
  14281.                       Files opened  with the  read only flag (SC_RDONLY)
  14282.                       cannot be packed.
  14283.  
  14284.  
  14285.             SEE ALSO
  14286.                       scddpack, scdtopenx
  14287.  
  14288.  
  14289.  
  14290.  
  14291.             EXAMPLE
  14292.  
  14293.             #include <softc.h>
  14294.             #include <sc_base.h>
  14295.  
  14296.             void main()
  14297.             {
  14298.               int dbf, dbt;
  14299.  
  14300.               scdinit(20,0);
  14301.               if (scddopenx(&dbf, "TOC.DBF", SC_SHARED) == SC_SUCCESS) {
  14302.                 if (scddopenx(&dbt, "TOC.DBT", SC_SHARED) == SC_SUCCESS)
  14303.             {
  14304.                   scdtpack(dbf, &dbt);
  14305.                   scdtclose(dbt);
  14306.                 }
  14307.                 scddclose(dbf);
  14308.               }
  14309.               scdterm();
  14310.             }
  14311.  
  14312.  
  14313.  
  14314.  
  14315.  
  14316.  
  14317.                                          209
  14318.  
  14319.  
  14320.  
  14321.  
  14322.  
  14323.  
  14324.  
  14325.  
  14326.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14327.  
  14328.  
  14329.  
  14330.             scdtrget  
  14331.  
  14332.             USAGE
  14333.                       signed int scdtrget(
  14334.                            signed int handle,
  14335.                            signed long recno,
  14336.                            signed char **data,
  14337.                            signed int command );
  14338.  
  14339.  
  14340.             PROTOTYPE IN
  14341.                       sc_base.h
  14342.  
  14343.  
  14344.             DESCRIPTION
  14345.                       scdtrget reads the desired record "recno" from the
  14346.                       memo file  specified by  "handle". A  buffer large
  14347.                       enough to  hold the  text will  be allocated,  the
  14348.                       address of which is returned in "data".
  14349.  
  14350.  
  14351.                       "command"  controls   whether  or   not  the  soft
  14352.                       carriage returns  are stripped. Use SC_CRUNCHNG to
  14353.                       leave the  soft carriage  returns  alone,  or  use
  14354.                       SC_CRDELETE to remove them.
  14355.  
  14356.  
  14357.             SEE ALSO
  14358.                       scdtrget.
  14359.  
  14360.  
  14361.  
  14362.  
  14363.             EXAMPLE
  14364.  
  14365.             #include <stdio.h>
  14366.             #include <softc.h>
  14367.             #include <sc_base.h>
  14368.  
  14369.             void main()
  14370.             {
  14371.               int dbt;
  14372.               char *data;
  14373.  
  14374.               scdinit(20,0);
  14375.               if (scdtopenx(&dbt,"TOC.DBT",SC_SHARED) == SC_SUCCESS) {
  14376.                 scdtrget(dbt,1L,&data,SC_CRDELETE);
  14377.                 puts(data);
  14378.                 free(data);
  14379.                 scddclose(dbt);
  14380.  
  14381.  
  14382.  
  14383.                                          210
  14384.  
  14385.  
  14386.  
  14387.  
  14388.  
  14389.  
  14390.  
  14391.  
  14392.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14393.  
  14394.  
  14395.               }
  14396.               scdterm();
  14397.             }
  14398.  
  14399.  
  14400.  
  14401.  
  14402.  
  14403.  
  14404.  
  14405.  
  14406.  
  14407.  
  14408.  
  14409.  
  14410.  
  14411.  
  14412.  
  14413.  
  14414.  
  14415.  
  14416.  
  14417.  
  14418.  
  14419.  
  14420.  
  14421.  
  14422.  
  14423.  
  14424.  
  14425.  
  14426.  
  14427.  
  14428.  
  14429.  
  14430.  
  14431.  
  14432.  
  14433.  
  14434.  
  14435.  
  14436.  
  14437.  
  14438.  
  14439.  
  14440.  
  14441.  
  14442.  
  14443.  
  14444.  
  14445.  
  14446.  
  14447.  
  14448.  
  14449.                                          211
  14450.  
  14451.  
  14452.  
  14453.  
  14454.  
  14455.  
  14456.  
  14457.  
  14458.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14459.  
  14460.  
  14461.  
  14462.             scdtrput  
  14463.  
  14464.             USAGE
  14465.                       signed int scdtrput(
  14466.                            signed int handle,
  14467.                            signed long *recno,
  14468.                            signed char *data,
  14469.                            signed int linelength );
  14470.  
  14471.  
  14472.             PROTOTYPE IN
  14473.                       sc_base.h
  14474.  
  14475.  
  14476.             DESCRIPTION
  14477.                       scdtrput writes  "data" to the memo file specified
  14478.                       by "handle". The record number written is returned
  14479.                       in  "recno".  This  record  number  must  be  then
  14480.                       written to  the data  output buffer  via a call to
  14481.                       scddfput. This  function assumes that "data" is an
  14482.                       ASCIIZ string  with a  maximum  length  of  65,536
  14483.                       characters.
  14484.  
  14485.  
  14486.                       The user  can directly  control whether or not the
  14487.                       soft carriage returns are added and, if so, where.
  14488.                       If "linelength"  is  zero  (0)  no  soft  carriage
  14489.                       returns will be added, else "linelength" specifies
  14490.                       the maximum  length of  a memo line.  It cannot be
  14491.                       less than 10 nor greater than 132.
  14492.  
  14493.  
  14494.             NOTES
  14495.                       Existing soft  carriage returns  are  not  removed
  14496.                       before new ones are added.
  14497.  
  14498.  
  14499.             SEE ALSO
  14500.                       scdtrput.
  14501.  
  14502.  
  14503.  
  14504.  
  14505.             EXAMPLE
  14506.  
  14507.             #include <stdio.h>
  14508.             #include <softc.h>
  14509.             #include <sc_base.h>
  14510.  
  14511.             void main()
  14512.  
  14513.  
  14514.  
  14515.                                          212
  14516.  
  14517.  
  14518.  
  14519.  
  14520.  
  14521.  
  14522.  
  14523.  
  14524.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14525.  
  14526.  
  14527.             {
  14528.               int dbt;
  14529.               char data[512];
  14530.               long recno;
  14531.  
  14532.               scdinit(20,0);
  14533.               if (scdtopenx(&dbt,"TOC.DBT",SC_BUFFER) == SC_SUCCESS) {
  14534.                 strcpy(data,"hello world.");
  14535.                 scdtrput(dbt,&recno,data,66);
  14536.                 printf("%ld",recno);
  14537.                 scddclose(dbt);
  14538.               }
  14539.               scdterm();
  14540.             }
  14541.  
  14542.  
  14543.  
  14544.  
  14545.  
  14546.  
  14547.  
  14548.  
  14549.  
  14550.  
  14551.  
  14552.  
  14553.  
  14554.  
  14555.  
  14556.  
  14557.  
  14558.  
  14559.  
  14560.  
  14561.  
  14562.  
  14563.  
  14564.  
  14565.  
  14566.  
  14567.  
  14568.  
  14569.  
  14570.  
  14571.  
  14572.  
  14573.  
  14574.  
  14575.  
  14576.  
  14577.  
  14578.  
  14579.  
  14580.  
  14581.                                          213
  14582.  
  14583.  
  14584.  
  14585.  
  14586.  
  14587.  
  14588.  
  14589.  
  14590.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14591.  
  14592.  
  14593.  
  14594.             sceclr    
  14595.  
  14596.             USAGE
  14597.                       void sceclr( void );
  14598.  
  14599.  
  14600.             MACRO IN
  14601.                       softc.h
  14602.  
  14603.  
  14604.             DESCRIPTION
  14605.                       sceclr is  a macro  which expands  to  "sc_code  =
  14606.                       SC_SUCCESS".   The SoftC  Database  Library  error
  14607.                       flag (sc_code) will be cleared.
  14608.  
  14609.  
  14610.             SEE ALSO
  14611.                       scemsg.
  14612.  
  14613.  
  14614.  
  14615.  
  14616.             EXAMPLE
  14617.  
  14618.             #include <stdio.h>
  14619.             #include <softc.h>
  14620.             #include <sc_base.h>
  14621.  
  14622.             void main()
  14623.             {
  14624.               int dbt;
  14625.               char data[512];
  14626.               long recno;
  14627.  
  14628.               scdinit(20,0);
  14629.               if (scdtopenx(&dbt,"TOC.DBT",SC_BUFFER) == SC_SUCCESS) {
  14630.                 .
  14631.                 .
  14632.                 .
  14633.                 scddclose(dbt);
  14634.               }
  14635.               else {
  14636.                 sceclr();
  14637.                 puts("File not found. Create? Y/N");
  14638.                 if (getch() == 'Y')
  14639.                   scdtcreate("TOC.DBT");
  14640.               }
  14641.               scdterm();
  14642.             }
  14643.  
  14644.  
  14645.  
  14646.  
  14647.                                          214
  14648.  
  14649.  
  14650.  
  14651.  
  14652.  
  14653.  
  14654.  
  14655.  
  14656.                        CHAPTER 8, THE SOFTC DATABASE LIBRARY
  14657.  
  14658.  
  14659.  
  14660.             scemsg    
  14661.  
  14662.             USAGE
  14663.                       signed char *scemsg( void );
  14664.  
  14665.  
  14666.             PROTOTYPE IN
  14667.                       softc.h
  14668.  
  14669.  
  14670.             DESCRIPTION
  14671.                       scemsg returns  a pointer  to the  SoftC  Database
  14672.                       Library error or warning message which corresponds
  14673.                       to the code found in sc_code.  Refer to Appendix A
  14674.                       for more information on error and warning codes.
  14675.  
  14676.  
  14677.             SEE ALSO
  14678.                       sceclr.
  14679.  
  14680.  
  14681.  
  14682.  
  14683.             EXAMPLE
  14684.  
  14685.             #include <stdio.h>
  14686.             #include <softc.h>
  14687.             #include <sc_base.h>
  14688.  
  14689.             void main()
  14690.             {
  14691.               int dbf;
  14692.  
  14693.               scdinit(20,0);
  14694.               if (scdopen(&dbf, "TOC.DBF", 0) != SC_SUCCESS)
  14695.                 puts(scemsg());
  14696.               else
  14697.                 puts("File opened O.K.");
  14698.               scdterm();
  14699.             }
  14700.  
  14701.  
  14702.  
  14703.  
  14704.  
  14705.  
  14706.  
  14707.  
  14708.  
  14709.  
  14710.  
  14711.  
  14712.  
  14713.                                          215
  14714.  
  14715.  
  14716.  
  14717.  
  14718.  
  14719.  
  14720.  
  14721.  
  14722.  
  14723.  
  14724.  
  14725.             Appendix A
  14726.  
  14727.  
  14728.             Result Codes and Messages
  14729.  
  14730.  
  14731.  
  14732.  
  14733.             Warning Codes and Messages
  14734.  
  14735.             SC_DELREC 1    "WARNING - record read is marked deleted"
  14736.  
  14737.             The data  file record just read was flagged as "inactive" or
  14738.             "deleted". dBASE  retains "deleted"  records until  the data
  14739.             file is packed.
  14740.  
  14741.  
  14742.             SC_EMPTY  2    "WARNING - file is empty"
  14743.  
  14744.             You have  attempted to  read from an index file which has no
  14745.             keys (is empty).
  14746.  
  14747.  
  14748.             SC_END    3    "WARNING - no more keys"
  14749.  
  14750.             The current  key pointer  is located  at the physical end of
  14751.             the index  file, either at the first key or at the last key.
  14752.             The actual position depends upon the function called.
  14753.  
  14754.  
  14755.             SC_NOFIND 4    "WARNING - could not find key in index file"
  14756.  
  14757.             The index key supplied to the function could not be found in
  14758.             the index  file. Make sure that the index key is being built
  14759.             properly.
  14760.  
  14761.  
  14762.             SC_FLDTRUNC    5    "WARNING - data field truncated"
  14763.  
  14764.             The length  of the  data supplied  is larger  than the space
  14765.             allocated for  the field  in  the  data  file  record.  This
  14766.             usually occurs only with character type fields.
  14767.  
  14768.  
  14769.             SC_FLDROUND    6    "WARNING - numeric field rounded"
  14770.  
  14771.             Numeric data  is not  stored in  the data record in floating
  14772.             point format,  rather it  is converted  to  ASCII  and  then
  14773.             stored complete  with a  decimal point. If the numeric value
  14774.             desired to  be written  is more  precise than  space in  the
  14775.  
  14776.  
  14777.  
  14778.  
  14779.                                         216
  14780.  
  14781.  
  14782.  
  14783.  
  14784.  
  14785.  
  14786.  
  14787.  
  14788.                        APPENDIX A, RESULT CODES AND MESSAGES
  14789.  
  14790.  
  14791.             field permits,  the data  will be  rounded and  this warning
  14792.             returned.
  14793.  
  14794.  
  14795.             SC_FILENGTH    7    "WARNING - file length is incorrect"
  14796.  
  14797.             After data,  index, or memo files are opened, the calculated
  14798.             file length is compared to the actual length. If they do not
  14799.             agree this  code is  returned. This  warning will occur most
  14800.             frequently with data files.
  14801.  
  14802.  
  14803.             SC_NOTBFRD     8    "WARNING - I/O not buffered"
  14804.  
  14805.             An attempt  was made  to flush  data to a file which was not
  14806.             opened with  buffering enabled.  Check how the data or index
  14807.             file was  opened. It  should be  opened using  the SC_BUFFER
  14808.             switch, not  SC_FLUSH. See "scd?openx" function descriptions
  14809.             for more information.
  14810.  
  14811.  
  14812.             SC_MEMWRN 9    "WARNING - memory allocation incomplete"
  14813.  
  14814.             The file manager has been unsuccessful in allocating all the
  14815.             memory requested.   This  failure could  be caused  by  many
  14816.             things:  not   enough  memory   available,  memory   threads
  14817.             corrupted, using  a null  pointer, ...  Check your  code  to
  14818.             ensure that  you do not have a problem in this area. You may
  14819.             need to use a larger data model.
  14820.  
  14821.  
  14822.             Error Codes and Messages
  14823.  
  14824.             SC_WRTFAIL     -1   "ERROR - file write failure"
  14825.  
  14826.             This indicates  an incomplete  file write.  The disk  may be
  14827.             full.
  14828.  
  14829.  
  14830.             SC_RDFAIL -2   "ERROR - file read failure"
  14831.  
  14832.             This indicates an incomplete read.
  14833.  
  14834.  
  14835.             SC_MEMERR -3   "ERROR - memory allocation error"
  14836.  
  14837.             An attempt  to allocate  memory  by  the  file  manager  has
  14838.             failed. This  failure could  be caused  by many  things: not
  14839.             enough memory  available, memory  threads corrupted, using a
  14840.             null pointer,  ... Check your code to ensure that you do not
  14841.  
  14842.  
  14843.  
  14844.  
  14845.                                         217
  14846.  
  14847.  
  14848.  
  14849.  
  14850.  
  14851.  
  14852.  
  14853.  
  14854.                        APPENDIX A, RESULT CODES AND MESSAGES
  14855.  
  14856.  
  14857.             have a  problem in this area. You may have to go to a larger
  14858.             data model.
  14859.  
  14860.  
  14861.             SC_SKFAIL -4   "ERROR - file pointer reposition failed"
  14862.  
  14863.             This error  is returned under two circumstances: actual seek
  14864.             failed or  an attempt was made to seek beyond the end of the
  14865.             file in  a function intending to read after seek. You should
  14866.             verify the  record number  (for either  data, index, or memo
  14867.             files) being requested is legitimate.
  14868.  
  14869.  
  14870.             SC_NOFILE -5   "ERROR - file not found"
  14871.  
  14872.             You have attempted to open a data, index, or memo file which
  14873.             cannot be  found. If  you are certain the file exists, check
  14874.             the path specification.
  14875.  
  14876.  
  14877.             SC_FILBAD -6   "ERROR - file corrupted"
  14878.  
  14879.             The file  manager has noticed something seriously wrong with
  14880.             the index  file. Close  and reopen the file, it may still be
  14881.             good. Otherwise you will have to rebuild the index file.
  14882.  
  14883.  
  14884.             SC_BADEXPR     -7   "ERROR - bad user specified key
  14885.                                 expression"
  14886.  
  14887.             This indicates  an error  either  with  the  length  or  the
  14888.             contents of the expression. The length can be no larger than
  14889.             220 characters.  See scdnkmake for more information on valid
  14890.             expression content.
  14891.  
  14892.  
  14893.             SC_NOHNDL -8   "ERROR - no handles available"
  14894.  
  14895.             Either DOS  or the  file manager  has no  more  unused  file
  14896.             handles. Each  DOS application  is allowed to have a maximum
  14897.             of twenty files open (up to the total defined by "FILES=" in
  14898.             "CONFIG.SYS"). Five of these files are reserved for console,
  14899.             printer, etc.  which leaves  only fifteen available for you.
  14900.             scdinit can  be used  to specify the maximum number of SoftC
  14901.             Database Library files which can be open simultaneously.
  14902.  
  14903.  
  14904.             SC_NOPGS  -9   "ERROR - no index pages loaded"
  14905.  
  14906.             This is  an internal  file manager  error which should never
  14907.             occur. Contact SoftC, Ltd. if you get this error.
  14908.  
  14909.  
  14910.  
  14911.                                         218
  14912.  
  14913.  
  14914.  
  14915.  
  14916.  
  14917.  
  14918.  
  14919.  
  14920.                        APPENDIX A, RESULT CODES AND MESSAGES
  14921.  
  14922.  
  14923.             SC_BADPG  -10  "ERROR - index page was not loaded"
  14924.  
  14925.             This is  an internal  file manager  error which should never
  14926.             occur. Contact SoftC, Ltd. if you get this error.
  14927.  
  14928.  
  14929.             SC_CLOSFAIL    -11  "ERROR - file close failure"
  14930.  
  14931.             This indicates  that DOS  could not properly close the file.
  14932.             Check errno for help in isolating further.
  14933.  
  14934.  
  14935.             SC_BADCMD -12  "ERROR - invalid command"
  14936.  
  14937.             This error is a general purpose indicator. It means that the
  14938.             I/O buffer  selected, date  string translation  format, data
  14939.             file record  write type, or maximum number of resident index
  14940.             pages was invalid depending upon the function executed.
  14941.  
  14942.  
  14943.             SC_BADHNDL     -13  "ERROR - invalid handle number"
  14944.  
  14945.             The file  handle does  not match  the function required file
  14946.             type or  there is  no file open for that handle. For example
  14947.             this will  occur when using an index file handle with a data
  14948.             file function.
  14949.  
  14950.  
  14951.             SC_BADFNAME    -14  "ERROR - invalid filename"
  14952.  
  14953.             The length  of the  file name  was zero or the file name was
  14954.             invalid in  some other  way. The  file manager  expects file
  14955.             names to  be complete  with an  extension.  File  paths  are
  14956.             optional.
  14957.  
  14958.  
  14959.             SC_BADDATE     -15  "ERROR - invalid date"
  14960.  
  14961.             The year,  month, and/or day was invalid. Verify the date is
  14962.             correct.
  14963.  
  14964.  
  14965.             SC_BADTIME     -16  "ERROR - invalid time"
  14966.  
  14967.             The hour, minute, and/or second was invalid. Verify the time
  14968.             is correct.
  14969.  
  14970.  
  14971.  
  14972.  
  14973.  
  14974.  
  14975.  
  14976.  
  14977.                                         219
  14978.  
  14979.  
  14980.  
  14981.  
  14982.  
  14983.  
  14984.  
  14985.  
  14986.                        APPENDIX A, RESULT CODES AND MESSAGES
  14987.  
  14988.  
  14989.             SC_NODBT  -17  "ERROR - file not in .DBT format"
  14990.  
  14991.             The memo  file length  was too  short. This  file cannot  be
  14992.             used.
  14993.  
  14994.  
  14995.             SC_DBFVERS     -18  "ERROR - invalid dBASE version"
  14996.  
  14997.             The dBASE  version  number  in  the  data  file  header  was
  14998.             unsupported. Only  dBASEIII, dBASEIII+, and dBASEIV versions
  14999.             are valid. This file cannot be used.
  15000.  
  15001.  
  15002.             SC_DBFHLEN     -19  "ERROR - file header length error"
  15003.  
  15004.             The length  of the  dBASE header  was invalid. The length of
  15005.             the header  must be  divisible by  32 with  a  remainder  of
  15006.             either 0 or 1. This file cannot be used.
  15007.  
  15008.  
  15009.             SC_DBFDATE     -20  "ERROR - last file change date in error"
  15010.  
  15011.             The data  file header  last modified  date was invalid. This
  15012.             file cannot be used.
  15013.  
  15014.  
  15015.             SC_NULLPARM    -21  "ERROR - parameter address null"
  15016.  
  15017.             The address  of a parameter is NULL. Check the parameters on
  15018.             the call to ensure they are correct.
  15019.  
  15020.  
  15021.             SC_BADKEYT     -22  "ERROR - invalid key type"
  15022.  
  15023.             The selected  key type  is invalid  for the index file type.
  15024.             Refer  to   scd?create  for  further  information  regarding
  15025.             allowable key types.
  15026.  
  15027.  
  15028.             SC_KEYLEN -23  "ERROR - invalid key length"
  15029.  
  15030.             The character  key maximum  length  definition  exceeds  100
  15031.             characters. This  error does not occur for numeric (or date)
  15032.             keys.
  15033.  
  15034.  
  15035.             SC_ITEMLEN     -24  "ERROR - item length incorrect"
  15036.  
  15037.             The file  manager index  key item  length not agree with the
  15038.             value read from the index file. This file cannot be used.
  15039.  
  15040.  
  15041.  
  15042.  
  15043.                                         220
  15044.  
  15045.  
  15046.  
  15047.  
  15048.  
  15049.  
  15050.  
  15051.  
  15052.                        APPENDIX A, RESULT CODES AND MESSAGES
  15053.  
  15054.  
  15055.             SC_BADROOT     -25  "ERROR - invalid root page"
  15056.  
  15057.             The index  page number  for the  top of  the Btree  does not
  15058.             exist in the index file. This file cannot be used.
  15059.  
  15060.  
  15061.             SC_MAXKEYS     -26  "ERROR - bad maximum number of keys per
  15062.                                 page"
  15063.  
  15064.             The file manager maximum number of index keys per index page
  15065.             does not agree with the value read from the index file. This
  15066.             file cannot be used.
  15067.  
  15068.  
  15069.             SC_FLDCNT -27  "ERROR - invalid number of fields"
  15070.  
  15071.             A  data  file  record  can  consist  of  a  maximum  of  128
  15072.             individual fields for dBASE III or 255 for dBASE IV.
  15073.  
  15074.  
  15075.             SC_BADFLDN     -28  "ERROR - field name invalid"
  15076.  
  15077.             The field  name length  cannot  exceed  ten  characters  not
  15078.             including the null bye.
  15079.  
  15080.  
  15081.             SC_FLDLEN -29  "ERROR - bad field length"
  15082.  
  15083.             Character fields  cannot be longer than 254 bytes. dBASE III
  15084.             numeric fields  cannot be  longer than  19 bytes.  dBASE  IV
  15085.             numeric and  float fields  cannot be  longer than  20 bytes.
  15086.             This error will not occur for the other field types.
  15087.  
  15088.  
  15089.             SC_DECPL  -30  "ERROR - decimal places parameter invalid"
  15090.  
  15091.             The  decimal   places  definition   portion  of   the  field
  15092.             description cannot be less than 0 nor can it be greater than
  15093.             the field length minus two.
  15094.  
  15095.  
  15096.             SC_BADFLDT     -31  "ERROR - invalid field type"
  15097.  
  15098.             Only character ('C'), date ('D'), logical ('L'), memo ('M'),
  15099.             and  numeric   ('N')  are   allowed  in   dBASE  III  files.
  15100.             Additionally, dBASE IV supports a floating point ('F') field
  15101.             type.
  15102.  
  15103.  
  15104.  
  15105.  
  15106.  
  15107.  
  15108.  
  15109.                                         221
  15110.  
  15111.  
  15112.  
  15113.  
  15114.  
  15115.  
  15116.  
  15117.  
  15118.                        APPENDIX A, RESULT CODES AND MESSAGES
  15119.  
  15120.  
  15121.             SC_RECLEN -32  "ERROR - invalid record length"
  15122.  
  15123.             The record length cannot exceed 4000 bytes. Check your field
  15124.             lengths and make sure that they total 4000 or less.
  15125.  
  15126.  
  15127.             SC_BADDATA     -33  "ERROR - bad data"
  15128.  
  15129.             The data  you requested  to be written into a data field was
  15130.             invalid. For  example a pointer to a floating point variable
  15131.             was passed  for a  character field.  Ensure  the  data  type
  15132.             passed matches the field definition.
  15133.  
  15134.  
  15135.             SC_LINELEN     -34  "ERROR - memo soft line length invalid"
  15136.  
  15137.             Valid values for line lengths are 0, and between 10 and 132.
  15138.             The line  length parameter  is used when the file manager is
  15139.             inserting soft  carriage returns  in  memo  text  as  it  is
  15140.             written to the memo file.
  15141.  
  15142.  
  15143.             SC_MDXFLAG     -35  "ERROR - MDX flag in DBF file invalid"
  15144.  
  15145.             The value  found in  byte twenty  eight (28)  of the dBASEIV
  15146.             data file  is not valid. Only values of zero (0) and one (1)
  15147.             are currently supported. This may indicate a corrupted file.
  15148.  
  15149.  
  15150.             SC_READOLY     -36  "ERROR - file open for reading only"
  15151.  
  15152.             An attempt  was made  to execute  a write function to a file
  15153.             opened for reading only. Check the switches used to open the
  15154.             file.
  15155.  
  15156.  
  15157.             SC_LCKVIOL     -37  "ERROR - file locking violation"
  15158.  
  15159.             This  only   occurs  when   sharing  files.  There  are  two
  15160.             situations when  this error  is returned:  1) attempting  to
  15161.             lock a record/file that is already locked, and 2) attempting
  15162.             to unlock a record/file which is not currently locked.
  15163.  
  15164.  
  15165.             SC_LCKBOVR     -38  "ERROR - sharing buffer overflow"
  15166.  
  15167.             This is  an internal  file manager  error which should never
  15168.             occur. Contact SoftC, Ltd. if you get this error.
  15169.  
  15170.  
  15171.  
  15172.  
  15173.  
  15174.  
  15175.                                         222
  15176.  
  15177.  
  15178.  
  15179.  
  15180.  
  15181.  
  15182.  
  15183.  
  15184.                        APPENDIX A, RESULT CODES AND MESSAGES
  15185.  
  15186.  
  15187.             SC_NOPATH -39  "ERROR - path not found"
  15188.  
  15189.             The path  specified in  the file  open command  could not be
  15190.             found. Make sure the path is correct.
  15191.  
  15192.  
  15193.             SC_ACCDEN -40  "ERROR - access to file denied"
  15194.  
  15195.             This error  occurs only  when sharing  files. The file could
  15196.             not be  accessed. This  can occur if another station has the
  15197.             file opened in SC_EXCLUDE mode.
  15198.  
  15199.  
  15200.             SC_BADACC -41  "ERROR - invalid access code"
  15201.  
  15202.             This is  an internal  file manager  error which should never
  15203.             occur. Contact SoftC, Ltd. if you get this error.
  15204.  
  15205.  
  15206.             SC_NOTLCKD     -42  "ERROR - file must be locked first"
  15207.  
  15208.             This error  occurs only when sharing files. The file must be
  15209.             locked before executing this function.
  15210.  
  15211.  
  15212.             SC_NEWDEV -43  "ERROR - diskette changed"
  15213.  
  15214.             DOS believes that the diskette has been changed.
  15215.  
  15216.  
  15217.             SC_MINKEYS     -44  "ERROR - bad minimum number of keys per
  15218.                                 page"
  15219.  
  15220.             The value found in the minimum number of keys per page field
  15221.             was incorrect.  This  error  can  occur  only  when  opening
  15222.             Clipper index files. This may indicate a corrupted file.
  15223.  
  15224.  
  15225.             SC_FILSOPEN    -45  "ERROR - some files remain open"
  15226.  
  15227.             This error  is returned  by scdterm. In order for this error
  15228.             to occur,  scdinit must  have been  called with  SC_USEXHNDL
  15229.             switch and  the "files parameter is greater than twenty. The
  15230.             error indicates  that a  file  handle  above  nineteen  (19)
  15231.             remains open  after all  SoftC files  have been closed. Make
  15232.             sure that  all of  your  files  are  closed  before  calling
  15233.             scdterm.
  15234.  
  15235.  
  15236.  
  15237.  
  15238.  
  15239.  
  15240.  
  15241.                                         223
  15242.  
  15243.  
  15244.  
  15245.  
  15246.  
  15247.  
  15248.  
  15249.  
  15250.                        APPENDIX A, RESULT CODES AND MESSAGES
  15251.  
  15252.  
  15253.             Other Messages
  15254.  
  15255.             "Unknown error or warning code"
  15256.  
  15257.             This message  is returned  by scemsg  if it  cannot  find  a
  15258.             message which corresponds to the value found in sc_code. The
  15259.             function scemsg  may be  old or  otherwise incompatible with
  15260.             the value found in sc_code.
  15261.  
  15262.  
  15263.  
  15264.  
  15265.  
  15266.  
  15267.  
  15268.  
  15269.  
  15270.  
  15271.  
  15272.  
  15273.  
  15274.  
  15275.  
  15276.  
  15277.  
  15278.  
  15279.  
  15280.  
  15281.  
  15282.  
  15283.  
  15284.  
  15285.  
  15286.  
  15287.  
  15288.  
  15289.  
  15290.  
  15291.  
  15292.  
  15293.  
  15294.  
  15295.  
  15296.  
  15297.  
  15298.  
  15299.  
  15300.  
  15301.  
  15302.  
  15303.  
  15304.  
  15305.  
  15306.  
  15307.                                         224
  15308.  
  15309.  
  15310.  
  15311.  
  15312.  
  15313.  
  15314.  
  15315.  
  15316.  
  15317.  
  15318.  
  15319.             Appendix B
  15320.  
  15321.  
  15322.             Diskette TOC Demo Program
  15323.  
  15324.  
  15325.  
  15326.  
  15327.             The Diskette  TOC Program  is a  simple program  which  will
  15328.             create a  database (TOC.DBF)  and  three  index  files.  The
  15329.             database record contains the following fields:
  15330.  
  15331.  
  15332.             field name  type  length description
  15333.             __________________________________________
  15334.             NAME        C     64     file name
  15335.             LENGTH      N     10.0   file size in bytes
  15336.             DATE        D     8      file creation date
  15337.             TIME        C     8      file creation time
  15338.             ATTRIBUTE   C     3      file attribute (READ ONLY, HIDDEN)
  15339.  
  15340.  
  15341.             The index  files created  are: TOCNAME (file name), TOCLNGTH
  15342.             (file length), and TOCDATE (file creation date and time).
  15343.  
  15344.  
  15345.             The  program   uses  the   DOS  functions   "findfirst"  and
  15346.             "findnext" to  step through  the files  in the directory. It
  15347.             reformats the  compressed file  date ("mm/dd/yy")  and  time
  15348.             ("hh:mm:ss") and  places the  resultant data into the output
  15349.             buffer. After  all fields have been entered it will append a
  15350.             record to the end of the database and add keys for each file
  15351.             found.   After all  records have been added, the contents of
  15352.             the data  file are  displayed in  the filename  order  using
  15353.             index file TOCNAME.
  15354.  
  15355.  
  15356.             The program only works on the current directory. It does not
  15357.             support any  command line  arguments, although  it would  be
  15358.             easy for  the user  to add  such support.  Very little error
  15359.             checking is performed.
  15360.  
  15361.  
  15362.             The program as it stands has value only in the demonstration
  15363.             of certain library functions:
  15364.  
  15365.  
  15366.             scdinit,      scdterm,      scddclose,
  15367.             scddcreate,   scddopenx,    scddfget,
  15368.             scddfput,     scddrget,     scdrput,
  15369.  
  15370.  
  15371.  
  15372.  
  15373.                                          225
  15374.  
  15375.  
  15376.  
  15377.  
  15378.  
  15379.  
  15380.  
  15381.  
  15382.                                         APPENDIX B, DISKETTE TOC DEMO PROGRAM
  15383.  
  15384.  
  15385.             scd?create,   scd?openx,    scd?kadd,
  15386.             scd?kmake,    scd?knext,    scd?ktop
  15387.  
  15388.  
  15389.             However, it could form the basis of a diskette cataloger, or
  15390.             ...
  15391.  
  15392.  
  15393.  
  15394.  
  15395.  
  15396.  
  15397.  
  15398.  
  15399.  
  15400.  
  15401.  
  15402.  
  15403.  
  15404.  
  15405.  
  15406.  
  15407.  
  15408.  
  15409.  
  15410.  
  15411.  
  15412.  
  15413.  
  15414.  
  15415.  
  15416.  
  15417.  
  15418.  
  15419.  
  15420.  
  15421.  
  15422.  
  15423.  
  15424.  
  15425.  
  15426.  
  15427.  
  15428.  
  15429.  
  15430.  
  15431.  
  15432.  
  15433.  
  15434.  
  15435.  
  15436.  
  15437.  
  15438.  
  15439.                                          226
  15440.  
  15441.  
  15442.  
  15443.  
  15444.  
  15445.  
  15446.  
  15447.  
  15448.                                        Index
  15449.  
  15450.  
  15451.                                                    long  35
  15452.             Data                                 to long  40
  15453.               field                                integer  29
  15454.                 array  93, 101                   to month
  15455.                 read                               string  41
  15456.                   memo  210                      to string
  15457.                   strings  99                      day of week  43
  15458.                   values  97                       integers  30
  15459.                 write                              long  36
  15460.                   memo  212                        month  47
  15461.                   strings  107                     string  42
  15462.                   values  105
  15463.               file                           Functions
  15464.                 close  92                      sccdi2l  19, 29, 35
  15465.                 create  93                     sccdi2s  19, 30, 39, 44
  15466.                 flush  103                     sccdiget  20, 31, 45
  15467.                 I/O buffer clear  117          sccdileap  20, 32, 46
  15468.                 I/O cache  89                  sccdiperm  20, 33, 48
  15469.                 information  109               sccdl2dow  20, 34
  15470.                 last update  113               sccdl2i  19, 29, 35
  15471.                 lock file  111                 sccdl2sx  19, 36
  15472.                 lock record  121               sccds2day  20, 37, 38, 41
  15473.                 number of records  128         sccds2dow  20, 34, 37, 38
  15474.                 open  114                      sccds2i  19, 30, 39
  15475.                 pack  116                      sccds2lx  19, 36, 40
  15476.                 position  91, 96, 123          sccds2mon  20, 41
  15477.                 record                         sccds2s  19, 42, 44
  15478.                   status  126                  sccdsday  20, 43, 47
  15479.                 unlock  129                    sccdsdiff  20, 44
  15480.               record                           sccdsget  20, 31, 45
  15481.                 delete  118                    sccdsleap  20, 32, 46
  15482.                 read  119                      sccdsmonth  20, 43, 47
  15483.                 recover  127                   sccdsperm  20, 33, 48
  15484.                 write  124                     sccdsvalid  20, 30, 44,
  15485.                                                    49
  15486.             Date                               sccdxlat  42
  15487.               calculate                        sccti2s  20, 50, 52, 53
  15488.                 days per month  33, 48         scctiget  21, 51
  15489.                 difference  44                 sccts2i  20, 50, 52
  15490.               get from DOS                     scctsdiff  21, 53
  15491.                 integers  31                   scctsget  21, 45, 54
  15492.                 string  45                     scctsvalid  21, 50, 53,
  15493.               test                                 55
  15494.                 leap year  32, 46              scdcbfrsz  56
  15495.                 valid  49                      scdcclose  58
  15496.               translate                        scdccreate  59, 65, 80
  15497.                 to day of week                 scdcexpr  61
  15498.                   integer  37                  scdcflush  63
  15499.                   long  34                     scdcindex  65
  15500.                   string  38                   scdcinfo  61, 66, 70, 72,
  15501.                 to integers  39                    76, 77, 81, 83, 85
  15502.  
  15503.  
  15504.  
  15505.                                         227
  15506.  
  15507.  
  15508.  
  15509.  
  15510.  
  15511.  
  15512.  
  15513.  
  15514.                                        INDEX
  15515.  
  15516.  
  15517.               scdckadd  68, 74                 scddunlock  16, 24, 111,
  15518.               scdckbot  70, 72                     121, 129
  15519.               scdckcur  72                     scdibfrsz  131
  15520.               scdckdel  74                     scdiclose  133
  15521.               scdckfind  72, 76                scdicreate  134, 157, 160
  15522.               scdckmake  60, 68, 78            scdiexpr  136
  15523.               scdcknext  72, 81                scdiflush  138
  15524.               scdckprev  72, 83                scdiindex  140
  15525.               scdcktop  72, 85                 scdiinfo  136, 141, 145,
  15526.               scdcopenx  63, 66, 87                147, 153, 154, 158,
  15527.               scddbfrsz  14, 89                    161, 163
  15528.               scddbof  13, 91, 96, 123         scdikadd  143, 151
  15529.               scddclose  13, 92                scdikbot  145, 147
  15530.               scddcreate  13, 15, 93,          scdikcur  147
  15531.                   94                           scdikdate  143, 149, 157,
  15532.               scddeof  13, 91, 96, 123             160
  15533.               scddfget  15, 22, 97, 99,        scdikdel  151
  15534.                   105, 107, 119                scdikfind  147, 153
  15535.               scddfgets  15, 98, 99,           scdikmake  135, 143, 149,
  15536.                   107                              155, 160
  15537.               scddfinfo  15, 97, 98,           scdiknext  147, 158
  15538.                   99, 101                      scdiknum  18, 143, 149,
  15539.               scddflush  14, 103                   157, 160
  15540.               scddfnam2no  15, 104             scdikprev  147, 161
  15541.               scddfput  15, 16, 22, 98,        scdiktop  147, 163
  15542.                   105, 107, 119, 124,          scdinit  2, 7, 22, 165,
  15543.                   212                              205, 218, 223
  15544.               scddfputs  15, 99, 105,          scdiopenx  138, 141, 167
  15545.                   107, 124                     scdnbfrsz  17, 169
  15546.               scddinfo  13, 109                scdnclose  17, 171
  15547.               scddlock  15, 24, 111,           scdncreate  17, 172, 194
  15548.                   121, 129                     scdnexpr  17, 174
  15549.               scddlud  13, 113                 scdnflush  17, 176
  15550.               scddopenx  13, 89, 92,           scdnindex  17, 116, 178
  15551.                   103, 109, 111, 114,          scdninfo  17, 174, 179,
  15552.                   115, 116, 121, 129               183, 185, 190, 191,
  15553.               scddpack  14, 116, 209               195, 197, 199
  15554.               scddrclear  14, 117              scdnkadd  18, 181, 188
  15555.               scddrcopy  124                   scdnkbot  17, 183, 185
  15556.               scddrdel  14, 118, 127           scdnkcur  17, 185
  15557.               scddrget  14, 98, 99,            scdnkdate  18, 181, 187,
  15558.                   119, 124, 126                    194
  15559.               scddrinfo  14, 101, 120          scdnkdel  18, 188
  15560.               scddrlock  16, 24, 111,          scdnkfind  17, 185, 190
  15561.                   121, 129                     scdnkmake  18, 172, 173,
  15562.               scddrnum  15, 91, 96, 123            181, 192, 218
  15563.               scddrput  14, 119, 124           scdnknext  17, 185, 195
  15564.               scddrstat  15, 126               scdnkprev  17, 185, 197
  15565.               scddrundel  14, 118, 127         scdnktop  17, 185, 199
  15566.               scddsize  13, 128                scdnopenx  16, 176, 179,
  15567.                                                    201
  15568.  
  15569.  
  15570.  
  15571.                                         228
  15572.  
  15573.  
  15574.  
  15575.  
  15576.  
  15577.  
  15578.  
  15579.  
  15580.                                        INDEX
  15581.  
  15582.  
  15583.               scdtclose  16, 203                   dtoc  18, 192
  15584.               scdtcreate  16, 204                  left  18, 192
  15585.               scdterm  7, 13, 22, 165,             right  18, 192, 193
  15586.                   205, 223                         str  18, 192, 193
  15587.               scdtinfo  16, 206                    substr  18, 192, 193
  15588.               scdtopenx  16, 203, 206,             read  174
  15589.                   207, 209                       file
  15590.               scdtpack  16, 116, 209               cache  169
  15591.               scdtrget  16, 97, 98, 210            close  171
  15592.               scdtrput  16, 212                    create  172
  15593.               sceclr  23, 214, 215                 flush  176
  15594.               scemsg  23, 214, 215, 224            index  178
  15595.                                                    open  201
  15596.             Global variables                     key
  15597.               sc_code  22, 23, 205,                add  181
  15598.                   214, 215, 224                    build  187, 192
  15599.               sc_date_style  22, 97,               delete  188
  15600.                   105                              get first  199
  15601.               sc_version  22                       get last  183
  15602.                                                    read next  195
  15603.             Index                                  read previous  197
  15604.               Clipper                              search  190
  15605.                 expression                     FoxBASE+
  15606.                   defined  59, 78                expression
  15607.                   functions                        defined  134, 155
  15608.                   dtoc  78                         functions
  15609.                   left  78                         dtoc  155
  15610.                   right  78, 79                    left  155
  15611.                   str  78, 79                      right  155, 156
  15612.                   substr  78, 79                   str  155, 156
  15613.                   read  61                         substr  155, 156
  15614.                 file                               read  136
  15615.                   cache  56                      file
  15616.                   close  58                        cache  131
  15617.                   create  59                       close  133
  15618.                   flush  63                        create  134
  15619.                   index  65                        flush  138
  15620.                   open  87                         index  140
  15621.                 key                                open  167
  15622.                   add  68                        key
  15623.                   build  78                        add  143
  15624.                   delete  74                       build  149, 155, 160
  15625.                   get first  85                    delete  151
  15626.                   get last  70                     get first  163
  15627.                   read next  81                    get last  145
  15628.                   read previous  83                read next  158
  15629.                   search  76                       read previous  161
  15630.               dBASE                                search  153
  15631.                 expression
  15632.                   defined  172, 192          Initialization  165
  15633.                   functions
  15634.  
  15635.  
  15636.  
  15637.                                         229
  15638.  
  15639.  
  15640.  
  15641.  
  15642.  
  15643.  
  15644.  
  15645.  
  15646.                                        INDEX
  15647.  
  15648.  
  15649.             Memo                                 SC_NOPATH  223
  15650.               file                               SC_NOPGS  218
  15651.                 pack  209                        SC_NOTLCKD  223
  15652.                                                  SC_NULLPARM  220
  15653.             Memo file                            SC_RDFAIL  217
  15654.               close  203                         SC_READOLY  222
  15655.               create  204                        SC_RECLEN  222
  15656.               open  207                          SC_SKFAIL  218
  15657.               read  210                          SC_WRTFAIL  217
  15658.               write  212                       message translate  215
  15659.                                                warnings
  15660.             Return codes                         SC_DELREC  216
  15661.               clear  214                         SC_EMPTY  216
  15662.               defined  22, 216                   SC_END  216
  15663.               errors                             SC_FILENGTH  217
  15664.                 SC_ACCDEN  223                   SC_FLDROUND  216
  15665.                 SC_BADACC  223                   SC_FLDTRUNC  216
  15666.                 SC_BADCMD  219                   SC_MEMWRN  217
  15667.                 SC_BADDATA  222                  SC_NOFIND  216
  15668.                 SC_BADDATE  219                  SC_NOTBFRD  217
  15669.                 SC_BADEXPR  218
  15670.                 SC_BADFLDN  221              SC_ADD  124
  15671.                 SC_BADFLDT  221
  15672.                 SC_BADFNAME  219             SC_BUFFER  14, 17, 63, 87,
  15673.                 SC_BADHNDL  219              89, 103, 114, 138, 167,
  15674.                 SC_BADKEYT  220              176, 201, 207, 217
  15675.                 SC_BADPG  219
  15676.                 SC_BADROOT  221              SC_CKEY  59, 134, 172
  15677.                 SC_BADTIME  219
  15678.                 SC_CLOSFAIL  219             SC_CRDELETE  210
  15679.                 SC_DBFDATE  220
  15680.                 SC_DBFHLEN  220              SC_CRUNCHNG  210
  15681.                 SC_DBFVERS  220
  15682.                 SC_DECPL  221                SC_CSHMS  19, 50, 52, 53,
  15683.                 SC_FILBAD  218               54, 55
  15684.                 SC_FILSOPEN  223
  15685.                 SC_FLDCNT  221               SC_DB3  94
  15686.                 SC_FLDLEN  221
  15687.                 SC_ITEMLEN  220              SC_DB4  94
  15688.                 SC_KEYLEN  220
  15689.                 SC_LCKBOVR  222              SC_DELREC  126
  15690.                 SC_LCKVIOL  222
  15691.                 SC_LINELEN  222              SC_DKEY  59, 134, 172
  15692.                 SC_MAXKEYS  221
  15693.                 SC_MDXFLAG  222              SC_DMY  19, 22, 30, 36, 37,
  15694.                 SC_MEMERR  217               38, 39, 40, 41, 42, 43, 44,
  15695.                 SC_MINKEYS  223              45, 46, 47, 48, 49, 113,
  15696.                 SC_NEWDEV  223               149, 187
  15697.                 SC_NODBT  220
  15698.                 SC_NOFILE  218               SC_EXACT  76, 153, 190
  15699.                 SC_NOHNDL  218
  15700.  
  15701.  
  15702.  
  15703.                                         230
  15704.  
  15705.  
  15706.  
  15707.  
  15708.  
  15709.  
  15710.  
  15711.  
  15712.                                        INDEX
  15713.  
  15714.  
  15715.             SC_EXCLUDE  87, 114, 168,        SC_TRUE  13, 32, 46, 91, 96
  15716.             201, 207, 223
  15717.                                              SC_UNIQUE  59, 134, 172
  15718.             SC_FALSE  32, 46, 91, 96
  15719.                                              SC_UPDATE  124
  15720.             SC_FIELD  93, 101
  15721.                                              SC_USEXHNDL  223
  15722.             SC_FIRST  76, 153, 190, 191
  15723.                                              SC_USEXHNDLS  165
  15724.             SC_FLUSH  88, 114, 167,
  15725.             201, 217                         SC_YMD  19, 30, 36, 37, 38,
  15726.                                              39, 40, 41, 42, 43, 44, 45,
  15727.             SC_GETSZ  56, 89, 131, 169       46, 47, 48, 49, 113, 149,
  15728.                                              187
  15729.             SC_GREGOR  19, 22, 30, 36,
  15730.             37, 38, 39, 40, 41, 42, 43,      Structures
  15731.             44, 45, 46, 47, 48, 49, 97,        SC_DBFINFO  109
  15732.             105, 113, 149, 187                 SC_DBFRINFO  120
  15733.                                                SC_DBTINFO  206
  15734.             SC_GREGORL  19, 30, 36, 37,        SC_FIELD  93, 101
  15735.             38, 39, 40, 41, 42, 43, 44,        SC_FLAGS  66, 109, 141,
  15736.             45, 46, 47, 48, 49, 113,               179, 206
  15737.             149, 187                           SC_IDXINFO  141
  15738.                                                SC_NDXINFO  179
  15739.             SC_JULIAN  19, 30, 36, 37,         SC_NTXINFO  66
  15740.             38, 39, 40, 41, 42, 43, 44,
  15741.             45, 46, 47, 48, 49, 113,         Termination  205
  15742.             149, 187
  15743.                                              Time
  15744.             SC_LKEY  134                       calculation  53
  15745.                                                get from DOS
  15746.             SC_MIL  19, 50, 52, 53, 54,          integers  51
  15747.             55                                   string  54
  15748.                                                test  55
  15749.             SC_NKEY  59, 134, 172              translation  50, 52
  15750.  
  15751.             SC_NOTUSED  116
  15752.  
  15753.             SC_RDONLY  87, 114, 116,
  15754.             167, 201, 207
  15755.  
  15756.             SC_RDWR  87, 114, 167, 201,
  15757.             207
  15758.  
  15759.             SC_SETSZ  56, 89, 131, 169
  15760.  
  15761.             SC_SHARED  87, 111, 114,
  15762.             121, 129, 168, 201, 207
  15763.  
  15764.             SC_SUCCESS  126
  15765.  
  15766.  
  15767.  
  15768.  
  15769.                                         231
  15770.  
  15771.  
  15772.  
  15773.  
  15774.  
  15775.  
  15776.  
  15777.  
  15778.  
  15779.  
  15780.  
  15781.                  
  15782.  
  15783.  
  15784.  
  15785.  
  15786.  
  15787.  
  15788.  
  15789.  
  15790.  
  15791.  
  15792.  
  15793.  
  15794.  
  15795.  
  15796.  
  15797.  
  15798.  
  15799.  
  15800.  
  15801.  
  15802.  
  15803.  
  15804.  
  15805.  
  15806.  
  15807.  
  15808.  
  15809.  
  15810.  
  15811.  
  15812.  
  15813.  
  15814.  
  15815.  
  15816.  
  15817.  
  15818.  
  15819.  
  15820.  
  15821.  
  15822.  
  15823.  
  15824.  
  15825.  
  15826.  
  15827.  
  15828.  
  15829.  
  15830.  
  15831.  
  15832.  
  15833.  
  15834.  
  15835.  
  15836.  
  15837.  
  15838.  
  15839.  
  15840.  
  15841.