home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / scd210.zip / MANUAL.DOC < prev    next >
Text File  |  1991-01-26  |  380KB  |  13,267 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                                SoftC Database Library
  16.  
  17.                                   Reference Guide
  18.  
  19.  
  20.                                     Version 2.10
  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/Facsimile (612) 434-6968
  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.                                   Table Of Contents
  71.  
  72.  
  73.  
  74.             Chapter 1 Introduction..........................................1
  75.                Registration.................................................2
  76.                Shareware....................................................2
  77.                Typographic Conventions......................................2
  78.                Trademarks...................................................3
  79.                Support and Updates..........................................3
  80.  
  81.             Chapter 2 Before You Begin......................................4
  82.                The READ.ME File.............................................4
  83.                The Demonstration Package....................................4
  84.                Sample Files.................................................4
  85.                Header Files.................................................5
  86.                Help Files...................................................5
  87.                Library Object Code Files....................................6
  88.                Library Source Files.........................................6
  89.                Installing SoftC on Your System..............................7
  90.                SoftC Applications...........................................8
  91.                Compiling with Microsoft C...................................8
  92.                Compiling with Quick C.......................................9
  93.                Compiling with Turbo C.......................................9
  94.                Compiling with Turbo C++.....................................9
  95.                Compiling with Zortech C++...................................9
  96.                Recompiling the Database Libraries..........................10
  97.                OS/2, Windows 3.0 and UNIX Support..........................10
  98.                Function Naming Conventions.................................11
  99.  
  100.             Chapter 3 A Database Tutorial..................................12
  101.                Sequential Files............................................12
  102.                Random Access Files.........................................12
  103.                Keys........................................................13
  104.                ISAM........................................................13
  105.                Binary Trees................................................13
  106.                B- and B+ Trees.............................................13
  107.  
  108.             Chapter 4 Database Functions...................................15
  109.                dBASE Data File Functions...................................15
  110.                dBASE Data Record I/O.......................................16
  111.                dBASE Data Field I/O........................................17
  112.                File Sharing Functions......................................17
  113.                dBASEIII Memo File Functions................................18
  114.                FoxPro Memo Functions.......................................18
  115.                dBASE Index File Functions..................................19
  116.                dBASE Index Page Functions..................................19
  117.                dBASE Index Key Functions...................................19
  118.                Clipper Index Functions.....................................20
  119.                FoxBase/FoxPro Index Functions..............................20
  120.  
  121.             Chapter 5 Clock & Calendar Functions...........................21
  122.                Conversion to String........................................21
  123.                Conversion to Integers......................................21
  124.  
  125.  
  126.  
  127.                                           i
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                                   TABLE OF CONTENTS
  137.  
  138.  
  139.                Conversion to Long Integer..................................21
  140.                Day of Week Conversions.....................................22
  141.                Month Conversions...........................................22
  142.                Date String Calculations....................................22
  143.                Date Validation and Testing.................................22
  144.                Get Current Date from DOS...................................22
  145.                Time String to Numeric Conversion...........................22
  146.                Time Numeric to String Conversion...........................22
  147.                Time String Calculations....................................23
  148.                Time Validation.............................................23
  149.                Get Current Time from DOS...................................23
  150.  
  151.             Chapter 6 Miscellaneous Functions..............................24
  152.                Program Initialization......................................24
  153.                Program Termination.........................................24
  154.                Library Version.............................................24
  155.                Default Date String Format..................................24
  156.                Errors and Warnings.........................................24
  157.  
  158.             Chapter 7 Sharing Files on a LAN...............................26
  159.                Updating a Data Record......................................26
  160.                Adding or Removing a Data Record............................27
  161.  
  162.             Chapter 8 The SoftC Database Library...........................29
  163.                sccdi2l.....................................................31
  164.                sccdi2s.....................................................31
  165.                sccdiget....................................................32
  166.                sccdileap...................................................33
  167.                sccdiperm...................................................34
  168.                sccdl2dow...................................................35
  169.                sccdl2i.....................................................35
  170.                sccdl2sx....................................................36
  171.                sccds2day...................................................37
  172.                sccds2dow...................................................38
  173.                sccds2i.....................................................39
  174.                sccds2lx....................................................40
  175.                sccds2mon...................................................41
  176.                sccds2s.....................................................42
  177.                sccdsday....................................................43
  178.                sccdsdiff...................................................44
  179.                sccdsget....................................................45
  180.                sccdsleap...................................................46
  181.                sccdsmonth..................................................47
  182.                sccdsperm...................................................48
  183.                sccdsvalid..................................................49
  184.                sccti2s.....................................................50
  185.                scctiget....................................................51
  186.                sccts2i.....................................................52
  187.                scctsdiff...................................................53
  188.                scctsget....................................................54
  189.                scctsvalid..................................................55
  190.  
  191.  
  192.  
  193.                                          ii
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                                   TABLE OF CONTENTS
  203.  
  204.  
  205.                scdcbfrsz...................................................56
  206.                scdcclose...................................................57
  207.                scdccreate..................................................58
  208.                scdcexpr....................................................59
  209.                scdcflush...................................................60
  210.                scdcindex...................................................61
  211.                scdchget....................................................62
  212.                scdcinfo....................................................63
  213.                scdckadd....................................................65
  214.                scdckbot....................................................66
  215.                scdckcur....................................................67
  216.                scdckdel....................................................68
  217.                scdckfind...................................................69
  218.                scdckmake...................................................71
  219.                scdcknext...................................................73
  220.                scdckprev...................................................74
  221.                scdcktop....................................................75
  222.                scdcopenx...................................................76
  223.                scddbfrsz...................................................77
  224.                scddbof.....................................................78
  225.                scddclose...................................................79
  226.                scddcreate..................................................80
  227.                scddeof.....................................................82
  228.                scddfget....................................................83
  229.                scddfgets...................................................85
  230.                scddfinfo...................................................86
  231.                scddflush...................................................88
  232.                scddfnam2no.................................................88
  233.                scddfput....................................................89
  234.                scddfputs...................................................91
  235.                scddhget....................................................92
  236.                scddinfo....................................................93
  237.                scddlock....................................................94
  238.                scddlud.....................................................95
  239.                scddopenx...................................................96
  240.                scddpack....................................................97
  241.                scddrclear..................................................98
  242.                scddrdel....................................................99
  243.                scddrget....................................................99
  244.                scddrgetx..................................................100
  245.                scddrinfo..................................................101
  246.                scddrlock..................................................102
  247.                scddrnum...................................................103
  248.                scddrput...................................................104
  249.                scddrputx..................................................105
  250.                scddrstat..................................................107
  251.                scddrundel.................................................108
  252.                scddsize...................................................109
  253.                scddunlock.................................................110
  254.                scdibfrsz..................................................111
  255.                scdiclose..................................................112
  256.  
  257.  
  258.  
  259.                                          iii
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                                   TABLE OF CONTENTS
  269.  
  270.  
  271.                scdicreate.................................................112
  272.                scdiexpr...................................................114
  273.                scdiflush..................................................115
  274.                scdihget...................................................116
  275.                scdiindex..................................................117
  276.                scdiinfo...................................................118
  277.                scdikadd...................................................119
  278.                scdikbot...................................................120
  279.                scdikcur...................................................121
  280.                scdikdate..................................................122
  281.                scdikdel...................................................123
  282.                scdikfind..................................................124
  283.                scdikmake..................................................126
  284.                scdiknext..................................................128
  285.                scdiknum...................................................130
  286.                scdikprev..................................................131
  287.                scdiktop...................................................132
  288.                scdinit....................................................134
  289.                scdiopenx..................................................134
  290.                scdnbfrsz..................................................136
  291.                scdnclose..................................................137
  292.                scdncreate.................................................137
  293.                scdnexpr...................................................138
  294.                scdnflush..................................................139
  295.                scdnhget...................................................140
  296.                scdnindex..................................................141
  297.                scdninfo...................................................142
  298.                scdnkadd...................................................143
  299.                scdnkbot...................................................144
  300.                scdnkcur...................................................146
  301.                scdnkdate..................................................147
  302.                scdnkdel...................................................148
  303.                scdnkfind..................................................149
  304.                scdnkmake..................................................151
  305.                scdnknext..................................................153
  306.                scdnkprev..................................................155
  307.                scdnktop...................................................157
  308.                scdnopenx..................................................158
  309.                scdtclose..................................................159
  310.                scdtcreate.................................................160
  311.                scdterm....................................................160
  312.                scdthget...................................................161
  313.                scdtinfo...................................................162
  314.                scdtopenx..................................................163
  315.                scdtpack...................................................164
  316.                scdtrget...................................................165
  317.                scdtrput...................................................166
  318.                scdwclose..................................................167
  319.                scdwcreate.................................................168
  320.                scdwhget...................................................168
  321.                scdwinfo...................................................169
  322.  
  323.  
  324.  
  325.                                          iv
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                                   TABLE OF CONTENTS
  335.  
  336.  
  337.                scdwopenx..................................................170
  338.                scdwpack...................................................171
  339.                scdwrget...................................................172
  340.                scdwrput...................................................173
  341.                sceclr.....................................................174
  342.                scemsg.....................................................175
  343.  
  344.             Appendix A Result Codes and Messages..........................177
  345.                Warning Codes and Messages.................................177
  346.                Error Codes and Messages...................................178
  347.                Other Messages.............................................186
  348.  
  349.             Appendix B Diskette TOC Demo Program..........................187
  350.  
  351.             Index.........................................................189
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.                                           v
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.             Chapter 1
  404.  
  405.  
  406.             Introduction
  407.  
  408.  
  409.  
  410.  
  411.             C is  generally considered  to be a "bare-bones" language. A
  412.             way  to  put  some  flesh  on  those  bones  is  to  develop
  413.             generalized functions  (extensions) which  may be  reused in
  414.             many programs.  The presence  of these  functions  can  make
  415.             programming a  quick and  simple task.  The absence of these
  416.             language extensions  can mean  many hours lost "re-inventing
  417.             the wheel".
  418.  
  419.  
  420.             Few programmers  have the time required to develop and debug
  421.             such a  library of functions. This is why the SoftC Database
  422.             Library  was  written.  It  is  a  collection  of  functions
  423.             designed to  make your  applications quicker  and easier  to
  424.             code and  test. With  the library you can spend time on your
  425.             application not on developing tools.
  426.  
  427.  
  428.             The SoftC  Database Library  adds powerful  capabilities  to
  429.             your function library:
  430.  
  431.  
  432.                  - data, memo, and index file access functions for:
  433.                       Clipper, dBASE III+, dBXL, FoxBase, FoxPro and
  434.                       Quicksilver.
  435.                  - dBASEIV data file functions
  436.                  - date and time manipulation and calculation
  437.  
  438.  
  439.             The SoftC Database Library is intended for use as a
  440.             supplement to your compiler's object libraries. It contains
  441.             120 user functions. The primary purpose of the library is to
  442.             provide completely compatible access to dBASE data, memo,
  443.             and index files. The clock/calendar functions have been
  444.             added to enhance the core dBASE routines. The library is
  445.             currently available for Microsoft C 5.x and 6.0, Quick C
  446.             2.x, Turbo C 2.0, and Turbo C++ 1.0. These routines are
  447.             written entirely in C.
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.             User's Reference Guide                   1
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.             CHAPTER 1, INTRODUCTION                   
  467.  
  468.  
  469.             Registration
  470.  
  471.             If you  find this  library useful,  you  are  encouraged  to
  472.             register.   Refer to  ORDER.DOC for  registration fees.   To
  473.             register,  read   the  license  agreement,  print  the  file
  474.             ORDER.DOC, and  mail the completed form and appropriate fees
  475.             to:
  476.  
  477.  
  478.                                     SoftC, Ltd.
  479.                               16820 Third Street N.E.
  480.                             Ham Lake, MN 55304-4703  USA
  481.  
  482.  
  483.             Shareware
  484.  
  485.             This library  is "shareware"  (user supported  software) NOT
  486.             "public domain",    which  means  that  the  SoftC  Database
  487.             Library  (including   the  demonstration  programs)  is  the
  488.             copyrighted property  of SoftC,  Ltd. Registered  users  are
  489.             legally bound  by the  terms and conditions set forth in the
  490.             license agreement.   Everyone  is granted  the right to make
  491.             copies and  to freely  share  the  UNMODIFIED  demonstration
  492.             programs.
  493.  
  494.  
  495.             The shareware  concept  is  an  attempt  to  provide  useful
  496.             software at low cost.  The expense of offering a new product
  497.             by conventional  means is  quite high  and thus  discourages
  498.             many independent authors and small companies from developing
  499.             and promoting  their ideas.   Shareware  is  an  attempt  to
  500.             develop a  new  marketing  channel  where  products  can  be
  501.             introduced at minimum cost.
  502.  
  503.  
  504.             Everyone will benefit if shareware works.  The user benefits
  505.             by having quality products at low cost, and by being able to
  506.             test software  thoroughly before  purchasing it.  The author
  507.             benefits by  being able  to enter  the  commercial  software
  508.             market without the need of large amounts of venture capital.
  509.  
  510.  
  511.             But it can only work with your support. If you obtain a user
  512.             supported product  from a  friend or coworker, and are still
  513.             using it  after a  few weeks,  then it  is  obviously  worth
  514.             something to you and you should register it.
  515.  
  516.  
  517.             Typographic Conventions
  518.  
  519.             []             Square brackets enclose optional data.
  520.  
  521.  
  522.  
  523.             2                   SoftC Database Library
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                                CHAPTER 1, INTRODUCTION
  533.  
  534.  
  535.             Boldface       SoftC Database Library function names (such
  536.                            as scdinit) and structure names when they
  537.                            appear in text (but not in program examples).
  538.             Underline      indicate variable name "identifiers" which
  539.                            appear in text.
  540.  
  541.  
  542.             Trademarks
  543.  
  544.             Clipper is a registered trademark of Nantucket Software.
  545.             dBASE, dBASEIII, and dBASEIV are registered trademarks of
  546.             Ashton-Tate.
  547.             dBXL is a registered trademark of WordTech Systems, Inc.
  548.             FoxBase and FoxPro are registered trademarks of Fox
  549.             Software.
  550.             Microsoft is a registered trademark of Microsoft
  551.             Corporation.
  552.             Quicksilver is a trademark of Quicksilver Software, Inc.
  553.             R&R Relational Report Writer is a registered trademark of
  554.             Concentric Data.
  555.             SoftC is a trademark of SoftC, Ltd.
  556.             Turbo C is a registered trademark of Borland International.
  557.  
  558.  
  559.             Support and Updates
  560.  
  561.             Technical advice  and technical  support will  be offered to
  562.             registered users  only.    Registered  users  will  also  be
  563.             notified when updates and new products are available.
  564.  
  565.  
  566.             We can be contacted by:
  567.  
  568.  
  569.             mail          SoftC, Ltd.
  570.                           16820 Third Street N.E.
  571.                           Ham Lake, MN 55304-4703  USA
  572.  
  573.             telephone/facsimile (612) 434-6968
  574.  
  575.             modem         We do not have a BBS, but we have a second
  576.                           telephone line which can be used to
  577.                           upload/download.  Please call the above number
  578.                           first so that arrangements can be made.
  579.  
  580.             GEnie         "K.SCHUMANN"
  581.  
  582.             CompuServ     73667,3420.
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.             User's Reference Guide                   3
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.             Chapter 2
  602.  
  603.  
  604.             Before You Begin
  605.  
  606.  
  607.  
  608.  
  609.             This  chapter   supplies  instructions  for  installing  the
  610.             library on your hard disk and compiling the source.
  611.  
  612.  
  613.             The READ.ME File
  614.  
  615.             For last  minute update  information not  contained in  this
  616.             documentation, and/or a brief description of what's new with
  617.             this release please read the READ.ME file.
  618.  
  619.  
  620.             The Demonstration Package
  621.  
  622.             The SoftC Database Library demonstration package consists of
  623.             several archive files: DOCS.xxx - documentation for library,
  624.             SAMPLE.xxx -  sample programs,  HEADERS.xxx -  header files,
  625.             and the small memory model libraries for supported compilers
  626.             and operating  systems.   You are encouraged to freely share
  627.             these  completely   unmodified  programs  with  others.  The
  628.             documentation archive file contains three (3) files:
  629.  
  630.  
  631.             LICENSE.DOC   MANUAL.DOC    ORDER.DOC
  632.  
  633.  
  634.             The small memory model library archives are:
  635.  
  636.  
  637.             MSC5S.xxx     Microsoft C 5.x
  638.             MSC6S.xxx     Microsoft C 6.0
  639.             TC2S.xxx      Turbo C 2.0
  640.             TCP1S.xxx     Turbo C++ 1.0
  641.             ZTC2S.xxx     Zortech 2.0
  642.             OS2S.xxx      Microsoft C 6.0 for OS/2
  643.  
  644.  
  645.             Sample Files
  646.  
  647.             There are  three sample  files provided  in the archive file
  648.             SAMPLE.COM. They  are variations of the program described in
  649.             Appendix B.
  650.  
  651.  
  652.  
  653.  
  654.  
  655.             User's Reference Guide                   4
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                            CHAPTER 2, BEFORE YOU BEGIN
  665.  
  666.  
  667.             CLIPPER.C     Clipper version
  668.             DBASE.C       dBASE III version
  669.             FOXBASE.C     FoxBASE/FoxPro version
  670.  
  671.  
  672.             Header Files
  673.  
  674.             There are  three header  files provided  in the archive file
  675.             HEADERS.COM:
  676.  
  677.  
  678.             SOFTC.H       SC_BASE.H     SC_CLOCK.H
  679.  
  680.  
  681.             SOFTC.H contains  some common prototypes and definitions for
  682.             error/warning   codes.    SC_BASE.H    contains    structure
  683.             definitions and  prototypes for  data, memo,  and index file
  684.             input/output. SC_CLOCK.H  contains structure definitions and
  685.             prototypes for clock and calendar functions.
  686.  
  687.  
  688.             There are  two additional  header files  provided  to  users
  689.             registered at  the source  code level  in the  archive  file
  690.             HEAD.COM:
  691.  
  692.  
  693.             SOFTC.NTL     SC_BASE.NTL
  694.  
  695.  
  696.             SOFTC.NTL  contains  some  common  internal  prototypes  and
  697.             definitions. SC_BASE.NTL  contains structure definitions and
  698.             internal  prototypes   for  data,   memo,  and   index  file
  699.             input/output.
  700.  
  701.  
  702.             Help Files
  703.  
  704.             There are two help files included in the package:
  705.  
  706.  
  707.             GUIDE.COM     MSC-HELP.EXE
  708.  
  709.  
  710.             GUIDE.COM is  a Norton  Guide compatible database containing
  711.             function  and  error/warning  code  descriptions,  structure
  712.             definitions, etc.  MSC-HELP.EXE is  a Microsoft Programmer's
  713.             Workbench compatible  help file  containing  much  the  same
  714.             information as GUIDE.COM.
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.             User's Reference Guide                   5
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.             CHAPTER 2, BEFORE YOU BEGIN               
  731.  
  732.  
  733.             Library Object Code Files
  734.  
  735.             Each  of  the  memory  model  libraries  for  your  selected
  736.             compiler is  archived in  its own  individual file.  This is
  737.             done so  that you  can extract  only the  memory  model  you
  738.             actually need.
  739.  
  740.  
  741.             SMALL.EXE     Small memory model library
  742.             MEDIUM.EXE    Medium
  743.             COMPACT.EXE   Compact
  744.             LARGE.EXE     Large
  745.             HUGE.EXE      Huge
  746.  
  747.  
  748.             The HUGE  memory model  library will  not be present for all
  749.             compilers.
  750.  
  751.  
  752.             Library Source Files
  753.  
  754.             The source  code archive  (SOURCE.EXE), for users registered
  755.             at that level, contains 139 files:
  756.  
  757.  
  758.             CBFRSZ.C      CCREATE.C     CDI2L.C
  759.             CDI2S.C       CDIGET.C      CDILEAP.C
  760.             CDIPERM.C     CDL2DOW.C     CDL2I.C
  761.             CDL2S.C       CDS2DAY.C     CDS2DOW.C
  762.             CDS2I.C       CDS2L.C       CDS2MON.C
  763.             CDS2S.C       CDSDAY.C      CDSDIFF.C
  764.             CDSGET.C      CDSLEAP.C     CDSMONTH.C
  765.             CDSPERM.C     CDSVALID.C    CEXPR.C
  766.             CFLUSH.C      CHGET.C       CINDEX.C
  767.             CINFO.C       CKADD.C       CKBOT.C
  768.             CKCUR.C       CKDEL.C       CKFIND.C
  769.             CKMAKE.C      CKNEXT.C      CKPREV.C
  770.             CKTOP.C       COPEN.C       CPGET.C
  771.             CPPUT.C       CTI2S.C       CTIGET.C
  772.             CTS2I.C       CTSDIFF.C     CTSGET.C
  773.             CTSVALID.C    DBFRSZ.C      DBOF.C
  774.             DCREATE.C     DEOF.C        DFGET.C
  775.             DFINFO.C      DFLUSH.C      DFNAM2NO.C
  776.             DFPUT.C       DHGET.C       DINFO.C
  777.             DLOCK.C       DLUD.C        DOPEN.C
  778.             DPACK.C       DRCLEAR.C     DRGET.C
  779.             DRINFO.C      DRNUM.C       DRPUT.C
  780.             DRSTAT.C      DSIZE.C       EMSG.C
  781.             ERRLOG.C      HCREATE.C     HEOF.C
  782.             HERASE.C      HEXIST.C      HFLUSH.C
  783.             HLEN.C        HLOCK.C       HREAD.C
  784.  
  785.  
  786.  
  787.             6                   SoftC Database Library
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                            CHAPTER 2, BEFORE YOU BEGIN
  797.  
  798.  
  799.             HRENAME.C     HSEEK.C       HSIZE.C
  800.             HTELL.C       HWRITE.C      IBFRSZ.C
  801.             ICREATE.C     IEXPR.C       IFLUSH.C
  802.             IHGET.C       IINDEX.C      IINFO.C
  803.             IKADD.C       IKBOT.C       IKCUR.C
  804.             IKDATE.C      IKDEL.C       IKFIND.C
  805.             IKMAKE.C      IKNEXT.C      IKPREV.C
  806.             IKTOP.C       INIT.C        IOPEN.C
  807.             IPGET.C       IPPUT.C       NBFRSZ.C
  808.             NCREATE.C     NEXPR.C       NFLUSH.C
  809.             NHGET.C       NINDEX.C      NINFO.C
  810.             NKADD.C       NKBOT.C       NKCUR.C
  811.             NKDATE.C      NKDEL.C       NKFIND.C
  812.             NKMAKE.C      NKNEXT.C      NKPREV.C
  813.             NKTOP.C       NOPEN.C       NPGET.C
  814.             NPPUT.C       STRUPR.C      TCREATE.C
  815.             THGET.C       TINFO.C       TOPEN.C
  816.             TPACK.C       TRGET.C       TRPUT.C
  817.             WCREATE.C     WHGET.C       WINFO.C
  818.             WOPEN.C       WPACK.C       WRGET.C
  819.             WRPUT.C
  820.  
  821.  
  822.             Installing SoftC on Your System
  823.  
  824.             The SoftC  Database Library   source code is compatible with
  825.             all of  the compilers  which we  support.  The  object  code
  826.             provided is for a specific C compiler.
  827.  
  828.  
  829.             Many compiler  manufacturers  suggest  a  certain  directory
  830.             setup to enable the compiler to find the header, object, and
  831.             library files.  Rather than  trying to  explain the  various
  832.             manufacturers suggested  directory setups,  we will  explain
  833.             what files are required and where they are often located.
  834.  
  835.  
  836.             The library header files need to be placed where they can be
  837.             found by  your compiler.  In many cases this is in a special
  838.             "INCLUDE" directory.  Other times they are placed where your
  839.             source code  is found.  We would suggest that they be placed
  840.             where the header files for your compiler are located.
  841.  
  842.  
  843.             Your linker  will need  to be  able to find the SoftC object
  844.             code libraries.  It is  suggested that these be placed where
  845.             the run-time libraries for your compiler are found.
  846.  
  847.  
  848.             The name  of the  library defines  the compiler manufacturer
  849.             and version, and the memory model for which it was compiled.
  850.  
  851.  
  852.  
  853.             User's Reference Guide                   7
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.             CHAPTER 2, BEFORE YOU BEGIN               
  863.  
  864.  
  865.             All library  names begin with "SCD". The next few characters
  866.             specify the  compiler manufacturer  and  version.  The  last
  867.             character defines the memory model.
  868.  
  869.  
  870.             For example  SCDTC20S.LIB is  the small memory model library
  871.             for Borland's Turbo C compiler (version 2.0x).
  872.  
  873.  
  874.             SoftC Applications
  875.  
  876.             A typical application skeleton has the following form:
  877.  
  878.  
  879.                       #include <sc_base.h>
  880.  
  881.                       /* global declarations */
  882.  
  883.                       void main()
  884.                       {
  885.                         /* local declarations */
  886.  
  887.                         scdinit(15,0);
  888.                         atexit(scdterm());
  889.                         .
  890.                         .
  891.                         .
  892.                         /* body of application */
  893.                         .
  894.                         .
  895.                         .
  896.                       }
  897.  
  898.  
  899.             The scdinit  function must  be the  first function called in
  900.             your application  and IT  MUST BE CALLED ONLY ONCE. The last
  901.             function should be scdterm. This is not a requirement but it
  902.             is good  programming practice.  This function should also be
  903.             called only once. See the descriptions of these functions in
  904.             the library reference section of this manual.
  905.  
  906.  
  907.             Compiling with Microsoft C
  908.  
  909.             To use  the library  with Microsoft's  command line compiler
  910.             simply include the library name in the file name list:
  911.  
  912.  
  913.             cl /AS /Zp myprog scdmc50s.lib
  914.  
  915.  
  916.  
  917.  
  918.  
  919.             8                   SoftC Database Library
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                            CHAPTER 2, BEFORE YOU BEGIN
  929.  
  930.  
  931.             The above example used the small memory model for C 5.x. Use
  932.             SCDMC60S.LIB for C 6.0.
  933.  
  934.  
  935.             Compiling with Quick C
  936.  
  937.             To use  the library  with Quick  C's command  line  compiler
  938.             simply include the library name in the file name list:
  939.  
  940.  
  941.             qcl /AS /Zp myprog /link scdmc50s.lib
  942.  
  943.  
  944.             Compiling with Turbo C
  945.  
  946.             Turbo  C  provides  two  ways  of  compiling  programs:  the
  947.             integrated environment  and the  command  line  version.  In
  948.             order to  use the SoftC Database Library with the integrated
  949.             environment  a   project  file   must  be  created  and  the
  950.             appropriate library must be specified in that file:
  951.  
  952.  
  953.             myprog              /* your program name */
  954.             scdtc20s.lib        /* the desired SoftC Database library */
  955.  
  956.  
  957.             To use  the library  with the  command line  compiler simply
  958.             include the library name in the file name list:
  959.  
  960.  
  961.             tcc -ms -I<header_file_path> -L<lib_file_path> myprog
  962.             scdtc20s.lib
  963.  
  964.  
  965.             Compiling with Turbo C++
  966.  
  967.             To use  the library  with Turbo  C++'s command line compiler
  968.             simply include the library name in the file name list:
  969.  
  970.  
  971.             tcc -ms -I<header_file_path> -L<lib_file_path> myprog
  972.             scdtp10s.lib
  973.  
  974.  
  975.             Compiling with Zortech C++
  976.  
  977.             To use  the library with Zortech C++'s command line compiler
  978.             simply include the library name in the file name list:
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.             User's Reference Guide                   9
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.             CHAPTER 2, BEFORE YOU BEGIN               
  995.  
  996.  
  997.             ztc -a -b -c -I<header_file_path> -ms -o -r myprog
  998.             scdzc20s.lib
  999.  
  1000.  
  1001.             Recompiling the Database Libraries
  1002.  
  1003.             If you  modify a  SoftC Database Library source module, then
  1004.             that module  and  any  related  modules  (if  any)  must  be
  1005.             recompiled and replaced in the libraries. The library source
  1006.             code is compiled just like any other program.
  1007.  
  1008.  
  1009.             Microsoft C command line:
  1010.  
  1011.  
  1012.             cl /AS /c /D__PCDOS__ /Olt /W3 /Zp *.c
  1013.  
  1014.  
  1015.             Quick C command line:
  1016.  
  1017.  
  1018.             qcl /AS /c /D__PCDOS__ /W3 /Zp *.c
  1019.  
  1020.  
  1021.             Turbo C/C++ command line:
  1022.  
  1023.  
  1024.             tcc -c -D__PCDOS__ -I<header_file_path> -ms -O *.c
  1025.  
  1026.  
  1027.             Zortech C++ command line:
  1028.  
  1029.  
  1030.             ztc -a -b -c -D__PCDOS__ -I<header_file_path> -ms -o -r *.c
  1031.  
  1032.  
  1033.             Refer to  your compiler  documentation for  instructions for
  1034.             replacing modules in libraries.
  1035.  
  1036.  
  1037.             OS/2, Windows 3.0 and UNIX Support
  1038.  
  1039.             Although we  can not  provide  complete  support  for  OS/2,
  1040.             Windows 3.0  and UNIX/XENIX,  the library  is being  used in
  1041.             each of  these environments  now.   The source  code for the
  1042.             library has  support for OS/2 and UNIX/XENIX built in and we
  1043.             do have a set of libraries built specifically for OS/2.
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.             10                  SoftC Database Library
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                            CHAPTER 2, BEFORE YOU BEGIN
  1061.  
  1062.  
  1063.             Function Naming Conventions
  1064.  
  1065.             All of  the SoftC  Database Library functions begin with the
  1066.             letters  "sc".  This  is  to  differentiate  them  from  the
  1067.             standard library functions.
  1068.  
  1069.  
  1070.             "scc"     clock/calendar functions
  1071.  
  1072.                  "sccd"    date or calendar functions
  1073.                  "scct"    time functions
  1074.  
  1075.  
  1076.             "scd"     database file functions
  1077.  
  1078.                  "scdc"    Clipper index file functions (open, close,
  1079.                            etc.)
  1080.                  "scdck"   Clipper index key functions (add, delete,
  1081.                            etc.)
  1082.  
  1083.                  "scdd"    dBASE data file functions (open, close, etc.)
  1084.                  "scddf"   dBASE data field functions
  1085.                  "scddr"   dBASE data record functions (write, read,
  1086.                            delete, ...)
  1087.  
  1088.                  "scdi"    FoxBase/FoxPro index file functions (open,
  1089.                            close, etc.)
  1090.                  "scdik"   FoxBase/FoxPro index key functions (add,
  1091.                            delete, etc.)
  1092.  
  1093.                  "scdn"    dBASE index file functions (open, close,
  1094.                            etc.)
  1095.                  "scdnk"   dBASE index key functions (add, delete, etc.)
  1096.  
  1097.                  "scdt"    memo file functions (open, close, etc.)
  1098.  
  1099.                  "scdw"    FoxPro memo file functions (open, close,
  1100.                            etc.)
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.             User's Reference Guide                  11
  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/FoxPro  compatible data,  memo,
  1143.             and 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.             User's Reference Guide                  12
  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.             User's Reference Guide                  13
  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/FoxPro 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.             14                  SoftC Database Library
  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.             User's Reference Guide                  15
  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 want
  1427.             to save  use scddpack  to "pack" the data file. All inactive
  1428.             data records  will be  removed from  the file  and the  file
  1429.             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
  1441.             (" ").  This has  the effect  on numeric  fields of  placing
  1442.             nothing in the field rather than zero.
  1443.  
  1444.  
  1445.  
  1446.  
  1447.             16                  SoftC Database Library
  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.             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.             User's Reference Guide                  17
  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.             FoxPro Memo Functions
  1571.  
  1572.             All the  dBASE Memo  File functions listed above have FoxPro
  1573.             equivalents. There are two differences between dBASE III and
  1574.             FoxPro memo files: dBASE uses a constant 512 byte block size
  1575.             where FoxPro  allows the  block size to be selected (between
  1576.  
  1577.  
  1578.  
  1579.             18                  SoftC Database Library
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                          CHAPTER 4, DATABASE FUNCTIONS
  1589.  
  1590.  
  1591.             33 and  16384 bytes),  and dBASE always appends memo text at
  1592.             the end  of the file where FoxPro will allow you to update a
  1593.             memo block.
  1594.  
  1595.  
  1596.             dBASE Index File Functions
  1597.  
  1598.             In order  to use  an index  file it  first must  be  opened.
  1599.             scdnopenx will  open any  dBASEIII,  dBASEIII+,  or  dBASEIV
  1600.             compatible index  file (.NDX).  The SoftC  Database  Library
  1601.             file manager  handle will  be returned.  This handle  number
  1602.             must be used for all I/O with that specific index file.
  1603.  
  1604.  
  1605.             When you  are finished  with an index file, it can be closed
  1606.             via a  call to  scdnclose. Information  about the index file
  1607.             such as  the file  name and length of the key expression can
  1608.             be retrieved  by a call to scdninfo. A new index file can be
  1609.             created by using the function scdncreate.
  1610.  
  1611.  
  1612.             scdnexpr can be used to get the actual index key expression.
  1613.             This key expression is generally a formula listing the field
  1614.             names used  to make  the index  key. For example, FIRST_NAME
  1615.             and LAST_NAME  are both  fields found  in a data file. If an
  1616.             index key was made from the combination of these fields, the
  1617.             key expression could be "LAST_NAME + FIRST_NAME".
  1618.  
  1619.  
  1620.             The functional  equivalent to  dBASE's "INDEX ON" command is
  1621.             provided by  scdnindex. This  function will  build an  index
  1622.             file.
  1623.  
  1624.  
  1625.             dBASE Index Page Functions
  1626.  
  1627.             Page I/O  will be  buffered if the file was opened using the
  1628.             SC_BUFFER switch.  scdnflush will flush all buffered data to
  1629.             the disk.  To get  the current  size of the I/O buffer or to
  1630.             change it, use scdnbfrsz.
  1631.  
  1632.  
  1633.             dBASE Index Key Functions
  1634.  
  1635.             Twelve functions  have been  provided for  use in: finding a
  1636.             key, moving  to the  next or previous key, adding/deleting a
  1637.             key, retrieving  the current  key, and building a key. There
  1638.             are three  search functions  supported: find  the first  key
  1639.             (scdnktop), find  the last  key (scdnkbot), and search for a
  1640.             specific key  (scdnkfind). The  keys found  in  this  manner
  1641.  
  1642.  
  1643.  
  1644.  
  1645.             User's Reference Guide                  19
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.             CHAPTER 4, DATABASE FUNCTIONS             
  1655.  
  1656.  
  1657.             become the  "current key".  Wildcards such  as "?"  and  "*"
  1658.             cannot be used.
  1659.  
  1660.  
  1661.             Once a  particular key  is found  it is often desired to get
  1662.             the key  following (scdnknext)  or preceding (scdnkprev) it.
  1663.             These keys,  if  found,  become  the  current  key.  Another
  1664.             function is provided to return the current key, scdnkcur.
  1665.  
  1666.  
  1667.             It is  also desirable to be able to add and delete keys from
  1668.             the  index   file.  scdnkadd   and  scdnkdel  provide  these
  1669.             functions.
  1670.  
  1671.  
  1672.             A function  is supplied   to  convert date  fields to  valid
  1673.             index keys,  scdnkdate allows  the user  to specify the date
  1674.             string format.
  1675.  
  1676.  
  1677.             dBASE provides  certain functions which may be used in a key
  1678.             expression. scdnkmake  will build  a key  for you  using the
  1679.             index  key  expression  and  the  current  contents  of  the
  1680.             internal record  buffer of  the  data  file.  This  function
  1681.             supports five  of the  more common  dBASE  functions:  dtoc,
  1682.             left, right,  str, and  substr (and  the various  legitimate
  1683.             combinations). Note  that this function is not necessary for
  1684.             single  field   character  or   numeric  keys,  but  it  (or
  1685.             scdnkdate) can be used for date keys.
  1686.  
  1687.  
  1688.             Clipper Index Functions
  1689.  
  1690.             All the dBASE Index File functions listed above have Clipper
  1691.             equivalents with  the exception  of scdnkdate.  Clipper does
  1692.             not need the functionality provided by this function.
  1693.  
  1694.  
  1695.             FoxBase/FoxPro Index Functions
  1696.  
  1697.             All  the  dBASE  Index  File  functions  listed  above  have
  1698.             FoxBase/FoxPro   equivalents.    FoxBase/FoxPro   has    one
  1699.             additional function used to create a numeric key (scdiknum).
  1700.             The FoxBase/FoxPro  numeric key  format as stored on disk is
  1701.             different from 'C' doubles.
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.             20                  SoftC Database Library
  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.             User's Reference Guide                  21
  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.             22                  SoftC Database Library
  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.             User's Reference Guide                  23
  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.             User's Reference Guide                  24
  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.             User's Reference Guide                  25
  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
  2082.                       record cannot be locked then wait for a period of
  2083.                       time and try again. If after a reasonable number
  2084.                       of 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
  2092.                       then either go back to step 3, or if changes made
  2093.                       by others are unaffected by your changes then
  2094.                       update 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.             User's Reference Guide                  26
  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
  2130.                       record cannot be locked, then wait for a period of
  2131.                       time and try again. If after a reasonable number
  2132.                       of 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
  2140.                       then either unlock the file and go back to step 4,
  2141.                       or if changes made by others are unaffected by
  2142.                       your changes then update modified fields and
  2143.                       continue.
  2144.                       8)   Modify any memo or index files required.
  2145.                       9)   Update the record.
  2146.                       10)  Unlock the file.
  2147.  
  2148.  
  2149.  
  2150.             The memo  file must  be updated before the data file because
  2151.             the memo record number must be recorded in the data record.
  2152.  
  2153.  
  2154.             Adding or Removing a Data Record
  2155.  
  2156.             The proper  sequence to  follow when  adding or  removing  a
  2157.             record is:
  2158.  
  2159.  
  2160.                       1)   Lock the data file. If the file cannot be
  2161.                       locked, then wait for a period of time and try
  2162.                       again. If after a reasonable number of retries the
  2163.                       file still cannot be locked then fail.
  2164.                       2)   Modify memo file as needed.
  2165.                       3)   Add or delete the record.
  2166.                       4)   Update index file(s) as needed.
  2167.                       5)   Unlock the file.
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.             User's Reference Guide                  27
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.             CHAPTER 7, SHARING FILES ON A LAN         
  2183.  
  2184.  
  2185.             The memo  file must  be updated before the data file because
  2186.             the memo  record number must be recorded in the data record.
  2187.             The index  file(s) must  be updated after the data record is
  2188.             added because  the data  record number  is written  into the
  2189.             index file along with the key.
  2190.  
  2191.  
  2192.             The  locking  mechanisms  provided  by  dBASE  (Clipper  and
  2193.             FoxBase/FoxPro as  well) are  very simple  and  crude.  Many
  2194.             other schemes  exist to  provide a  more elegant solution to
  2195.             the locking  problem, but  keep in  mind that  they are  not
  2196.             implicitly compatible  with dBASE.  They will  not work with
  2197.             dBASEIII+'s ASSIST  or with  R&R Report Writer, for example.
  2198.             We would  advise caution when contemplating straying too far
  2199.             from the dBASE standards.
  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.             28                  SoftC Database Library
  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/FoxPro 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.             Guide.
  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.             User's Reference Guide                  29
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  2315.  
  2316.  
  2317.             function name_____________________________
  2318.  
  2319.                            USAGE     function(
  2320.                       modifier parameter[,...]);
  2321.  
  2322.                       The declaration syntax for function, "parameter"
  2323.                       names are underlined. The [,...] indicates that
  2324.                       other parameters and their modifiers may follow.
  2325.  
  2326.             PROTOTYPE IN          This lists the header files in which
  2327.                       the function is prototyped.
  2328.  
  2329.             DESCRIPTION           This describes what the function does,
  2330.                       the parameters it takes, and any details you need
  2331.                       in order to use the function and the related
  2332.                       routines listed.
  2333.  
  2334.             RETURN VALUE          Some of the return codes are listed
  2335.                       here for selected functions.  A complete listing
  2336.                       of all return codes can be found in Appendix A.
  2337.  
  2338.              SEE ALSO Routines related to the function about which you
  2339.                       may wish to read are listed here.
  2340.  
  2341.               EXAMPLE A sample program listing demonstrating how the
  2342.                       function is used.
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.             30                  SoftC Database Library
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2381.  
  2382.  
  2383.             sccdi2l___________________________________
  2384.  
  2385.                            USAGE      int sccdi2l(
  2386.                        long *date,
  2387.                        int year,
  2388.                        int month,
  2389.                        int day );
  2390.  
  2391.             PROTOTYPE IN          sc_clock.h
  2392.  
  2393.             DESCRIPTION           sccdi2l converts three integer date
  2394.                       values ("year", "month", and "day") into a long
  2395.                       integer.  The integer values are verified to be a
  2396.                       valid date before conversion.
  2397.  
  2398.              SEE ALSO sccdl2i.
  2399.  
  2400.               EXAMPLE #include <stdio.h>
  2401.                       #include <softc.h>
  2402.                       #include <sc_clock.h>
  2403.  
  2404.                       void main()
  2405.                       {
  2406.                         int year = 1990, month = 5, day = 16;
  2407.                         long date = 0L;
  2408.  
  2409.                         scdinit(20,0);
  2410.                         sccdi2l(&date, year, month, day);
  2411.                         printf("%d %d %d = %ld\n", year, month, day,
  2412.                       date);
  2413.                         scdterm();
  2414.                       }
  2415.  
  2416.  
  2417.             sccdi2s___________________________________
  2418.  
  2419.                            USAGE     int sccdi2s(
  2420.                       char *string,
  2421.                       int format,
  2422.                       int year,
  2423.                       int month,
  2424.                       int day );
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.             User's Reference Guide                  31
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  2447.  
  2448.  
  2449.             PROTOTYPE IN          sc_clock.h
  2450.  
  2451.             DESCRIPTION           sccdi2s converts three integer date
  2452.                       values ("year", "month", and "day") into an ASCIIZ
  2453.                       string "string" using the date string style
  2454.                       "format". A check is made to verify that "string"
  2455.                       is a valid date string before exiting.
  2456.  
  2457.                       Date string styles:
  2458.  
  2459.  
  2460.                       SC_GREGOR   mm/dd/yy
  2461.  
  2462.  
  2463.                       SC_GREGORL  mm/dd/yyyy
  2464.  
  2465.  
  2466.                       SC_JULIAN   yyyy/ddd
  2467.  
  2468.  
  2469.                       SC_YMD      yyyymmdd
  2470.  
  2471.  
  2472.                       SC_DMY      ddmmyy
  2473.  
  2474.              SEE ALSO sccdsvalid, sccds2i.
  2475.  
  2476.               EXAMPLE #include <stdio.h>
  2477.                       #include <softc.h>
  2478.                       #include <sc_clock.h>
  2479.  
  2480.                       void main()
  2481.                       {
  2482.                         char d[9];
  2483.  
  2484.                         sccdi2s(d,SC_YMD,1989,2,13);
  2485.                         puts(d);
  2486.                       }
  2487.  
  2488.  
  2489.             sccdiget__________________________________
  2490.  
  2491.                            USAGE     int sccdiget(
  2492.                       int *year,
  2493.                       int *month,
  2494.                       int *monthday,
  2495.                       int *dayofweek );
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.             32                  SoftC Database Library
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2513.  
  2514.  
  2515.             PROTOTYPE IN          sc_clock.h
  2516.  
  2517.             DESCRIPTION           sccdiget returns the current date in
  2518.                       integer form from DOS.
  2519.  
  2520.              SEE ALSO sccdsget.
  2521.  
  2522.               EXAMPLE #include <stdio.h>
  2523.                       #include <softc.h>
  2524.                       #include <sc_clock.h>
  2525.  
  2526.                       void main()
  2527.                       {
  2528.                         int year, month, dayofmonth, dayofweek;
  2529.  
  2530.                         sccdiget(&year, &month, &dayofmonth,
  2531.                       &dayofweek);
  2532.                         printf("%d %d %d %d\n",year, month, dayofmonth,
  2533.                       dayofweek);
  2534.                       }
  2535.  
  2536.  
  2537.             sccdileap_________________________________
  2538.  
  2539.                            USAGE     int sccdileap(
  2540.                       int leap );
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.             User's Reference Guide                  33
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  2579.  
  2580.  
  2581.             PROTOTYPE IN          sc_clock.h
  2582.  
  2583.             DESCRIPTION           sccdileap tests the integer year
  2584.                       passed to it in "leap" to see if it is a leap
  2585.                       year.
  2586.  
  2587.             RETURN VALUE          SC_TRUE is leap year
  2588.  
  2589.  
  2590.                       SC_FALSE    not leap year
  2591.  
  2592.              SEE ALSO sccdsleap.
  2593.  
  2594.               EXAMPLE #include <stdio.h>
  2595.                       #include <softc.h>
  2596.                       #include <sc_clock.h>
  2597.  
  2598.                       void main()
  2599.                       {
  2600.                         if (sccdileap(1989))
  2601.                           puts("Leap Year!");
  2602.                         else
  2603.                           puts("Normal Year.");
  2604.                       }
  2605.  
  2606.  
  2607.             sccdiperm_________________________________
  2608.  
  2609.                            USAGE     int sccdiperm(
  2610.                       char *days,
  2611.                       int year,
  2612.                       int month );
  2613.  
  2614.             PROTOTYPE IN          sc_clock.h
  2615.  
  2616.             DESCRIPTION           sccdiperm calculates the number of
  2617.                       "days" in "month" for "year". This function also
  2618.                       senses leap year and will properly return 29 days
  2619.                       for February.
  2620.  
  2621.              SEE ALSO sccdsperm.
  2622.  
  2623.               EXAMPLE #include <stdio.h>
  2624.                       #include <softc.h>
  2625.                       #include <sc_clock.h>
  2626.  
  2627.                       void main()
  2628.                       {
  2629.                         char d;
  2630.  
  2631.                         sccdiperm(&d,1989,3);
  2632.  
  2633.  
  2634.  
  2635.             34                  SoftC Database Library
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2645.  
  2646.  
  2647.                         printf("%d",d);
  2648.                       }
  2649.  
  2650.  
  2651.             sccdl2dow_________________________________
  2652.  
  2653.                            USAGE     int sccdl2dow(
  2654.                       char *dayofweek,
  2655.                       long date );
  2656.  
  2657.             PROTOTYPE IN          sc_clock.h
  2658.  
  2659.             DESCRIPTION           sccdl2dow converts a long integer
  2660.                       "date" to an integer "dayofweek". "dayofweek" will
  2661.                       be a value between 0 (Sunday) and 6 (Saturday).
  2662.  
  2663.              SEE ALSO sccds2dow.
  2664.  
  2665.               EXAMPLE #include <stdio.h>
  2666.                       #include <softc.h>
  2667.                       #include <sc_clock.h>
  2668.  
  2669.                       void main()
  2670.                       {
  2671.                         char dayofweek;
  2672.                         long date;
  2673.  
  2674.                         sccdi2l(&date,1990,5,16);
  2675.                         sccdl2dow(&dayofweek,date);
  2676.                         printf("%d\n",dayofweek);
  2677.                       }
  2678.  
  2679.  
  2680.             sccdl2i___________________________________
  2681.  
  2682.                            USAGE     int sccdl2i(
  2683.                       int *year,
  2684.                       int *month,
  2685.                       int *day,
  2686.                       long date );
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.             User's Reference Guide                  35
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  2711.  
  2712.  
  2713.             PROTOTYPE IN          sc_clock.h
  2714.  
  2715.             DESCRIPTION           sccdl2i converts a long integer "date"
  2716.                       into three integers: "year", "month", and "day".
  2717.                       The long "date" is tested for validity before the
  2718.                       conversion takes place.
  2719.  
  2720.              SEE ALSO sccdi2l.
  2721.  
  2722.               EXAMPLE #include <stdio.h>
  2723.                       #include <softc.h>
  2724.                       #include <sc_clock.h>
  2725.  
  2726.                       void main()
  2727.                       {
  2728.                         int year, month, day;
  2729.                         long date;
  2730.  
  2731.                         sccdi2l(&date,1990,5,16);
  2732.                         date++;
  2733.                         sccdl2i(&year,&month,&day,date);
  2734.                         printf("%d %d %d\n",year,month,day);
  2735.                       }
  2736.  
  2737.  
  2738.             sccdl2sx__________________________________
  2739.  
  2740.                            USAGE     int sccdl2sx(
  2741.                       char *string,
  2742.                       int format,
  2743.                       long date);
  2744.  
  2745.             PROTOTYPE IN          sc_clock.h
  2746.  
  2747.             DESCRIPTION           sccdl2sx converts a long "date"  into
  2748.                       an ASCIIZ string "string" of the date style
  2749.                       "format". A check is made to verify that "string"
  2750.                       is a valid date string before exiting.
  2751.  
  2752.                       Date string styles:
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.             36                  SoftC Database Library
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2777.  
  2778.  
  2779.                       SC_GREGOR   mm/dd/yy
  2780.  
  2781.  
  2782.                       SC_GREGORL  mm/dd/yyyy
  2783.  
  2784.  
  2785.                       SC_JULIAN   yyyy/ddd
  2786.  
  2787.  
  2788.                       SC_YMD      yyyymmdd
  2789.  
  2790.  
  2791.                       SC_DMY      ddmmyy
  2792.  
  2793.              SEE ALSO sccds2lx.
  2794.  
  2795.               EXAMPLE #include <stdio.h>
  2796.                       #include <softc.h>
  2797.                       #include <sc_clock.h>
  2798.  
  2799.                       void main()
  2800.                       {
  2801.                         char d[9];
  2802.  
  2803.                         sccdl2sx(d,SC_YMD,726489);
  2804.                         puts(d);
  2805.                       }
  2806.  
  2807.  
  2808.             sccds2day_________________________________
  2809.  
  2810.                            USAGE     int sccds2day(
  2811.                       char *dayofweek,
  2812.                       char *daystr,
  2813.                       int format );
  2814.  
  2815.             PROTOTYPE IN          sc_clock.h
  2816.  
  2817.             DESCRIPTION           sccds2day converts an ASCIIZ string
  2818.                       date "datestr" of style "format" to an ASCIIZ
  2819.                       string "dayofweek". "dayofweek" will be a NULL
  2820.                       terminated string "Sunday" ... "Saturday".
  2821.  
  2822.                       Date string styles:
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.             User's Reference Guide                  37
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  2843.  
  2844.  
  2845.                       SC_GREGOR   mm/dd/yy
  2846.  
  2847.  
  2848.                       SC_GREGORL  mm/dd/yyyy
  2849.  
  2850.  
  2851.                       SC_JULIAN   yyyy/ddd
  2852.  
  2853.  
  2854.                       SC_YMD      yyyymmdd
  2855.  
  2856.  
  2857.                       SC_DMY      ddmmyy
  2858.  
  2859.              SEE ALSO sccds2dow.
  2860.  
  2861.               EXAMPLE #include <stdio.h>
  2862.                       #include <softc.h>
  2863.                       #include <sc_clock.h>
  2864.  
  2865.                       void main()
  2866.                       {
  2867.                         char dayofweek[10];
  2868.  
  2869.                         sccds2day(dayofweek, "19900516", SC_YMD);
  2870.                         printf("%s\n",dayofweek);
  2871.                       }
  2872.  
  2873.  
  2874.             sccds2dow_________________________________
  2875.  
  2876.                            USAGE     int sccds2dow(
  2877.                       char *dayofweek,
  2878.                       char *daystr,
  2879.                       int format );
  2880.  
  2881.             PROTOTYPE IN          sc_clock.h
  2882.  
  2883.             DESCRIPTION           sccds2dow converts an ASCIIZ string
  2884.                       date "datestr" to an integer "dayofweek".
  2885.                       "dayofweek" will be a value between 0 (Sunday) and
  2886.                       6 (Saturday).
  2887.  
  2888.                       Date string styles:
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.             38                  SoftC Database Library
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  2909.  
  2910.  
  2911.                       SC_GREGOR   mm/dd/yy
  2912.  
  2913.  
  2914.                       SC_GREGORL  mm/dd/yyyy
  2915.  
  2916.  
  2917.                       SC_JULIAN   yyyy/ddd
  2918.  
  2919.  
  2920.                       SC_YMD      yyyymmdd
  2921.  
  2922.  
  2923.                       SC_DMY      ddmmyy
  2924.  
  2925.              SEE ALSO sccds2day.
  2926.  
  2927.               EXAMPLE #include <stdio.h>
  2928.                       #include <softc.h>
  2929.                       #include <sc_clock.h>
  2930.  
  2931.                       void main()
  2932.                       {
  2933.                         char dayofweek;
  2934.  
  2935.                         sccds2dow(&dayofweek, "19900516", SC_YMD);
  2936.                         printf("%d\n",dayofweek);
  2937.                       }
  2938.  
  2939.  
  2940.             sccds2i___________________________________
  2941.  
  2942.                            USAGE     int sccds2i(
  2943.                       int *year,
  2944.                       int *month,
  2945.                       int *day,
  2946.                       char *string,
  2947.                       int format );
  2948.  
  2949.             PROTOTYPE IN          sc_clock.h
  2950.  
  2951.             DESCRIPTION           sccds2i converts dates from an ASCIIZ
  2952.                       string "string" of the style "format"  to three
  2953.                       integer values ("year", "month", and "day"). A
  2954.                       partial check is made to verify that "string" is a
  2955.                       valid date string before attempting to convert.
  2956.  
  2957.                       Date string styles:
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.             User's Reference Guide                  39
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  2975.  
  2976.  
  2977.                       SC_GREGOR   mm/dd/yy
  2978.  
  2979.  
  2980.                       SC_GREGORL  mm/dd/yyyy
  2981.  
  2982.  
  2983.                       SC_JULIAN   yyyy/ddd
  2984.  
  2985.  
  2986.                       SC_YMD      yyyymmdd
  2987.  
  2988.  
  2989.                       SC_DMY      ddmmyy
  2990.  
  2991.              SEE ALSO sccdi2s.
  2992.  
  2993.               EXAMPLE #include <stdio.h>
  2994.                       #include <softc.h>
  2995.                       #include <sc_clock.h>
  2996.  
  2997.                       void main()
  2998.                       {
  2999.                         int y, m, d;
  3000.  
  3001.                         sccds2i(&y,&m,&d,"19890213",SC_YMD);
  3002.                         printf("%d %d %d",y,m,d);
  3003.                       }
  3004.  
  3005.  
  3006.             sccds2lx__________________________________
  3007.  
  3008.                            USAGE     int sccds2lx(
  3009.                       long *date,
  3010.                       char *string,
  3011.                       int format );
  3012.  
  3013.             PROTOTYPE IN          sc_clock.h
  3014.  
  3015.             DESCRIPTION           sccds2lx converts an ASCIIZ "string"
  3016.                       into a long "date". The date string must be of the
  3017.                       style "format". This date is a calculated count of
  3018.                       days since 1/1/0001. No attempt has been made to
  3019.                       adjust for changes made in the calendar. This
  3020.                       function is used predominantly for date
  3021.                       arithmetic, calculating elapsed days, etc.
  3022.  
  3023.                       Date string styles:
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.             40                  SoftC Database Library
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3041.  
  3042.  
  3043.                       SC_GREGOR   mm/dd/yy
  3044.  
  3045.  
  3046.                       SC_GREGORL  mm/dd/yyyy
  3047.  
  3048.  
  3049.                       SC_JULIAN   yyyy/ddd
  3050.  
  3051.  
  3052.                       SC_YMD      yyyymmdd
  3053.  
  3054.  
  3055.                       SC_DMY      ddmmyy
  3056.  
  3057.               EXAMPLE #include <stdio.h>
  3058.                       #include <softc.h>
  3059.                       #include <sc_clock.h>
  3060.  
  3061.                       void main()
  3062.                       {
  3063.                         long l;
  3064.  
  3065.                         sccds2lx(&l,"19890323",SC_YMD);
  3066.                         printf("%ld",l);
  3067.                       }
  3068.  
  3069.  
  3070.             sccds2mon_________________________________
  3071.  
  3072.                            USAGE     int sccds2mon(
  3073.                       char *monthstr,
  3074.                       char *date,
  3075.                       int format );
  3076.  
  3077.             PROTOTYPE IN          sc_clock.h
  3078.  
  3079.             DESCRIPTION           sccds2mon returns the ASCIIZ month of
  3080.                       year ("monthstr").  The ASCIIZ date string
  3081.                       ("date") is converted to integers under control of
  3082.                       the date string format indicator ("format") and
  3083.                       then the month is translated into a string.
  3084.  
  3085.                       Date string styles:
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.             User's Reference Guide                  41
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3107.  
  3108.  
  3109.                       SC_GREGOR   mm/dd/yy
  3110.  
  3111.  
  3112.                       SC_GREGORL  mm/dd/yyyy
  3113.  
  3114.  
  3115.                       SC_JULIAN   yyyy/ddd
  3116.  
  3117.  
  3118.                       SC_YMD      yyyymmdd
  3119.  
  3120.  
  3121.                       SC_DMY      ddmmyy
  3122.  
  3123.              SEE ALSO sccds2day.
  3124.  
  3125.               EXAMPLE #include <stdio.h>
  3126.                       #include <softc.h>
  3127.                       #include <sc_clock.h>
  3128.  
  3129.                       void main()
  3130.                       {
  3131.                         char month[10];
  3132.  
  3133.                         sccds2mon(&month,"5/16/90",SC_GREGOR);
  3134.                         puts(month);
  3135.                       }
  3136.  
  3137.  
  3138.             sccds2s___________________________________
  3139.  
  3140.                            USAGE     int sccds2s(
  3141.                       char *outstr,
  3142.                       int outformat,
  3143.                       char *instr,
  3144.                       int informat );
  3145.  
  3146.             PROTOTYPE IN          sc_clock.h
  3147.  
  3148.             DESCRIPTION           sccds2s translates one ASCIIZ date
  3149.                       string "instr" of "informat" to another ("outstr"
  3150.                       of "outformat").  The input date string is
  3151.                       converted to integers and checked for validity
  3152.                       before being translated to a string again.  This
  3153.                       function replaces the sccdxlat function which has
  3154.                       been removed from the library.
  3155.  
  3156.                       Date string styles:
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.             42                  SoftC Database Library
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3173.  
  3174.  
  3175.                       SC_GREGOR   mm/dd/yy
  3176.  
  3177.  
  3178.                       SC_GREGORL  mm/dd/yyyy
  3179.  
  3180.  
  3181.                       SC_JULIAN   yyyy/ddd
  3182.  
  3183.  
  3184.                       SC_YMD      yyyymmdd
  3185.  
  3186.  
  3187.                       SC_DMY      ddmmyy
  3188.  
  3189.               EXAMPLE #include <stdio.h>
  3190.                       #include <softc.h>
  3191.                       #include <sc_clock.h>
  3192.  
  3193.                       void main()
  3194.                       {
  3195.                         char day[10];
  3196.  
  3197.                         sccds2s(day, SC_GREGOR, "19900516", SC_YMD);
  3198.                         puts(day);
  3199.                       }
  3200.  
  3201.  
  3202.             sccdsday__________________________________
  3203.  
  3204.                            USAGE     int sccdsday(
  3205.                       char *daystr,
  3206.                       char day );
  3207.  
  3208.             PROTOTYPE IN          sc_clock.h
  3209.  
  3210.             DESCRIPTION           sccdsday returns the day of the week
  3211.                       ASCIIZ string in "daystr" for the day specified by
  3212.                       "day". "day" must be in the range of 0 (Sunday) to
  3213.                       6 (Saturday). The maximum length of the string
  3214.                       returned will be 9 plus the NULL byte.
  3215.  
  3216.                       Date string styles:
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.             User's Reference Guide                  43
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3239.  
  3240.  
  3241.                       SC_GREGOR   mm/dd/yy
  3242.  
  3243.  
  3244.                       SC_GREGORL  mm/dd/yyyy
  3245.  
  3246.  
  3247.                       SC_JULIAN   yyyy/ddd
  3248.  
  3249.  
  3250.                       SC_YMD      yyyymmdd
  3251.  
  3252.  
  3253.                       SC_DMY      ddmmyy
  3254.  
  3255.              SEE ALSO sccdsmonth.
  3256.  
  3257.               EXAMPLE #include <stdio.h>
  3258.                       #include <softc.h>
  3259.                       #include <sc_clock.h>
  3260.  
  3261.                       void main()
  3262.                       {
  3263.                         char day[10];
  3264.  
  3265.                         sccdsday(day,0);
  3266.                         puts(day);
  3267.                       }
  3268.  
  3269.  
  3270.             sccdsdiff_________________________________
  3271.  
  3272.                            USAGE     int sccdsdiff(
  3273.                       long *diff,
  3274.                       char *date1,
  3275.                       int format1,
  3276.                       char *date2,
  3277.                       int format2 );
  3278.  
  3279.             PROTOTYPE IN          sc_clock.h
  3280.  
  3281.             DESCRIPTION           sccdsdiff returns the difference in
  3282.                       days between "date1" and "date2". The two ASCIIZ
  3283.                       date strings can be in any order, but the styles
  3284.                       ("format1", "format2") must be valid.
  3285.  
  3286.                       Date string styles:
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.             44                  SoftC Database Library
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3305.  
  3306.  
  3307.                       SC_GREGOR   mm/dd/yy
  3308.  
  3309.  
  3310.                       SC_GREGORL  mm/dd/yyyy
  3311.  
  3312.  
  3313.                       SC_JULIAN   yyyy/ddd
  3314.  
  3315.  
  3316.                       SC_YMD      yyyymmdd
  3317.  
  3318.  
  3319.                       SC_DMY      ddmmyy
  3320.  
  3321.              SEE ALSO sccds2s, sccdi2s, sccdsvalid.
  3322.  
  3323.               EXAMPLE #include <stdio.h>
  3324.                       #include <softc.h>
  3325.                       #include <sc_clock.h>
  3326.  
  3327.                       void main()
  3328.                       {
  3329.                         long d;
  3330.  
  3331.                         sccdsdiff(&d, "19890213", SC_YMD, "19881217",
  3332.                       SC_YMD);
  3333.                         printf("%ld",d);
  3334.                       }
  3335.  
  3336.  
  3337.             sccdsget__________________________________
  3338.  
  3339.                            USAGE     int sccdsget(
  3340.                       char *date,
  3341.                       int format );
  3342.  
  3343.             PROTOTYPE IN          sc_clock.h
  3344.  
  3345.             DESCRIPTION           sccdsget returns the current "date" in
  3346.                       ASCIIZ string "format" from DOS.
  3347.  
  3348.                       Date string styles:
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.             User's Reference Guide                  45
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3371.  
  3372.  
  3373.                       SC_GREGOR   mm/dd/yy
  3374.  
  3375.  
  3376.                       SC_GREGORL  mm/dd/yyyy
  3377.  
  3378.  
  3379.                       SC_JULIAN   yyyy/ddd
  3380.  
  3381.  
  3382.                       SC_YMD      yyyymmdd
  3383.  
  3384.  
  3385.                       SC_DMY      ddmmyy
  3386.  
  3387.              SEE ALSO sccdiget, scctsget.
  3388.  
  3389.               EXAMPLE #include <stdio.h>
  3390.                       #include <softc.h>
  3391.                       #include <sc_clock.h>
  3392.  
  3393.                       void main()
  3394.                       {
  3395.                         char date[10];
  3396.  
  3397.                         sccdsget(date,SC_GREGOR);
  3398.                         puts(date);
  3399.                       }
  3400.  
  3401.  
  3402.             sccdsleap_________________________________
  3403.  
  3404.                            USAGE     int sccdsleap(
  3405.                       char *leap,
  3406.                       int format );
  3407.  
  3408.             PROTOTYPE IN          sc_clock.h
  3409.  
  3410.             DESCRIPTION           sccdsleap tests the ASCIIZ year string
  3411.                       formatted as "format" passed to it in "leap" to
  3412.                       see if it is a leap year.
  3413.  
  3414.                       Date string styles:
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.             46                  SoftC Database Library
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3437.  
  3438.  
  3439.                       SC_GREGOR   mm/dd/yy
  3440.  
  3441.  
  3442.                       SC_GREGORL  mm/dd/yyyy
  3443.  
  3444.  
  3445.                       SC_JULIAN   yyyy/ddd
  3446.  
  3447.  
  3448.                       SC_YMD      yyyymmdd
  3449.  
  3450.  
  3451.                       SC_DMY      ddmmyy
  3452.  
  3453.             RETURN VALUE          SC_TRUE is leap year
  3454.                       SC_FALSE    not leap year
  3455.  
  3456.  
  3457.              SEE ALSO sccdileap
  3458.  
  3459.               EXAMPLE #include <stdio.h>
  3460.                       #include <softc.h>
  3461.                       #include <sc_clock.h>
  3462.  
  3463.                       void main()
  3464.                       {
  3465.                         if (sccdsleap("19890101",SC_YMD))
  3466.                           puts("Leap Year!");
  3467.                         else
  3468.                           puts("Normal Year.");
  3469.                       }
  3470.  
  3471.  
  3472.             sccdsmonth________________________________
  3473.  
  3474.                            USAGE     int sccdsmonth(
  3475.                       char *monthstr,
  3476.                       char month );
  3477.  
  3478.             PROTOTYPE IN          sc_clock.h
  3479.  
  3480.             DESCRIPTION           sccdsmonth returns the ASCIIZ month
  3481.                       string in "monthstr" for the month specified by
  3482.                       "month". "month" must be in the range of 1
  3483.                       (January) to 12 (December). The maximum length of
  3484.                       the string returned will be 9 plus the NULL byte.
  3485.  
  3486.                       Date string styles:
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.             User's Reference Guide                  47
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3503.  
  3504.  
  3505.                       SC_GREGOR   mm/dd/yy
  3506.  
  3507.  
  3508.                       SC_GREGORL  mm/dd/yyyy
  3509.  
  3510.  
  3511.                       SC_JULIAN   yyyy/ddd
  3512.  
  3513.  
  3514.                       SC_YMD      yyyymmdd
  3515.  
  3516.  
  3517.                       SC_DMY      ddmmyy
  3518.  
  3519.              SEE ALSO sccdsday
  3520.  
  3521.               EXAMPLE #include <stdio.h>
  3522.                       #include <softc.h>
  3523.                       #include <sc_clock.h>
  3524.  
  3525.                       void main()
  3526.                       {
  3527.                         char month[10];
  3528.  
  3529.                         sccdsmonth(month,4);
  3530.                         puts(month);
  3531.                       }
  3532.  
  3533.  
  3534.             sccdsperm_________________________________
  3535.  
  3536.                            USAGE     int sccdsperm(
  3537.                       char *days,
  3538.                       char *date,
  3539.                       int format );
  3540.  
  3541.             PROTOTYPE IN          sc_clock.h
  3542.  
  3543.             DESCRIPTION           sccdsperm calculates the number of
  3544.                       "days" in the month for the year specified in
  3545.                       "date". The date string style ("format") must be
  3546.                       valid. This function also senses leap year and
  3547.                       will properly return 29 days for February.
  3548.  
  3549.                       Date string styles:
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.             48                  SoftC Database Library
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3569.  
  3570.  
  3571.                       SC_GREGOR   mm/dd/yy
  3572.  
  3573.  
  3574.                       SC_GREGORL  mm/dd/yyyy
  3575.  
  3576.  
  3577.                       SC_JULIAN   yyyy/ddd
  3578.  
  3579.  
  3580.                       SC_YMD      yyyymmdd
  3581.  
  3582.  
  3583.                       SC_DMY      ddmmyy
  3584.  
  3585.              SEE ALSO sccdiperm.
  3586.  
  3587.               EXAMPLE #include <stdio.h>
  3588.                       #include <softc.h>
  3589.                       #include <sc_clock.h>
  3590.  
  3591.                       void main()
  3592.                       {
  3593.                         char d;
  3594.  
  3595.                         sccdsperm(&d, "19890325", SC_YMD);
  3596.                         printf("%d",d);
  3597.                       }
  3598.  
  3599.  
  3600.             sccdsvalid________________________________
  3601.  
  3602.                            USAGE     int sccdsvalid(
  3603.                       char *string,
  3604.                       int format );
  3605.  
  3606.             PROTOTYPE IN          sc_clock.h
  3607.  
  3608.             DESCRIPTION           sccdsvalid tests the date ASCIIZ
  3609.                       "string" passed for validity: string properly
  3610.                       formatted (format), valid day of month, and valid
  3611.                       month of year.
  3612.  
  3613.                       Date string styles:
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.             User's Reference Guide                  49
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3635.  
  3636.  
  3637.                       SC_GREGOR   mm/dd/yy
  3638.  
  3639.  
  3640.                       SC_GREGORL  mm/dd/yyyy
  3641.  
  3642.  
  3643.                       SC_JULIAN   yyyy/ddd
  3644.  
  3645.  
  3646.                       SC_YMD      yyyymmdd
  3647.  
  3648.  
  3649.                       SC_DMY      ddmmyy
  3650.  
  3651.               EXAMPLE #include <stdio.h>
  3652.                       #include <softc.h>
  3653.                       #include <sc_clock.h>
  3654.  
  3655.                       void main()
  3656.                       {
  3657.                         if (sccdsvalid("19890213" SC_YMD) == SC_SUCCESS)
  3658.                           puts("Good Date.");
  3659.                         else
  3660.                           puts("Bad Date.");
  3661.                       }
  3662.  
  3663.  
  3664.             sccti2s___________________________________
  3665.  
  3666.                            USAGE     int sccti2s(
  3667.                       char *string,
  3668.                       int format,
  3669.                       int hours,
  3670.                       int minutes,
  3671.                       int seconds );
  3672.  
  3673.             PROTOTYPE IN          sc_clock.h
  3674.  
  3675.             DESCRIPTION           sccti2s converts three integer time
  3676.                       values "hours", "minutes", and "seconds" into an
  3677.                       ASCIIZ string "string" of the string style
  3678.                       "format". A check is made to verify that "string"
  3679.                       is a valid time string before exiting.
  3680.  
  3681.                       Time string styles:
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.             50                  SoftC Database Library
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3701.  
  3702.  
  3703.                       SC_CSHMS    hh:mm:ss
  3704.  
  3705.  
  3706.                       SC_MIL      European/military
  3707.  
  3708.              SEE ALSO scctsvalid, sccts2i.
  3709.  
  3710.               EXAMPLE #include <stdio.h>
  3711.                       #include <softc.h>
  3712.                       #include <sc_clock.h>
  3713.  
  3714.                       void main()
  3715.                       {
  3716.                         char d[9];
  3717.  
  3718.                         sccti2s(d,SC_GREGOR,12,3,59);
  3719.                         puts(d);
  3720.                       }
  3721.  
  3722.  
  3723.             scctiget__________________________________
  3724.  
  3725.                            USAGE     int scctiget(
  3726.                       int *hours,
  3727.                       int *minutes,
  3728.                       int *seconds,
  3729.                       int *fraction );
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.             User's Reference Guide                  51
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3767.  
  3768.  
  3769.             PROTOTYPE IN          sc_clock.h
  3770.  
  3771.             DESCRIPTION           scctiget returns the current time from
  3772.                       DOS in integer form: "hours", "minutes",
  3773.                       "seconds", and hundredths of a second
  3774.                       ("fraction").
  3775.  
  3776.               EXAMPLE #include <stdio.h>
  3777.                       #include <softc.h>
  3778.                       #include <sc_clock.h>
  3779.  
  3780.                       void main()
  3781.                       {
  3782.                         int hours, minutes, seconds, fraction;
  3783.  
  3784.                         scctiget(&hours, &minutes, &seconds, &fraction);
  3785.                         printf("%d %d %d %d\n", hours, minutes, seconds,
  3786.                       fraction);
  3787.                       }
  3788.  
  3789.  
  3790.             sccts2i___________________________________
  3791.  
  3792.                            USAGE     int sccts2i(
  3793.                       int *hours,
  3794.                       int *minutes,
  3795.                       int *seconds,
  3796.                       char *string,
  3797.                       int format );
  3798.  
  3799.             PROTOTYPE IN          sc_clock.h
  3800.  
  3801.             DESCRIPTION           sccts2i converts times from an ASCIIZ
  3802.                       string "string" of style "format" to three integer
  3803.                       values "hour", "minute", and "second". A partial
  3804.                       check is made to verify that "string" is a valid
  3805.                       time string before attempting to convert.
  3806.  
  3807.                       Time string styles:
  3808.  
  3809.  
  3810.                       SC_CSHMS    hh:mm:ss
  3811.  
  3812.  
  3813.                       SC_MIL      European/military
  3814.  
  3815.              SEE ALSO sccti2s.
  3816.  
  3817.               EXAMPLE #include <stdio.h>
  3818.                       #include <softc.h>
  3819.                       #include <sc_clock.h>
  3820.  
  3821.  
  3822.  
  3823.             52                  SoftC Database Library
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3833.  
  3834.  
  3835.  
  3836.                       void main()
  3837.                       {
  3838.                         int h, m, s;
  3839.  
  3840.                         sccts2i(&h,&m,&s,"12:03:59",SC_CSHMS);
  3841.                         printf("%d %d %d",h,m,s);
  3842.                       }
  3843.  
  3844.  
  3845.             scctsdiff_________________________________
  3846.  
  3847.                            USAGE     int scctsdiff(
  3848.                       long *diff,
  3849.                       char *time1,
  3850.                       int format1,
  3851.                       char *time2,
  3852.                       int format2 );
  3853.  
  3854.             PROTOTYPE IN          sc_clock.h
  3855.  
  3856.             DESCRIPTION           scctsdiff returns the difference in
  3857.                       seconds between "time1" and "time2". The two
  3858.                       ASCIIZ time strings can be in any order, but must
  3859.                       be valid  string styles ("format1", "format2").
  3860.  
  3861.                       Time string styles:
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.             User's Reference Guide                  53
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  3899.  
  3900.  
  3901.                       SC_CSHMS    hh:mm:ss
  3902.  
  3903.  
  3904.                       SC_MIL      European/military
  3905.  
  3906.              SEE ALSO sccti2s, scctsvalid.
  3907.  
  3908.               EXAMPLE #include <stdio.h>
  3909.                       #include <softc.h>
  3910.                       #include <sc_clock.h>
  3911.  
  3912.                       void main()
  3913.                       {
  3914.                         long d;
  3915.  
  3916.                         scctsdiff(&d, "12:03:59", SC_CSHMS, "11:30:00",
  3917.                       SC_CSHMS);
  3918.                         printf("%ld",d);
  3919.                       }
  3920.  
  3921.  
  3922.             scctsget__________________________________
  3923.  
  3924.                            USAGE     int scctsget(
  3925.                       char *time,
  3926.                       int format );
  3927.  
  3928.             PROTOTYPE IN          sc_clock.h
  3929.  
  3930.             DESCRIPTION           scctsget returns the current "time"
  3931.                       from DOS in ASCIIZ string "format".
  3932.  
  3933.                       Time string styles:
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.             54                  SoftC Database Library
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  3965.  
  3966.  
  3967.                       SC_CSHMS    hh:mm:ss
  3968.  
  3969.  
  3970.                       SC_MIL      European/military
  3971.  
  3972.               EXAMPLE #include <stdio.h>
  3973.                       #include <softc.h>
  3974.                       #include <sc_clock.h>
  3975.  
  3976.                       void main()
  3977.                       {
  3978.                         char time[10];
  3979.  
  3980.                         scctsget(time,SC_MIL);
  3981.                         puts(time);
  3982.                       }
  3983.  
  3984.  
  3985.             scctsvalid________________________________
  3986.  
  3987.                            USAGE     int scctsvalid(
  3988.                       char *string,
  3989.                       int format );
  3990.  
  3991.             PROTOTYPE IN          sc_clock.h
  3992.  
  3993.             DESCRIPTION           scctsvalid tests the ASCIIZ time
  3994.                       string "string" passed for validity: string
  3995.                       properly formatted ("format"), valid hours,
  3996.                       minutes, and seconds.
  3997.  
  3998.                       Time string styles:
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.             User's Reference Guide                  55
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4031.  
  4032.  
  4033.                       SC_CSHMS    hh:mm:ss
  4034.  
  4035.  
  4036.                       SC_MIL      European/military
  4037.  
  4038.               EXAMPLE #include <stdio.h>
  4039.                       #include <softc.h>
  4040.                       #include <sc_clock.h>
  4041.  
  4042.                       void main()
  4043.                       {
  4044.                         if (scctsvalid("12:03:59",SC_CSHMS) ==
  4045.                       SC_SUCCESS)
  4046.                           puts("Good Time.");
  4047.                         else
  4048.                           puts("Bad Time.");
  4049.                       }
  4050.  
  4051.  
  4052.             scdcbfrsz_________________________________
  4053.  
  4054.                            USAGE     int scdcbfrsz(
  4055.                       int handle,
  4056.                       int *numpgs,
  4057.                       int command );
  4058.  
  4059.             PROTOTYPE IN          sc_base.h
  4060.  
  4061.             DESCRIPTION           scdcbfrsz will either get (SC_GETSZ)
  4062.                       or set (SC_SETSZ) the maximum number of index
  4063.                       pages the library file manager can keep in memory
  4064.                       and returns it via "numpgs".  This is under
  4065.                       control of "command".
  4066.  
  4067.               EXAMPLE /* get size */
  4068.                       #include <stdio.h>
  4069.                       #include <softc.h>
  4070.                       #include <sc_base.h>
  4071.  
  4072.                       void main()
  4073.                       {
  4074.                         int ntx, numpgs;
  4075.                         char *index="TOCNAME.NTX";
  4076.  
  4077.                         scdinit(20,0);
  4078.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4079.                       {
  4080.                           scdcbfrsz(ntx,&numpgs,SC_GETSZ);
  4081.                           printf("Maximum number of pages = %d\n",
  4082.                       numpgs);
  4083.                           scdcclose(ntx);
  4084.  
  4085.  
  4086.  
  4087.             56                  SoftC Database Library
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4097.  
  4098.  
  4099.                         }
  4100.                         scdterm();
  4101.                       }
  4102.  
  4103.                       /* set size */
  4104.                       #include <stdio.h>
  4105.                       #include <softc.h>
  4106.                       #include <sc_base.h>
  4107.  
  4108.                       void main()
  4109.                       {
  4110.                         int ntx, numpgs=5;
  4111.                         char *index="TOCNAME.NTX";
  4112.  
  4113.                         scdinit(20,0);
  4114.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4115.                       {
  4116.                           scdcbfrsz(ntx,&numpgs,SC_SETSZ);
  4117.                           printf("New max = %d\n",numpgs);
  4118.                           scdcclose(ntx);
  4119.                         }
  4120.                         scdterm();
  4121.                       }
  4122.  
  4123.  
  4124.             scdcclose_________________________________
  4125.  
  4126.                            USAGE     int scdcclose(
  4127.                       int handle );
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.             User's Reference Guide                  57
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4163.  
  4164.  
  4165.             PROTOTYPE IN          sc_base.h
  4166.  
  4167.             DESCRIPTION           scdcclose closes a Clipper index file
  4168.                       and frees all allocated memory associated with
  4169.                       "handle".
  4170.  
  4171.               EXAMPLE #include <softc.h>
  4172.                       #include <sc_base.h>
  4173.  
  4174.                       void main()
  4175.                       {
  4176.                         int ntx;
  4177.                         char *index="TOCNAME.NTX";
  4178.  
  4179.                         scdinit(20,0);
  4180.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4181.                           scdcclose(ntx);
  4182.                         scdterm();
  4183.                       }
  4184.  
  4185.  
  4186.             scdccreate________________________________
  4187.  
  4188.                            USAGE     int scdccreate(
  4189.                       char *filename,
  4190.                       int keytype,
  4191.                       char *keyexpr,
  4192.                       int keylen,
  4193.                       int decpl );
  4194.  
  4195.             PROTOTYPE IN          sc_base.h
  4196.  
  4197.             DESCRIPTION           scdccreate creates a Clipper index
  4198.                       file. "keyexpr" will be translated to all upper
  4199.                       case when the index file is created.
  4200.  
  4201.                       If "keytype" is SC_CKEY, then "keyexpr" must be an
  4202.                       ASCIIZ string consisting of one or more field
  4203.                       names from the data record. All fields included in
  4204.                       the expression must be of type 'c' or be
  4205.                       translated into type 'c'. No check is made to
  4206.                       verify this. "keylen" cannot exceed 100.
  4207.  
  4208.                       If "keytype" is SC_NKEY, then "keyexpr" should
  4209.                       consist of only one data field. "keylen" cannot
  4210.                       exceed 19, and "decpl" must be 2 less than
  4211.                       "keylen" and not more than 15.
  4212.  
  4213.                       If "keytype" is SC_DKEY, then "keyexpr" should
  4214.                       consist of only one data field. "keylen" and
  4215.                       "decpl" are ignored as the length is forced to 8.
  4216.  
  4217.  
  4218.  
  4219.             58                  SoftC Database Library
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4229.  
  4230.  
  4231.                       When unique keys are required, OR SC_UNIQUE with
  4232.                       "keytype".
  4233.  
  4234.                 NOTES scdccreate will create a new index file even if
  4235.                       one had already existed.
  4236.  
  4237.                       "keyexpr" is NOT checked for validity during the
  4238.                       file creation process. Currently only the
  4239.                       scdckmake function uses "keyexpr".
  4240.  
  4241.              SEE ALSO scdckmake.
  4242.  
  4243.               EXAMPLE #include <sc_base.h>
  4244.  
  4245.                       void main()
  4246.                       {
  4247.                         scdinit(20,0);
  4248.                         scdccreate("TOCNAME.NTX", SC_DKEY, "name", 64,
  4249.                       0);
  4250.                         scdterm();
  4251.                       }
  4252.  
  4253.  
  4254.             scdcexpr__________________________________
  4255.  
  4256.                            USAGE     int scdcexpr(
  4257.                       int handle,
  4258.                       char *keyexpr );
  4259.  
  4260.             PROTOTYPE IN          sc_base.h
  4261.  
  4262.             DESCRIPTION           scdcexpr gets the index key expression
  4263.                       and returns it as an ASCIIZ string into a user
  4264.                       supplied buffer "keyexpr". The user must ensure
  4265.                       that the buffer is large enough (the key
  4266.                       expression length can be determined via a call to
  4267.                       scdcinfo) to hold the entire key expression.
  4268.  
  4269.                 NOTES A NULL byte will be appended to the end of the
  4270.                       expression string returned.
  4271.  
  4272.              SEE ALSO scdcinfo.
  4273.  
  4274.               EXAMPLE #include <stdio.h>
  4275.                       #include <softc.h>
  4276.                       #include <sc_base.h>
  4277.  
  4278.                       void main()
  4279.                       {
  4280.                         int ntx;
  4281.                         char buffer[512],*index="TOCNAME.NTX";
  4282.  
  4283.  
  4284.  
  4285.             User's Reference Guide                  59
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4295.  
  4296.  
  4297.  
  4298.                         scdinit(20,0);
  4299.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4300.                       {
  4301.                           scdcexpr(ntx,buffer);
  4302.                           printf("key expression = %s",buffer);
  4303.                           scdcclose(ntx);
  4304.                         }
  4305.                         scdterm();
  4306.                       }
  4307.  
  4308.  
  4309.             scdcflush_________________________________
  4310.  
  4311.                            USAGE     int scdcflush(
  4312.                       int handle );
  4313.  
  4314.             PROTOTYPE IN          sc_base.h
  4315.  
  4316.             DESCRIPTION           scdcflush will write the contents of
  4317.                       the I/O cache to disk.  An I/O cache will be used
  4318.                       only if the index file was opened with SC_BUFFER
  4319.                       command switch.
  4320.  
  4321.              SEE ALSO scdcopenx
  4322.  
  4323.               EXAMPLE #include <string.h>
  4324.                       #include <softc.h>
  4325.                       #include <sc_base.h>
  4326.  
  4327.                       void main()
  4328.                       {
  4329.                         int dbf, ntx;
  4330.                         char *key,*data="TOC.DBF",*index="TOCNAME.NTX";
  4331.                         long record;
  4332.  
  4333.                         scdinit(20,0);
  4334.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  4335.                       {
  4336.                           if
  4337.                       (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS) {
  4338.                             scddfput(dbf,0,"TOC.DBF");
  4339.                             scddrput(dbf,&record,SC_ADD);
  4340.                             scdckmake(dbf,ntx,&key);
  4341.                             scdckadd(ntx,key,record);
  4342.                             free(key);
  4343.                             scdcflush(ntx);
  4344.                             scdcclose(ntx);
  4345.                           }
  4346.                           scddclose(dbf);
  4347.  
  4348.  
  4349.  
  4350.  
  4351.             60                  SoftC Database Library
  4352.  
  4353.  
  4354.  
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4361.  
  4362.  
  4363.                         }
  4364.                         scdterm();
  4365.                       }
  4366.  
  4367.  
  4368.             scdcindex_________________________________
  4369.  
  4370.                            USAGE     int scdcindex(
  4371.                       int datafile,
  4372.                       char *filename,
  4373.                       int keytype,
  4374.                       char *keyexpr,
  4375.                       int keylen,
  4376.                       int decpl );
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.             User's Reference Guide                  61
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4427.  
  4428.  
  4429.             PROTOTYPE IN          sc_base.h
  4430.  
  4431.             DESCRIPTION           scdcindex will create and build a
  4432.                       Clipper index file.  A blank file will be created
  4433.                       using "filename", "keytype", "keyexpr", "keylen",
  4434.                       and "decpl".  The resultant file will be opened,
  4435.                       and the "datafile" will be read sequentially
  4436.                       building keys from each data record.  The index
  4437.                       file will be closed at exit.  The "datafile" must
  4438.                       be open prior to the function call.
  4439.  
  4440.              SEE ALSO scdccreate
  4441.  
  4442.               EXAMPLE #include <softc.h>
  4443.                       #include <sc_base.h>
  4444.  
  4445.                       void main()
  4446.                       {
  4447.                         int dbf;
  4448.                         char *data="TOC.DBF",*index="TOCNAME.NTX";
  4449.  
  4450.                         scdinit(20,0);
  4451.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  4452.                       {
  4453.                           scdcindex(dbf,index,SC_CKEY,"NAME",64,0);
  4454.                           scddclose(dbf);
  4455.                         }
  4456.                         scdterm();
  4457.                       }
  4458.  
  4459.  
  4460.             scdchget__________________________________
  4461.  
  4462.  
  4463.             USAGEint scdchget(
  4464.                       int handle );
  4465.  
  4466.             PROTOTYPE IN          sc_base.h
  4467.  
  4468.             DESCRIPTION           scdchget will read the index file
  4469.                       header. This function should be called after the
  4470.                       data file has been locked in order to reload the
  4471.                       current file header information.
  4472.  
  4473.             RETURN VALUES         SC_SUCCESS   header read successfully
  4474.                       SC_RDFAIL   file read failure
  4475.                       SC_SKFAIL   file pointer reposition failed
  4476.                       SC_BADHNDL  invalid handle number
  4477.  
  4478.              SEE ALSO scddlock.
  4479.  
  4480.  
  4481.  
  4482.  
  4483.             62                  SoftC Database Library
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4493.  
  4494.  
  4495.               EXAMPLE #include <stdio.h>
  4496.                       #include <softc.h>
  4497.                       #include <sc_base.h>
  4498.  
  4499.                       void main()
  4500.                       {
  4501.                         int dbf, ntx;
  4502.  
  4503.                         scdinit(20,0);
  4504.                         if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) ==
  4505.                       SC_SUCCESS) {
  4506.                           scdcopenx(&ntx,"TOCNAME.NTX",SC_SHARED);
  4507.                           scddlock(dbf);
  4508.                           scddhget(dbf);
  4509.                           scdchget(ntx);
  4510.                       /* append records - add keys - etc. */
  4511.                           scddunlock(dbf);
  4512.                           scddclose(dbf);
  4513.                         }
  4514.                         scdterm();
  4515.                       }
  4516.  
  4517.  
  4518.             scdcinfo__________________________________
  4519.  
  4520.                            USAGE     int scdcinfo(
  4521.                       int handle,
  4522.                       SC_NTXINFO *info );
  4523.  
  4524.             PROTOTYPE IN          sc_base.h
  4525.  
  4526.             DESCRIPTION           scdcinfo gets the filename of the
  4527.                       index file associated with "handle", the index key
  4528.                       type, the maximum index key length and number of
  4529.                       decimal places (numeric keys) , and the length of
  4530.                       the index key expression via the structure:
  4531.  
  4532.                       typedef struct {
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.             User's Reference Guide                  63
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4559.  
  4560.  
  4561.                         char fname[80];   /* file name */
  4562.  
  4563.  
  4564.                         char keylen; /* key length */
  4565.  
  4566.  
  4567.                         char keydpl; /* decimal places */
  4568.  
  4569.  
  4570.                         char exprlen;     /* expression len */
  4571.  
  4572.  
  4573.                         SC_FLAGS flags;   /* misc. flags */
  4574.  
  4575.  
  4576.                       } SC_NTXINFO;
  4577.  
  4578.                 NOTES If you are using the value returned for the index
  4579.                       expression to dynamically allocate memory to hold
  4580.                       the key expression, be sure to add one to the
  4581.                       length before allocation.
  4582.  
  4583.              SEE ALSO scdcopenx.
  4584.  
  4585.               EXAMPLE #include <stdio.h>
  4586.                       #include <softc.h>
  4587.                       #include <sc_base.h>
  4588.  
  4589.                       void main()
  4590.                       {
  4591.                         int ntx;
  4592.                         SC_NTXINFO info;
  4593.                         char *index="TOCNAME.NTX";
  4594.  
  4595.                         scdinit(20,0);
  4596.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4597.                       {
  4598.                           scdcinfo(ntx,&info);
  4599.                           printf("File name = %s\n",info.fname);
  4600.                           printf("Maximum key length =
  4601.                       %d\n",info.keylen);
  4602.                           printf("Number of decimals =
  4603.                       %d\n,info.keydpl);
  4604.                           printf("Key expression length =
  4605.                       %d\n",info.exprlen);
  4606.                           scdcclose(ntx);
  4607.                         }
  4608.                         scdterm();
  4609.                       }
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.             64                  SoftC Database Library
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4625.  
  4626.  
  4627.             scdckadd__________________________________
  4628.  
  4629.                            USAGE     int scdckadd(
  4630.                       int handle,
  4631.                       void *key,
  4632.                       long recno );
  4633.  
  4634.  
  4635.  
  4636.  
  4637.  
  4638.  
  4639.  
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.             User's Reference Guide                  65
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4691.  
  4692.  
  4693.             PROTOTYPE IN          sc_base.h
  4694.  
  4695.             DESCRIPTION           scdckadd will add "key" to the index
  4696.                       file specified by "handle". "recno" is the data
  4697.                       record number to be associated with "key" (the
  4698.                       data record pointed to by recno must exist prior
  4699.                       to calling scdckadd).
  4700.  
  4701.                 NOTES When adding character keys it is not necessary  to
  4702.                       pad  the key string to size with spaces (" "),
  4703.                       because the function will automatically do this
  4704.                       for you.
  4705.  
  4706.              SEE ALSO scdckmake.
  4707.  
  4708.               EXAMPLE #include <string.h>
  4709.                       #include <softc.h>
  4710.                       #include <sc_base.h>
  4711.  
  4712.                       void main()
  4713.                       {
  4714.                         int dbf, ntx;
  4715.                         char name[65]="ABC.DEF",*index="TOCNAME.NTX";
  4716.                         long recno;
  4717.  
  4718.                         scdinit(20,0);
  4719.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  4720.                           if
  4721.                       (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS) {
  4722.                             scddfputs(dbf,0,name);
  4723.                             if (scddrput(dbf,&recno,SC_ADD) ==
  4724.                       SC_SUCCESS)
  4725.                               scdckadd(ntx,name,recno);
  4726.                             scdcclose(ntx);
  4727.                           }
  4728.                           scddclose(dbf)
  4729.                         }
  4730.                         scdterm();
  4731.                       }
  4732.  
  4733.  
  4734.             scdckbot__________________________________
  4735.  
  4736.                            USAGE     int scdckbot(
  4737.                       int handle,
  4738.                       void *key,
  4739.                       long *recno );
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.             66                  SoftC Database Library
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4757.  
  4758.  
  4759.             PROTOTYPE IN          sc_base.h
  4760.  
  4761.             DESCRIPTION           scdckbot will set the current key
  4762.                       pointer to the last logical key in the index and
  4763.                       return the key value "key" and data record number
  4764.                       "recno" associated with the new current key.
  4765.  
  4766.                 NOTES The user must ensure that the buffer used to
  4767.                       return the key is large enough to hold the entire
  4768.                       key. The maximum length of the key can be
  4769.                       determined via a call to scdcinfo.
  4770.  
  4771.                       All keys are returned as strings.
  4772.  
  4773.              SEE ALSO scdcinfo.
  4774.  
  4775.               EXAMPLE #include <stdio.h>
  4776.                       #include <softc.h>
  4777.                       #include <sc_base.h>
  4778.  
  4779.                       void main()
  4780.                       {
  4781.                         int ntx;
  4782.                         char name[65],*index="TOCNAME.NTX";
  4783.                         long recno;
  4784.  
  4785.                         scdinit(20,0);
  4786.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4787.                       {
  4788.                           name[64] = 0;
  4789.                           scdckbot(ntx,name,&recno);
  4790.                           printf("%s %ld\n",name,recno);
  4791.                           scdcclose(ntx);
  4792.                         }
  4793.                         scdterm();
  4794.                       }
  4795.  
  4796.  
  4797.             scdckcur__________________________________
  4798.  
  4799.                            USAGE     int scdckcur(
  4800.                       int handle,
  4801.                       void *key,
  4802.                       long *recno );
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811.  
  4812.  
  4813.             User's Reference Guide                  67
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4823.  
  4824.  
  4825.             PROTOTYPE IN          sc_base.h
  4826.  
  4827.             DESCRIPTION           scdckcur will return the key value
  4828.                       "key" and data record number "recno" associated
  4829.                       with the current key in the index file.
  4830.  
  4831.                       The current key pointer must be set by a call to
  4832.                       either scdckfind, scdcktop, scdckbot, scdcknext,
  4833.                       or scdckprev before calling scdckcur.
  4834.  
  4835.                 NOTES The user must ensure that the buffer used to
  4836.                       return the key is large enough to hold the entire
  4837.                       key. The maximum length of the key can be
  4838.                       determined via a call to scdcinfo.
  4839.  
  4840.              SEE ALSO scdcinfo, scdckfind, scdcktop, scdckbot,
  4841.                       scdcknext, scdckprev.
  4842.  
  4843.               EXAMPLE #include <stdio.h>
  4844.                       #include <softc.h>
  4845.                       #include <sc_base.h>
  4846.  
  4847.                       void main()
  4848.                       {
  4849.                         int ntx;
  4850.                         char date[17],dat[17],*index="TOCDATE.NTX";
  4851.                         long recno, recn;
  4852.  
  4853.                         scdinit(20,0);
  4854.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4855.                       {
  4856.                           date[16] = 0;
  4857.                           dat[16] = 0;
  4858.                           scdcktop(ntx,date,&recn);
  4859.                           scdckcur(ntx,dat,&recno);
  4860.                           printf("%s %s %ld %ld\n",
  4861.                       date,dat,recno,recn);
  4862.                           scdcclose(ntx);
  4863.                         }
  4864.                         scdterm();
  4865.                       }
  4866.  
  4867.  
  4868.             scdckdel__________________________________
  4869.  
  4870.                            USAGE     int scdckdel(
  4871.                       int handle,
  4872.                       void *key,
  4873.                       long recno );
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.             68                  SoftC Database Library
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  4889.  
  4890.  
  4891.             PROTOTYPE IN          sc_base.h
  4892.  
  4893.             DESCRIPTION           scdckdel will remove "key" from the
  4894.                       index file specified by "handle". "recno" is used
  4895.                       along with "key" to ensure that the proper key has
  4896.                       been removed from the index file.
  4897.  
  4898.                 NOTES When deleting keys it is not necessary  to  pad
  4899.                       the key string to size with spaces (" "), the
  4900.                       function will automatically do this for you.
  4901.  
  4902.              SEE ALSO scdckadd.
  4903.  
  4904.               EXAMPLE #include <string.h>
  4905.                       #include <softc.h>
  4906.                       #include <sc_base.h>
  4907.  
  4908.                       void main()
  4909.                       {
  4910.                         int ntx;
  4911.                         char date[17],*index="TOCDATE.NTX";
  4912.  
  4913.                         scdinit(20,0);
  4914.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  4915.                       {
  4916.                           strcpy(date,"12/05/8815:30:04");
  4917.                           scdckdel(ntx,date,7L);
  4918.                           scdcclose(ntx);
  4919.                         }
  4920.                         scdterm();
  4921.                       }
  4922.  
  4923.  
  4924.             scdckfind_________________________________
  4925.  
  4926.                            USAGE     int scdckfind(
  4927.                       int handle,
  4928.                       void *key,
  4929.                       long *recno,
  4930.                       int method );
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.             User's Reference Guide                  69
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  4955.  
  4956.  
  4957.             PROTOTYPE IN          sc_base.h
  4958.  
  4959.             DESCRIPTION           scdckfind supports two key search
  4960.                       methods (determined by "method"): SC_EXACT - find
  4961.                       an exact match with "key" and "recno", and
  4962.                       SC_FIRST - find the first logical occurrence of
  4963.                       "key" in the index and return the associated
  4964.                       record number "recno" if found.
  4965.  
  4966.                       If a match cannot be found, the current key will
  4967.                       be the physical key which would immediately
  4968.                       precede "key". The current key's value and data
  4969.                       record number will be returned in "key" and
  4970.                       "recno".
  4971.  
  4972.                 NOTES The user must ensure that the buffer used to
  4973.                       return the key is large enough to hold the entire
  4974.                       key. The maximum length of the key can be
  4975.                       determined via a call to scdcinfo.
  4976.  
  4977.                       When searching it is not necessary  to  pad  the
  4978.                       key string to size with spaces (" "), the function
  4979.                       will automatically do this for you.
  4980.  
  4981.                       Searching for partial keys can be accomplished by
  4982.                       using the SC_FIRST method. For example, you are
  4983.                       using a fifteen character key and you want to find
  4984.                       the first entry where the first five characters
  4985.                       are "ABCDE". All you need do is copy that five
  4986.                       character ASCIIZ string into your key buffer and
  4987.                       then call scdckfind. The function will space pad
  4988.                       to length and then find the first matching entry.
  4989.  
  4990.                       All keys are returned as strings.
  4991.  
  4992.              SEE ALSO scdcinfo.
  4993.  
  4994.               EXAMPLE #include <stdio.h>
  4995.                       #include <string.h>
  4996.                       #include <softc.h>
  4997.                       #include <sc_base.h>
  4998.  
  4999.                       void main()
  5000.                       {
  5001.                         int ntx;
  5002.                         char key[65],*index="TOCNAME.NTX";
  5003.                         long recno;
  5004.  
  5005.                         scdinit(20,0);
  5006.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  5007.                       {
  5008.  
  5009.  
  5010.  
  5011.             70                  SoftC Database Library
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5021.  
  5022.  
  5023.                           strcpy(key,"ABCDE.XYZ");
  5024.                           recno = 7L;
  5025.                           if (scdckfind(ntx,key,&recno,SC_FIRST) !=
  5026.                       SC_SUCCESS)
  5027.                             printf("%s\n",scemsg());
  5028.                           else
  5029.                             printf("%s %ld\n",key,recno);
  5030.                           scdcclose(ntx);
  5031.                         }
  5032.                         scdterm();
  5033.                       }
  5034.  
  5035.  
  5036.             scdckmake_________________________________
  5037.  
  5038.                            USAGE     int scdckmake(
  5039.                       int datahandle,
  5040.                       int indexhandle,
  5041.                       void **key );
  5042.  
  5043.             PROTOTYPE IN          sc_base.h
  5044.  
  5045.             DESCRIPTION           scdckmake will build an index key
  5046.                       using the key expression of the index file
  5047.                       specified by "indexhandle" and the data found in
  5048.                       the record buffer of the data file "datahandle".
  5049.                       Memory space for the "key" will be allocated and
  5050.                       the address of this block will be returned.
  5051.  
  5052.                       The key expression can consist of either the data
  5053.                       field name or one of five Clipper functions or a
  5054.                       combination thereof. Data field types of date,
  5055.                       numeric, or character are allowed. Clipper
  5056.                       functions dtoc, left, right, str, and substr are
  5057.                       currently supported by scdckmake.
  5058.  
  5059.                       Following is a brief description of the five
  5060.                       expression functions:
  5061.  
  5062.                       dtoc will convert data from a date field to an
  5063.                       ASCIIZ string of the format "mm/dd/yy". Syntax is:
  5064.  
  5065.                       dtoc(field_name)
  5066.  
  5067.                       left will return the left portion of a character
  5068.                       field as an ASCIIZ string. The number of
  5069.                       characters returned is specified after the field
  5070.                       name. Syntax is:
  5071.  
  5072.                       left(field_name,number)
  5073.  
  5074.  
  5075.  
  5076.  
  5077.             User's Reference Guide                  71
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5087.  
  5088.  
  5089.                       right will return the right portion of a character
  5090.                       field as an ASCIIZ string. The number of
  5091.                       characters returned is specified after the field
  5092.                       name. This is a count from the right side of the
  5093.                       field. Syntax is:
  5094.  
  5095.                       right(field_name,number)
  5096.  
  5097.                       str will convert a numeric field to an ASCIIZ
  5098.                       string. The total length of the string and the
  5099.                       number of decimal places are optional parameters.
  5100.                       The default string length is 10 and the number of
  5101.                       decimal places is 0. Syntax is:
  5102.  
  5103.                       str(field_name,length,decimal_places)
  5104.  
  5105.                       substr will return the middle portion of a
  5106.                       character field. The starting offset into the
  5107.                       field is a required parameter. The number of
  5108.                       characters to be used is an optional parameter
  5109.                       whose default value is the remainder of the field.
  5110.                       Syntax is:
  5111.  
  5112.                       substr(field_name,start,count)
  5113.  
  5114.                       An example of a more complex key expression:
  5115.  
  5116.                       right(dtoc(date),2)+left(dtoc(date,2)
  5117.  
  5118.                       This expression would cause scdckmake to create an
  5119.                       index key string consisting of the year and month
  5120.                       ("yymm"). For example if date equals "2/13/89" the
  5121.                       resultant key would be "8902".
  5122.  
  5123.                 NOTES For key expressions consisting of only one data
  5124.                       field scdckmake is probably an overkill. You can
  5125.                       easily generate these keys yourself. scdckmake is
  5126.                       a fairly large module and if not needed probably
  5127.                       should not be used. This function is best used
  5128.                       when the key expression is more complex.
  5129.  
  5130.                       Memory is allocated for the generated key and it
  5131.                       is the responsibility of the caller to free this
  5132.                       memory when finished.
  5133.  
  5134.              SEE ALSO scdccreate.
  5135.  
  5136.               EXAMPLE #include <stdio.h>
  5137.                       #include <softc.h>
  5138.                       #include <sc_base.h>
  5139.  
  5140.  
  5141.  
  5142.  
  5143.             72                  SoftC Database Library
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5153.  
  5154.  
  5155.                       void main()
  5156.                       {
  5157.                         int ntx, dbf;
  5158.                         char *key,*index="TOCNAME.NTX";
  5159.                         long recno;
  5160.  
  5161.                         scdinit(20,0);
  5162.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  5163.                           if
  5164.                       (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS) {
  5165.                             scddfput(dbf,0,"ABCDEF.XYZ");
  5166.                             scddrput(dbf,&recno,SC_ADD);
  5167.                             scdckmake(dbf,ntx,(void **) &key);
  5168.                             printf("%s\n",key);
  5169.                             scdckadd(ntx,key,recno);
  5170.                             free(key);    /* free memory allocated for
  5171.                       key */
  5172.                             scdcclose(ntx);
  5173.                           }
  5174.                           scddclose(dbf);
  5175.                         }
  5176.                         scdterm();
  5177.                       }
  5178.  
  5179.  
  5180.             scdcknext_________________________________
  5181.  
  5182.                            USAGE     int scdcknext(
  5183.                       int handle,
  5184.                       void *key,
  5185.                       long *recno );
  5186.  
  5187.             PROTOTYPE IN          sc_base.h
  5188.  
  5189.             DESCRIPTION           scdcknext will increment the key
  5190.                       pointer and return the key value "key" and data
  5191.                       record number "recno" associated with the new
  5192.                       current key.
  5193.  
  5194.                       If scdcknext is called immediately after opening
  5195.                       the index file the first logical key will be
  5196.                       returned.
  5197.  
  5198.                 NOTES The user must ensure that the buffer used to
  5199.                       return the key is large enough to hold the entire
  5200.                       key. The maximum length of the key can be
  5201.                       determined via a call to scdcinfo.
  5202.  
  5203.                       All keys are returned as strings.
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.             User's Reference Guide                  73
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5219.  
  5220.  
  5221.              SEE ALSO scdcinfo.
  5222.  
  5223.               EXAMPLE #include <stdio.h>
  5224.                       #include <softc.h>
  5225.                       #include <sc_base.h>
  5226.  
  5227.                       void main()
  5228.                       {
  5229.                         int ntx;
  5230.                         char key[11],*index="TOCLNGTH.NTX";
  5231.                         long recno;
  5232.  
  5233.                         scdinit(20,0);
  5234.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  5235.                       {
  5236.                           scdcknext(ntx,key,&recno);     /* return first
  5237.                       key */
  5238.                           printf("%s %ld\n",key,recno);
  5239.                           scdcclose(ntx);
  5240.                         }
  5241.                         scdterm();
  5242.                       }
  5243.  
  5244.  
  5245.             scdckprev_________________________________
  5246.  
  5247.                            USAGE     int scdckprev(
  5248.                       int handle,
  5249.                       void *key,
  5250.                       long *recno );
  5251.  
  5252.             PROTOTYPE IN          sc_base.h
  5253.  
  5254.             DESCRIPTION           scdckprev will decrement the key
  5255.                       pointer and return the key value "key" and data
  5256.                       record number "recno" associated with the new
  5257.                       current key.
  5258.  
  5259.                       If scdckprev is called immediately after opening
  5260.                       the index file the last logical key will be
  5261.                       returned.
  5262.  
  5263.                 NOTES The user must ensure that the buffer used to
  5264.                       return the key is large enough to hold the entire
  5265.                       key. The maximum length of the key can be
  5266.                       determined via a call to scdcinfo.
  5267.  
  5268.                       All keys are returned as strings.
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.             74                  SoftC Database Library
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5285.  
  5286.  
  5287.              SEE ALSO scdcinfo.
  5288.  
  5289.               EXAMPLE #include <stdio.h>
  5290.                       #include <softc.h>
  5291.                       #include <sc_base.h>
  5292.  
  5293.                       void main()
  5294.                       {
  5295.                         int ntx;
  5296.                         char character[65],*index="TOCNAME.NTX";
  5297.                         long recno;
  5298.  
  5299.                         scdinit(20,0);
  5300.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  5301.                       {
  5302.                           scdckprev(ntx,character,&recno);    /* get
  5303.                       last key */
  5304.                           printf("%s %ld\n",character,recno);
  5305.                           scdcclose(ntx);
  5306.                         }
  5307.                         scdterm();
  5308.                       }
  5309.  
  5310.  
  5311.             scdcktop__________________________________
  5312.  
  5313.                            USAGE     int scdcktop(
  5314.                       int handle,
  5315.                       void *key,
  5316.                       long *recno );
  5317.  
  5318.             PROTOTYPE IN          sc_base.h
  5319.  
  5320.             DESCRIPTION           scdcktop will set the current key
  5321.                       pointer to the first logical key in the index and
  5322.                       return the key value "key" and data record number
  5323.                       "recno" associated with the new current key.
  5324.  
  5325.                 NOTES The user must ensure that the buffer used to
  5326.                       return the key is large enough to hold the entire
  5327.                       key. The maximum length of the key can be
  5328.                       determined via a call to scdcinfo.
  5329.  
  5330.                       All keys are returned as strings.
  5331.  
  5332.              SEE ALSO scdcinfo.
  5333.  
  5334.               EXAMPLE #include <stdio.h>
  5335.                       #include <softc.h>
  5336.                       #include <sc_base.h>
  5337.  
  5338.  
  5339.  
  5340.  
  5341.             User's Reference Guide                  75
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5351.  
  5352.  
  5353.                       void main()
  5354.                       {
  5355.                         int ntx;
  5356.                         char date[17],*index="TOCDATE.NTX";
  5357.                         long recno;
  5358.  
  5359.                         scdinit(20,0);
  5360.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  5361.                       {
  5362.                           date[16] = 0;
  5363.                           scdcktop(ntx,date,&recno);
  5364.                           printf("%s %ld\n",date,recno);
  5365.                           scdcclose(ntx);
  5366.                         }
  5367.                         scdterm();
  5368.                       }
  5369.  
  5370.  
  5371.             scdcopenx_________________________________
  5372.  
  5373.                            USAGE     int scdcopenx(
  5374.                       int *handle,
  5375.                       char *filename,
  5376.                       int command );
  5377.  
  5378.             PROTOTYPE IN          sc_base.h
  5379.  
  5380.             DESCRIPTION           scdcopenx opens a Clipper index file
  5381.                       (.NTX). Memory will be allocated for a file
  5382.                       packet, I/O buffers, and other miscellaneous
  5383.                       structures for use internally by the SoftC
  5384.                       Database Library file manager. The index file will
  5385.                       be tested as much as possible to insure that it is
  5386.                       a legitimate Clipper index file.
  5387.  
  5388.                       A block of memory large enough to hold at least 3
  5389.                       pages (3072 bytes) will be allocated during the
  5390.                       open. Three pages is the minimum number of buffers
  5391.                       required to add or delete index keys.
  5392.  
  5393.                       The file will be opened under control of the
  5394.                       "command" parameter.  Using SC_RDWR opens the file
  5395.                       for both read and write access.  SC_RDONLY
  5396.                       overrides SC_RDWR and causes the file to be opened
  5397.                       for read access only.  Any attempt to write to a
  5398.                       read only file will result in an error
  5399.                       (SC_READOLY).
  5400.  
  5401.                       Using SC_EXCLUDE opens the file for exclusive use
  5402.                       of this station (single user).  SC_SHARED
  5403.                       overrides SC_EXCLUDE and opens the file in multi-
  5404.  
  5405.  
  5406.  
  5407.             76                  SoftC Database Library
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5417.  
  5418.  
  5419.                       user mode.  This mode is used when a LAN file is
  5420.                       to be shared with other stations.
  5421.  
  5422.                       Using SC_BUFFER opens the file with I/O caching
  5423.                       enabled.  Memory for up  to 10 pages will be
  5424.                       allocated during the open.  Caching of page I/O
  5425.                       greatly increases the speed of file access.
  5426.                       Typically this mode is used with single user
  5427.                       files.  SC_FLUSH overrides SC_BUFFER and causes
  5428.                       the file to be opened with no caching.  This mode
  5429.                       is generally used with file sharing, although it
  5430.                       is not required.
  5431.  
  5432.                       The index expression will be translated to upper
  5433.                       case after being read from the index file.
  5434.  
  5435.               EXAMPLE #include <softc.h>
  5436.                       #include <sc_base.h>
  5437.  
  5438.                       void main()
  5439.                       {
  5440.                         int ntx;
  5441.                         char *index="UNKNOWN.NTX";
  5442.  
  5443.                         scdinit(20,0);
  5444.                         if (scdcopenx(&ntx,index,SC_BUFFER)==SC_SUCCESS)
  5445.                       {
  5446.                           scdcclose(ntx);
  5447.                         }
  5448.                         scdterm();
  5449.                       }
  5450.  
  5451.  
  5452.             scddbfrsz_________________________________
  5453.  
  5454.                            USAGE     int scddbfrsz(
  5455.                       int handle,
  5456.                       int *length,
  5457.                       int command );
  5458.  
  5459.             PROTOTYPE IN          sc_base.h
  5460.  
  5461.             DESCRIPTION           scddbfrsz either sets (SC_SETSZ) or
  5462.                       gets (SC_GETSZ) the I/O cache "length" (in
  5463.                       records) based upon the value of "command".
  5464.  
  5465.                       If the cache length is being set, the current
  5466.                       cache will be flushed to disk before the buffer is
  5467.                       reallocated.
  5468.  
  5469.  
  5470.  
  5471.  
  5472.  
  5473.             User's Reference Guide                  77
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5483.  
  5484.  
  5485.                       An I/O cache will be used only if the data file
  5486.                       was opened with SC_BUFFER in the command field.
  5487.  
  5488.              SEE ALSO scddopenx
  5489.  
  5490.               EXAMPLE /* Get Size */
  5491.                       #include <stdio.h>
  5492.                       #include <softc.h>
  5493.                       #include <sc_base.h>
  5494.  
  5495.                       void main()
  5496.                       {
  5497.                         int dbf, length;
  5498.                         char *data="TOC.DBF";
  5499.  
  5500.                         scdinit(20,0);
  5501.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  5502.                       {
  5503.                           scddbfrsz(dbf,&length,SC_GETSZ);
  5504.                           printf("%d\n",length);
  5505.                           scddclose(dbf);
  5506.                         }
  5507.                         scdterm();
  5508.                       }
  5509.  
  5510.                       /* Get Size */
  5511.                       #include <stdio.h>
  5512.                       #include <softc.h>
  5513.                       #include <sc_base.h>
  5514.  
  5515.                       void main()
  5516.                       {
  5517.                         int dbf, length = 100;
  5518.                         char *data="TOC.DBF";
  5519.  
  5520.                         scdinit(20,0);
  5521.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  5522.                       {
  5523.                           scddbfrsz(dbf,&length,SC_SETSZ);
  5524.                           printf("%d\n",length);
  5525.                           scddclose(dbf);
  5526.                         }
  5527.                         scdterm();
  5528.                       }
  5529.  
  5530.  
  5531.             scddbof___________________________________
  5532.  
  5533.                            USAGE     int scddbof(
  5534.                       int handle );
  5535.  
  5536.  
  5537.  
  5538.  
  5539.             78                  SoftC Database Library
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5549.  
  5550.  
  5551.             PROTOTYPE IN          sc_base.h
  5552.  
  5553.             DESCRIPTION           scddbof returns an indicator as to
  5554.                       whether or not the record pointer is positioned at
  5555.                       the beginning of the file.
  5556.  
  5557.             RETURN VALUE          SC_TRUE at beginning of file
  5558.  
  5559.  
  5560.                       SC_FALSE    somewhere else
  5561.  
  5562.              SEE ALSO scddeof, scddrnum.
  5563.  
  5564.               EXAMPLE #include <stdio.h>
  5565.                       #include <softc.h>
  5566.                       #include <sc_base.h>
  5567.  
  5568.                       void main()
  5569.                       {
  5570.                         int dbf;
  5571.  
  5572.                         scdinit(20,0);
  5573.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  5574.                           if (scddbof(dbf) < SC_SUCCESS)
  5575.                             puts(scemsg());
  5576.                           else if (sc_code == SC_TRUE)
  5577.                             puts("At beginning of file");
  5578.                           else
  5579.                             puts("Somewhere else.");
  5580.                           scddclose(dbf);
  5581.                         }
  5582.                         scdterm();
  5583.                       }
  5584.  
  5585.  
  5586.             scddclose_________________________________
  5587.  
  5588.                            USAGE     int scddclose(
  5589.                       int handle );
  5590.  
  5591.  
  5592.  
  5593.  
  5594.  
  5595.  
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601.  
  5602.  
  5603.  
  5604.  
  5605.             User's Reference Guide                  79
  5606.  
  5607.  
  5608.  
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5615.  
  5616.  
  5617.             PROTOTYPE IN          sc_base.h
  5618.  
  5619.             DESCRIPTION           scddclose closes a data file and frees
  5620.                       all allocated memory associated with data file
  5621.                       "handle". If the data file was modified, today's
  5622.                       date will be written into the file header.
  5623.  
  5624.                 NOTES If any locks are applied to the file, they will be
  5625.                       removed before closing.
  5626.  
  5627.              SEE ALSO scddopenx
  5628.  
  5629.               EXAMPLE #include <softc.h>
  5630.                       #include <sc_base.h>
  5631.  
  5632.                       void main()
  5633.                       {
  5634.                         int dbf;
  5635.  
  5636.                         scdinit(20,0);
  5637.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS)
  5638.                           scddclose(dbf);
  5639.                         scdterm();
  5640.                       }
  5641.  
  5642.  
  5643.             scddcreate________________________________
  5644.  
  5645.                            USAGE     int scddcreate(
  5646.                       char *filename,
  5647.                       int numfields,
  5648.                       SC_FIELD *fields,
  5649.                       int style );
  5650.  
  5651.             PROTOTYPE IN          sc_base.h
  5652.  
  5653.             DESCRIPTION           scddcreate creates a dBASEIII or
  5654.                       dBASEIV compatible data file. A pointer to an
  5655.                       array of SC_FIELD must be passed.
  5656.  
  5657.                       typedef struct {
  5658.  
  5659.  
  5660.  
  5661.  
  5662.  
  5663.  
  5664.  
  5665.  
  5666.  
  5667.  
  5668.  
  5669.  
  5670.  
  5671.             80                  SoftC Database Library
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5681.  
  5682.  
  5683.                         char name[11];    /* field name */
  5684.  
  5685.  
  5686.                         char type;   /* field type */
  5687.  
  5688.  
  5689.                         int len;  /* field length */
  5690.  
  5691.  
  5692.                         int decpl;   /* decimal places */
  5693.  
  5694.  
  5695.                       } SC_FIELD;
  5696.  
  5697.                       The field description array must be initialized
  5698.                       and each element set to appropriate values. The
  5699.                       array determines the organization of the data
  5700.                       record. The data file does not remain open upon
  5701.                       exit of this function.
  5702.  
  5703.                       This function will create a new data file even if
  5704.                       one had already existed.
  5705.  
  5706.                       Field names and types are converted to all upper
  5707.                       case when the file is created.
  5708.  
  5709.                       Valid field types are:
  5710.  
  5711.             'C'character (not NULL terminated in record)
  5712.  
  5713.             'D'date ("yyyymmdd" format)
  5714.  
  5715.             'F'floating point (valid only for dBASEIV files)
  5716.  
  5717.             'L'logical (TRUE, FALSE)
  5718.  
  5719.             'M'memo (memo file record number)
  5720.  
  5721.             'N'numeric.
  5722.  
  5723.                       Both 'F' and 'N' fields are handled as doubles by
  5724.                       the library. The library does not support BCD
  5725.                       numbers.
  5726.  
  5727.                       The type of data file created depends upon the
  5728.                       value of the "style" parameter: SC_DB3 - dBASEIII
  5729.                       compatible,  SC_DB4 - dBASEIV compatible, or
  5730.                       SC_FP1 - FoxPro compatible.
  5731.  
  5732.  
  5733.  
  5734.  
  5735.  
  5736.  
  5737.             User's Reference Guide                  81
  5738.  
  5739.  
  5740.  
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5747.  
  5748.  
  5749.             RESTRICTIONS          The maximum record length is 4000
  5750.                       bytes.
  5751.  
  5752.                       The maximum number of dBASE III fields is 128, but
  5753.                       the maximum number of dBASEIV fields is 255.
  5754.  
  5755.                       The maximum length of character fields is 254, and
  5756.                       they cannot be longer than 100 if used as a key.
  5757.  
  5758.                       The maximum length of dBASE III numeric fields is
  5759.                       19, but the maximum length of dBASE IV numeric &
  5760.                       float fields is 20.
  5761.  
  5762.                       The length of a date field is forced to 8.
  5763.  
  5764.                       The length of a logical field is forced to 1.
  5765.  
  5766.                       The length of a memo field is forced to 10.
  5767.  
  5768.                       The number of decimal places will be forced to
  5769.                       zero for all types except: 1) dBASE III NUMERIC -
  5770.                       it must be less than ('len' - 2) and also less
  5771.                       than 16, and 2) dBASE IV NUMERIC and FLOAT - it
  5772.                       must be less than ('len' - 2). The number of
  5773.                       decimal places cannot be less than zero.
  5774.  
  5775.              SEE ALSO scddcreate
  5776.  
  5777.               EXAMPLE #include <softc.h>
  5778.                       #include <sc_base.h>
  5779.  
  5780.                       void main()
  5781.                       {
  5782.                         SC_FIELD fields[] = {
  5783.                           "name",'c',64,0,     /* file name */
  5784.                           "length",'n',10,0,   /* file size */
  5785.                           "date",'d',8,0, /* date */
  5786.                           "time",'c',8,0, /* time */
  5787.                           "attribute",'c',3,0  /* file attributes */
  5788.                         };
  5789.  
  5790.                         scdinit(20,0);
  5791.                         scddcreate("TOC.DBF",5,fields,SC_DB3);
  5792.                         scdterm();
  5793.                       }
  5794.  
  5795.  
  5796.             scddeof___________________________________
  5797.  
  5798.                            USAGE     int scddeof(
  5799.                       int handle );
  5800.  
  5801.  
  5802.  
  5803.             82                  SoftC Database Library
  5804.  
  5805.  
  5806.  
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5813.  
  5814.  
  5815.             PROTOTYPE IN          sc_base.h
  5816.  
  5817.             DESCRIPTION           scddeof returns an indicator as to
  5818.                       whether or not the record pointer is positioned at
  5819.                       the end of the file.
  5820.  
  5821.             RETURN VALUE          SC_TRUE at end of file
  5822.  
  5823.  
  5824.                       SC_FALSE    somewhere else
  5825.  
  5826.              SEE ALSO scddbof, scddrnum.
  5827.  
  5828.               EXAMPLE #include <sc_base.h>
  5829.  
  5830.                       void main()
  5831.                       {
  5832.                         int dbf;
  5833.  
  5834.                         scdinit(20,0);
  5835.                         if (scddopenx(&dbf, "TOC.DBF", 0) == SC_SUCCESS)
  5836.                       {
  5837.                           if (scddeof(dbf) < SC_SUCCESS)
  5838.                             puts(scemsg());
  5839.                           else if (sc_code == SC_TRUE)
  5840.                             puts("At end of file");
  5841.                           else
  5842.                             puts("Somewhere else");
  5843.                           scddclose(dbf);
  5844.                         }
  5845.                         scdterm();
  5846.                       }
  5847.  
  5848.  
  5849.             scddfget__________________________________
  5850.  
  5851.                            USAGE     int scddfget(
  5852.                       int handle,
  5853.                       int fieldno,
  5854.                       void *data );
  5855.  
  5856.             PROTOTYPE IN          sc_base.h
  5857.  
  5858.             DESCRIPTION           scddfget gets data from the desired
  5859.                       field "fieldno" of the record I/O buffer. "data"
  5860.                       will be converted from dBASE to a more natural
  5861.                       data type for 'c':
  5862.  
  5863.                       dBASE type  returned data type
  5864.  
  5865.  
  5866.  
  5867.  
  5868.  
  5869.             User's Reference Guide                  83
  5870.  
  5871.  
  5872.  
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  5879.  
  5880.  
  5881.                       'C'         char *
  5882.  
  5883.  
  5884.                       'D'         char [9]
  5885.  
  5886.  
  5887.                       'F'         double (dBASEIV)
  5888.  
  5889.  
  5890.                       'L'         char
  5891.  
  5892.  
  5893.                       'M'         long
  5894.  
  5895.  
  5896.                       'N'         double
  5897.  
  5898.                       Date and character fields are returned as ASCIIZ
  5899.                       strings. The date strings will be formatted under
  5900.                       control of the global variable sc_date_style. This
  5901.                       variable will default to SC_GREGOR.
  5902.  
  5903.                       Data returned by this function for memo fields is
  5904.                       the memo file record number NOT the actual memo
  5905.                       text. A call must be made to scdtrget to retrieve
  5906.                       the memo text.
  5907.  
  5908.                       scddfinfo can be used to determine the length of
  5909.                       the longest data field in the file.
  5910.  
  5911.                 NOTES Fields are numbered from zero (0).
  5912.  
  5913.              SEE ALSO scdtrget, scddfgets, scddfput, scddfinfo,
  5914.                       scddrget.
  5915.  
  5916.               EXAMPLE #include <stdio.h>
  5917.                       #include <softc.h>
  5918.                       #include <sc_base.h>
  5919.  
  5920.                       void main()
  5921.                       {
  5922.                         int dbf;
  5923.                         char name[65], time[9], date[9];
  5924.                         double length, attribute;
  5925.  
  5926.                         scdinit(20,0);
  5927.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  5928.                           scddrget(dbf,1L);
  5929.                           scddfget(dbf,0,name);
  5930.                           scddfget(dbf,1,&length);
  5931.                           scddfget(dbf,2,date);
  5932.  
  5933.  
  5934.  
  5935.             84                  SoftC Database Library
  5936.  
  5937.  
  5938.  
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  5945.  
  5946.  
  5947.                           scddfget(dbf,3,time);
  5948.                           scddfget(dbf,4,&attribute);
  5949.                           printf("%s %lf %s %s %lf\n",
  5950.                       name,length,date,time,attribute);
  5951.                           scddclose(dbf);
  5952.                         }
  5953.                         scdterm();
  5954.                       }
  5955.  
  5956.  
  5957.             scddfgets_________________________________
  5958.  
  5959.                            USAGE     int scddfgets(
  5960.                       int handle,
  5961.                       int fieldno,
  5962.                       char *data );
  5963.  
  5964.             PROTOTYPE IN          sc_base.h
  5965.  
  5966.             DESCRIPTION           scddfgets gets data from the desired
  5967.                       field "fieldno" of the record I/O buffer. "data"
  5968.                       will be returned as an ASCIIZ string.
  5969.  
  5970.                       scddfinfo can be used to determine the length of
  5971.                       the longest data field in the file.
  5972.  
  5973.                 NOTES Date fields are returned in the form "yyyymmdd".
  5974.                       There is a difference between the date formats of
  5975.                       scddfgets and scddfget.
  5976.  
  5977.                       Fields are numbered from zero (0).
  5978.  
  5979.              SEE ALSO scddfget, scddfputs, scddfinfo, scddrget.
  5980.  
  5981.               EXAMPLE #include <stdio.h>
  5982.                       #include <softc.h>
  5983.                       #include <sc_base.h>
  5984.  
  5985.                       void main()
  5986.                       {
  5987.                         int dbf;
  5988.                         char name[65], time[9], date[9], length[11],
  5989.                       attribute[4];
  5990.  
  5991.                         scdinit(20,0);
  5992.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  5993.                           scddrget(dbf,1L);
  5994.                           scddfgets(dbf,0,name);
  5995.                           scddfgets(dbf,1,length);
  5996.                           scddfgets(dbf,2,date);
  5997.                           scddfgets(dbf,3,time);
  5998.  
  5999.  
  6000.  
  6001.             User's Reference Guide                  85
  6002.  
  6003.  
  6004.  
  6005.  
  6006.  
  6007.  
  6008.  
  6009.  
  6010.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6011.  
  6012.  
  6013.                           scddfgets(dbf,4,attribute);
  6014.                           printf("%s %s %s %s %s\n",
  6015.                       name,length,date,time,attribute);
  6016.                           scddclose(dbf);
  6017.                         }
  6018.                         scdterm();
  6019.                       }
  6020.  
  6021.  
  6022.             scddfinfo_________________________________
  6023.  
  6024.                            USAGE     int scddfinfo(
  6025.                       int handle,
  6026.                       int *longfldlen,
  6027.                       SC_FIELD *fields );
  6028.  
  6029.             PROTOTYPE IN          sc_base.h
  6030.  
  6031.             DESCRIPTION           scddfinfo copies the data field
  6032.                       descriptions to "fields" using the structure
  6033.                       SC_FIELD. The length of the longest data field is
  6034.                       also returned "longfldlen".
  6035.  
  6036.                       typedef struct {
  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.             86                  SoftC Database Library
  6068.  
  6069.  
  6070.  
  6071.  
  6072.  
  6073.  
  6074.  
  6075.  
  6076.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6077.  
  6078.  
  6079.                         char name[11];    /* field name */
  6080.  
  6081.  
  6082.                         char type;   /* field type */
  6083.  
  6084.  
  6085.                         int len;  /* field length */
  6086.  
  6087.  
  6088.                         int decpl;   /* decimal places */
  6089.  
  6090.  
  6091.                       } SC_FIELD;
  6092.  
  6093.                 NOTES The user must ensure that the array defined for
  6094.                       "fields" is large enough to hold all of the field
  6095.                       descriptions because scddfinfo blindly copies the
  6096.                       descriptions to "fields". Severe program errors
  6097.                       can be the result if the field array is too small.
  6098.                       Use scddrinfo to determine the number of fields in
  6099.                       the data record.
  6100.  
  6101.              SEE ALSO scddrinfo
  6102.  
  6103.               EXAMPLE #include <stdio.h>
  6104.                       #include <softc.h>
  6105.                       #include <sc_base.h>
  6106.  
  6107.                       void main()
  6108.                       {
  6109.                         int dbf, longfld, numflds, a, reclen;
  6110.                         SC_FIELD fields[128];     /* dBASEIII max size
  6111.                       */
  6112.                         char *bfr;
  6113.                         SC_DBFRINFO rinfo;
  6114.  
  6115.                         scdinit(20,0);
  6116.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6117.                           scddrinfo(dbf,&rinfo);
  6118.                           scddfinfo(dbf,&longfld,fields);
  6119.                           printf("longest field length = %d\n",longfld);
  6120.                           for (a=0; a<rinfo.numflds; a++)
  6121.                             printf("%s %c %d %d\n", fields[a].name,
  6122.                       fields[a].type,
  6123.                                   fields[a].len, fields[a].decpl);
  6124.                           scddclose(dbf);
  6125.                         }
  6126.                         scdterm();
  6127.                       }
  6128.  
  6129.  
  6130.  
  6131.  
  6132.  
  6133.             User's Reference Guide                  87
  6134.  
  6135.  
  6136.  
  6137.  
  6138.  
  6139.  
  6140.  
  6141.  
  6142.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6143.  
  6144.  
  6145.             scddflush_________________________________
  6146.  
  6147.                            USAGE     int scddflush(
  6148.                       int handle );
  6149.  
  6150.             PROTOTYPE IN          sc_base.h
  6151.  
  6152.             DESCRIPTION           scddflush will write the contents of
  6153.                       the I/O cache to disk.  An I/O cache will be used
  6154.                       only if the data file was opened with SC_BUFFER in
  6155.                       the command switch.
  6156.  
  6157.              SEE ALSO scddopenx
  6158.  
  6159.               EXAMPLE #include <softc.h>
  6160.                       #include <sc_base.h>
  6161.  
  6162.                       void main()
  6163.                       {
  6164.                         int dbf;
  6165.                         long record;
  6166.                         char *data="TOC.DBF";
  6167.  
  6168.                         scdinit(20,0);
  6169.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  6170.                       {
  6171.                           .
  6172.                           .
  6173.                           .
  6174.                           scddrput(dbf,&record,SC_ADD);
  6175.                           scddflush(dbf);
  6176.                           .
  6177.                           .
  6178.                           .
  6179.                           scddclose(dbf);
  6180.                         }
  6181.                         scdterm();
  6182.                       }
  6183.  
  6184.  
  6185.             scddfnam2no_______________________________
  6186.  
  6187.                            USAGE     int scddfnam2no(
  6188.                       int handle,
  6189.                       int *fieldno,
  6190.                       char *fieldname );
  6191.  
  6192.             PROTOTYPE IN          sc_base.h
  6193.  
  6194.             DESCRIPTION           scddfnam2no searches through the field
  6195.                       description array for data file "handle" looking
  6196.  
  6197.  
  6198.  
  6199.             88                  SoftC Database Library
  6200.  
  6201.  
  6202.  
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6209.  
  6210.  
  6211.                       for "fieldname". It will return the corresponding
  6212.                       field number.
  6213.  
  6214.                 NOTES Data files created by the SoftC Database Library
  6215.                       will have field names and types changed to all
  6216.                       upper case.
  6217.  
  6218.               EXAMPLE #include <stdio.h>
  6219.                       #include <softc.h>
  6220.                       #include <sc_base.h>
  6221.  
  6222.                       void main()
  6223.                       {
  6224.                         int dbf, fldno
  6225.  
  6226.                         scdinit(20,0);
  6227.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6228.                           scddfnam2no(dbf,&fldno,"ATTRIBUTE");
  6229.                           printf("%d",fldno);
  6230.                           scddclose(dbf);
  6231.                         }
  6232.                         scdterm();
  6233.                       }
  6234.  
  6235.  
  6236.             scddfput__________________________________
  6237.  
  6238.                            USAGE     int scddfput(
  6239.                       int handle,
  6240.                       int fieldno,
  6241.                       void *data );
  6242.  
  6243.             PROTOTYPE IN          sc_base.h
  6244.  
  6245.             DESCRIPTION           scddfput will convert "data" from 'c'
  6246.                       format to dBASE format and place it in the proper
  6247.                       field "fieldno" of the record I/O buffer.
  6248.  
  6249.                       dBASE type  returned data type
  6250.  
  6251.  
  6252.  
  6253.  
  6254.  
  6255.  
  6256.  
  6257.  
  6258.  
  6259.  
  6260.  
  6261.  
  6262.  
  6263.  
  6264.  
  6265.             User's Reference Guide                  89
  6266.  
  6267.  
  6268.  
  6269.  
  6270.  
  6271.  
  6272.  
  6273.  
  6274.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6275.  
  6276.  
  6277.                       'C'         char *
  6278.  
  6279.  
  6280.                       'D'         char [9]
  6281.  
  6282.  
  6283.                       'F'         double (dBASE IV)
  6284.  
  6285.  
  6286.                       'L'         char
  6287.  
  6288.  
  6289.                       'M'          long
  6290.  
  6291.  
  6292.                       'N'         double
  6293.  
  6294.                 NOTES Fields are numbered from zero (0).
  6295.  
  6296.                       scddfput uses the global variable sc_date_style to
  6297.                       control date string formatting. The initial value
  6298.                       of this variable is SC_GREGOR.
  6299.  
  6300.  
  6301.  
  6302.  
  6303.  
  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.             90                  SoftC Database Library
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6341.  
  6342.  
  6343.              SEE ALSO scddfget, scddfputs.
  6344.  
  6345.               EXAMPLE #include <stdio.h>
  6346.                       #include <softc.h>
  6347.                       #include <sc_base.h>
  6348.  
  6349.                       void main()
  6350.                       {
  6351.                         int dbf;
  6352.                         double length = 1200.0L, attribute = 1.0L;
  6353.                         long recno;
  6354.  
  6355.                         scdinit(20,0);
  6356.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6357.                           scddfput(dbf,0,"ABC.XYZ");
  6358.                           scddfput(dbf,1,&length);
  6359.                           scddfput(dbf,2,"07/21/90");
  6360.                           scddfput(dbf,3,"20:01:45");
  6361.                           scddfput(dbf,4,&attribute);
  6362.                           scddrput(dbf,&recno,SC_ADD);
  6363.                           scddclose(dbf);
  6364.                         }
  6365.                         scdterm();
  6366.                       }
  6367.  
  6368.  
  6369.             scddfputs_________________________________
  6370.  
  6371.                            USAGE     int scddfputs(
  6372.                       int handle,
  6373.                       int fieldno,
  6374.                       char *data );
  6375.  
  6376.             PROTOTYPE IN          sc_base.h
  6377.  
  6378.             DESCRIPTION           scddfputs will place "data" in the
  6379.                       proper field "fieldno" of the record I/O buffer.
  6380.                       It is the user's responsibility to provide a
  6381.                       properly sized and formatted ASCIIZ string to
  6382.                       scddfputs.
  6383.  
  6384.                 NOTES Fields are numbered from zero (0).
  6385.  
  6386.                       scddfputs follows the date formatting conventions
  6387.                       of scddfgets. Also be aware that the date
  6388.                       formatting conventions of scddfget/scddfput are
  6389.                       not the same as scddfgets/scddfputs.
  6390.  
  6391.  
  6392.  
  6393.  
  6394.  
  6395.  
  6396.  
  6397.             User's Reference Guide                  91
  6398.  
  6399.  
  6400.  
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6407.  
  6408.  
  6409.              SEE ALSO scddfgets, scddfput.
  6410.  
  6411.               EXAMPLE #include <stdio.h>
  6412.                       #include <softc.h>
  6413.                       #include <sc_base.h>
  6414.  
  6415.                       void main()
  6416.                       {
  6417.                         int dbf;
  6418.                         long recno;
  6419.  
  6420.                         scdinit(20,0);
  6421.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6422.                           scddfputs(dbf,0,"ABC.XYZ");
  6423.                           scddfputs(dbf,1,"    1234.0");
  6424.                           scddfputs(dbf,2,"19900721");
  6425.                           scddfputs(dbf,3,"20:01:45");
  6426.                           scddfputs(dbf,4,"  1");
  6427.                           scddrput(dbf,&recno,SC_ADD);
  6428.                           scddclose(dbf);
  6429.                         }
  6430.                         scdterm();
  6431.                       }
  6432.  
  6433.  
  6434.             scddhget__________________________________
  6435.  
  6436.  
  6437.             USAGEint scddhget(
  6438.                       int handle );
  6439.  
  6440.             PROTOTYPE IN          sc_base.h
  6441.  
  6442.             DESCRIPTION           scddhget will read the data file
  6443.                       header. This function should be called after the
  6444.                       data file has been locked in order to reload the
  6445.                       current file header information.
  6446.  
  6447.             RETURN VALUES         SC_SUCCESS   header read successfully
  6448.                       SC_RDFAIL   file read failure
  6449.                       SC_SKFAIL   file pointer reposition failed
  6450.                       SC_BADHNDL  invalid handle number
  6451.  
  6452.              SEE ALSO scddlock.
  6453.  
  6454.               EXAMPLE #include <stdio.h>
  6455.                       #include <softc.h>
  6456.                       #include <sc_base.h>
  6457.  
  6458.                       void main()
  6459.                       {
  6460.  
  6461.  
  6462.  
  6463.             92                  SoftC Database Library
  6464.  
  6465.  
  6466.  
  6467.  
  6468.  
  6469.  
  6470.  
  6471.  
  6472.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6473.  
  6474.  
  6475.                         int dbf;
  6476.  
  6477.                         scdinit(20,0);
  6478.                         if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) ==
  6479.                       SC_SUCCESS) {
  6480.                           scddlock(dbf);
  6481.                           scddhget(dbf);
  6482.                       /* append records - add keys - etc. */
  6483.                           scddunlock(dbf);
  6484.                           scddclose(dbf);
  6485.                         }
  6486.                         scdterm();
  6487.                       }
  6488.  
  6489.  
  6490.             scddinfo__________________________________
  6491.  
  6492.                            USAGE     int scddinfo(
  6493.                       int handle,
  6494.                       SC_DBFINFO *info );
  6495.  
  6496.             PROTOTYPE IN          sc_base.h
  6497.  
  6498.             DESCRIPTION           scddinfo returns an information
  6499.                       structure for the file associated with "handle".
  6500.  
  6501.                       typedef struct {
  6502.                         char fname[80];   /* file name */
  6503.                         char style;  /* file type */
  6504.                                      /* (dBASE 3 or 4) */
  6505.                         char memo;   /* memo file used */
  6506.                         char mdx;    /* MDX file used */
  6507.                         char trans;  /* transaction */
  6508.                                      /* in progress */
  6509.                         char encrypt;     /* data encrypted */
  6510.                         char lockt;  /* lock status */
  6511.                         unsigned long ladrs;   /* address of lock */
  6512.                         unsigned long lsize;   /* locked length */
  6513.                         SC_FLAGS flags;   /* misc. flags */
  6514.                       } SC_DBFINFO;
  6515.  
  6516.              SEE ALSO scddopenx
  6517.  
  6518.               EXAMPLE #include <stdio.h>
  6519.                       #include <softc.h>
  6520.                       #include <sc_base.h>
  6521.  
  6522.                       void main()
  6523.                       {
  6524.                         int dbf;
  6525.                         SC_DBFINFO info;
  6526.  
  6527.  
  6528.  
  6529.             User's Reference Guide                  93
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6539.  
  6540.  
  6541.  
  6542.                         scdinit(20,0);
  6543.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6544.                           scddinfo(dbf,&info);
  6545.                           puts(info.fname);
  6546.                           if (info.style == SC_DB3)
  6547.                             puts("dBASE III data file");
  6548.                           else {
  6549.                             puts("dBASE IV data file");
  6550.                             if (info.memo)
  6551.                               puts("memo file attached");
  6552.                             else
  6553.                               puts("no memo file attached");
  6554.                             if (info.mdx)
  6555.                               puts(".MDX file used")
  6556.                             else
  6557.                               puts("No .MDX file used");
  6558.                             if (info.trans)
  6559.                               puts("Transaction in progress");
  6560.                             if (info.encrypt)
  6561.                               puts("File encrypted");
  6562.                           }
  6563.                           scddclose(dbf);
  6564.                         }
  6565.                         scdterm();
  6566.                       }
  6567.  
  6568.  
  6569.             scddlock__________________________________
  6570.  
  6571.                            USAGE     int scddlock(
  6572.                       int handle );
  6573.  
  6574.             PROTOTYPE IN          sc_base.h
  6575.  
  6576.             DESCRIPTION           scddlock will lock the entire data
  6577.                       file for exclusive use by this station.  This
  6578.                       function should be used immediately prior to
  6579.                       adding records to the data file, or writing to the
  6580.                       index and/or memo files.  A call to scddunlock
  6581.                       should immediately follow the write so that others
  6582.                       may again access the data, memo, and index files.
  6583.  
  6584.                       File sharing is enabled by opening the data file
  6585.                       with SC_SHARED in the command switch.  Any
  6586.                       associated index and memo files should also be
  6587.                       opened with SC_SHARED in the command switch.
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.             94                  SoftC Database Library
  6596.  
  6597.  
  6598.  
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6605.  
  6606.  
  6607.              SEE ALSO scddopenx, scddrlock,scddunlock.
  6608.  
  6609.               EXAMPLE #include <softc.h>
  6610.                       #include <sc_base.h>
  6611.  
  6612.                       void main()
  6613.                       {
  6614.                         int dbf;
  6615.                         long record;
  6616.                         double length=1305,attribute=1;
  6617.                         char *data="TOC.DBF";
  6618.  
  6619.                         scdinit(20,0);
  6620.                         if (scddopenx(&dbf,data,SC_SHARED)==SC_SUCCESS)
  6621.                       {
  6622.                           scddfput(dbf,0,"MNO.XYZ");
  6623.                           scddfput(dbf,1,&length);
  6624.                           scddfput(dbf,2,"07/22/90");
  6625.                           scddfput(dbf,3,"20:10:45");
  6626.                           scddfput(dbf,4,&attribute);
  6627.                           scddlock(dbf);
  6628.                           scddrput(dbf,&record,SC_ADD);
  6629.                           scddunlock(dbf);
  6630.                           scddclose(dbf);
  6631.                         }
  6632.                         scdterm();
  6633.                       }
  6634.  
  6635.  
  6636.             scddlud___________________________________
  6637.  
  6638.                            USAGE     int scddlud(
  6639.                       int handle,
  6640.                       char *datestr,
  6641.                       int format );
  6642.  
  6643.             PROTOTYPE IN          sc_base.h
  6644.  
  6645.             DESCRIPTION           scddlud returns the ASCIIZ date string
  6646.                       ("datestr") of when the last update to the data
  6647.                       file was made.  The date string will be under
  6648.                       control of the "format" command.  This date will
  6649.                       be updated after the data file has been closed.
  6650.  
  6651.                       Date string styles:
  6652.  
  6653.  
  6654.  
  6655.  
  6656.  
  6657.  
  6658.  
  6659.  
  6660.  
  6661.             User's Reference Guide                  95
  6662.  
  6663.  
  6664.  
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6671.  
  6672.  
  6673.                       SC_GREGOR   mm/dd/yy
  6674.  
  6675.  
  6676.                       SC_GREGORL  mm/dd/yyyy
  6677.  
  6678.  
  6679.                       SC_JULIAN   yyyy/ddd
  6680.  
  6681.  
  6682.                       SC_YMD      yyyymmdd
  6683.  
  6684.  
  6685.                       SC_DMY      ddmmyy
  6686.  
  6687.               EXAMPLE #include <stdio.h>
  6688.                       #include <softc.h>
  6689.                       #include <sc_base.h>
  6690.  
  6691.                       void main()
  6692.                       {
  6693.                         int dbf;
  6694.                         char date[9];
  6695.  
  6696.                         scdinit(20,0);
  6697.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6698.                           scddlud(dbf,&date,SC_YMD);
  6699.                           puts(date);
  6700.                           scddclose(dbf);
  6701.                         }
  6702.                         scdterm();
  6703.                       }
  6704.  
  6705.  
  6706.             scddopenx_________________________________
  6707.  
  6708.                            USAGE     int scddopenx(
  6709.                       int *handle,
  6710.                       char *filename,
  6711.                       int command );
  6712.  
  6713.             PROTOTYPE IN          sc_base.h
  6714.  
  6715.             DESCRIPTION           scddopenx opens a data file.  Memory
  6716.                       will be allocated for a file packet and I/O
  6717.                       buffers for use internally by the SoftC Database
  6718.                       Library file manager.  The data file will be
  6719.                       tested as much as possible to insure that it is a
  6720.                       legitimate dBASE data file.
  6721.  
  6722.                       The file will be opened under control of the
  6723.                       "command" parameter.  Using SC_RDWR opens the file
  6724.  
  6725.  
  6726.  
  6727.             96                  SoftC Database Library
  6728.  
  6729.  
  6730.  
  6731.  
  6732.  
  6733.  
  6734.  
  6735.  
  6736.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6737.  
  6738.  
  6739.                       for both read and write access.  SC_RDONLY
  6740.                       overrides SC_RDWR and causes the file to be opened
  6741.                       for read access only.  Any attempt to write to a
  6742.                       read only file will result in an error
  6743.                       (SC_READOLY).
  6744.  
  6745.                       Using SC_EXCLUDE opens the file for exclusive use
  6746.                       of this station (single user).  SC_SHARED
  6747.                       overrides SC_EXCLUDE and opens the file in multi-
  6748.                       user mode.  This mode is used when a LAN file is
  6749.                       to be shared with other stations.
  6750.  
  6751.                       Using SC_BUFFER opens the file with I/O caching
  6752.                       enabled.  A buffer of at least 512 bytes but no
  6753.                       more than 16384 will be allocated during the open.
  6754.                       Caching of record I/O greatly increases the speed
  6755.                       of sequential file access.  Typically this mode is
  6756.                       used with single user files.  SC_FLUSH overrides
  6757.                       SC_BUFFER and causes the file to be opened with no
  6758.                       caching.  This mode is generally used with file
  6759.                       sharing, although it is not required.
  6760.  
  6761.                 NOTES All field names and types, and the file name will
  6762.                       be converted to upper case after the file has been
  6763.                       opened.
  6764.  
  6765.              SEE ALSO scddopenx
  6766.  
  6767.               EXAMPLE #include <softc.h>
  6768.                       #include <sc_base.h>
  6769.  
  6770.                       void main()
  6771.                       {
  6772.                         int dbf;
  6773.                         char *data="TOC.DBF";
  6774.  
  6775.                         scdinit(20,0);
  6776.                         scddopenx(&dbf,data,SC_SHARED|SC_FLUSH|SC_RDWR);
  6777.                         scdterm();
  6778.                       }
  6779.  
  6780.  
  6781.             scddpack__________________________________
  6782.  
  6783.                            USAGE     int scddpack(
  6784.                       int *handle );
  6785.  
  6786.             PROTOTYPE IN          sc_base.h
  6787.  
  6788.             DESCRIPTION           scddpack will remove all data file
  6789.                       records which have been flagged as deleted
  6790.  
  6791.  
  6792.  
  6793.             User's Reference Guide                  97
  6794.  
  6795.  
  6796.  
  6797.  
  6798.  
  6799.  
  6800.  
  6801.  
  6802.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6803.  
  6804.  
  6805.                       (SC_NOTUSED).   The data file will be compressed
  6806.                       so that all active records will be contiguous
  6807.                       after the pack.  Files opened with the read only
  6808.                       flag (SC_RDONLY) cannot be packed.
  6809.  
  6810.              SEE ALSO scddopenx,scdnindex,scdtpack
  6811.  
  6812.               EXAMPLE #include <softc.h>
  6813.                       #include <sc_base.h>
  6814.  
  6815.                       void main()
  6816.                       {
  6817.                         int dbf;
  6818.  
  6819.                         scdinit(20,0);
  6820.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6821.                           scddpack(&dbf);
  6822.                           scddclose(dbf);
  6823.                         }
  6824.                         scdterm();
  6825.                       }
  6826.  
  6827.  
  6828.             scddrclear________________________________
  6829.  
  6830.                            USAGE     int scddrclear(
  6831.                       int handle );
  6832.  
  6833.             PROTOTYPE IN          sc_base.h
  6834.  
  6835.             DESCRIPTION           scddrclear clears the record buffer.
  6836.                       The buffer will be written with spaces (" ") NOT
  6837.                       zeros (0).
  6838.  
  6839.               EXAMPLE #include <stdio.h>
  6840.                       #include <softc.h>
  6841.                       #include <sc_base.h>
  6842.  
  6843.                       void main()
  6844.                       {
  6845.                         int dbf;
  6846.                         char name[65];
  6847.  
  6848.                         scdinit(20,0);
  6849.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6850.                           scddfput(dbf,0,"Now is the time for all...");
  6851.                           scddrclear(dbf);
  6852.                           scddfget(dbf,0,name);
  6853.                           puts(name);
  6854.                         }
  6855.  
  6856.  
  6857.  
  6858.  
  6859.             98                  SoftC Database Library
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  6869.  
  6870.  
  6871.                         scdterm();
  6872.                       }
  6873.  
  6874.  
  6875.             scddrdel__________________________________
  6876.  
  6877.                            USAGE     int scddrdel(
  6878.                       int handle,
  6879.                       long recno );
  6880.  
  6881.             PROTOTYPE IN          sc_base.h
  6882.  
  6883.             DESCRIPTION           scddrdel will flag a record specified
  6884.                       by "recno" as 'deleted'. To maintain compatibility
  6885.                       with dBASE the data record cannot be reused, but
  6886.                       it can be recovered by scddrundel.
  6887.  
  6888.              SEE ALSO scddrundel.
  6889.  
  6890.               EXAMPLE #include <stdio.h>
  6891.                       #include <softc.h>
  6892.                       #include <sc_base.h>
  6893.  
  6894.                       void main()
  6895.                       {
  6896.                         int dbf;
  6897.  
  6898.                         scdinit(20,0);
  6899.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  6900.                           scddrdel(dbf,1L);
  6901.                           scddrget(dbf,1L);
  6902.                           puts(scemsg()); /* WARNING - record read is
  6903.                       deleted */
  6904.                           scddclose(dbf);
  6905.                         }
  6906.                         scdterm();
  6907.                       }
  6908.  
  6909.  
  6910.             scddrget__________________________________
  6911.  
  6912.                            USAGE     int scddrget(
  6913.                       int handle,
  6914.                       long recno );
  6915.  
  6916.  
  6917.  
  6918.  
  6919.  
  6920.  
  6921.  
  6922.  
  6923.  
  6924.  
  6925.             User's Reference Guide                  99
  6926.  
  6927.  
  6928.  
  6929.  
  6930.  
  6931.  
  6932.  
  6933.  
  6934.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  6935.  
  6936.  
  6937.             PROTOTYPE IN          sc_base.h
  6938.  
  6939.             DESCRIPTION           scddrget will read the data record
  6940.                       specified by "recno" from the data file associated
  6941.                       with "handle" into the internal record buffer.
  6942.  
  6943.             RETURN VALUES         SC_DELREC    inactive record read
  6944.                       SC_SUCCESS  data record read successfully
  6945.                       SC_RDFAIL   file read failure
  6946.                       SC_SKFAIL   file pointer reposition failed
  6947.                       SC_BADHNDL  invalid handle number
  6948.  
  6949.              SEE ALSO scddfget, scddfput, scddrgetx, scddrput.
  6950.  
  6951.               EXAMPLE #include <stdio.h>
  6952.                       #include <softc.h>
  6953.                       #include <sc_base.h>
  6954.  
  6955.                       void main()
  6956.                       {
  6957.                         int dbf;
  6958.                         char name[65], time[9], date[9];
  6959.                         double length, attribute;
  6960.  
  6961.                         scdinit(20,0);
  6962.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  6963.                           scddrget(dbf,1L);
  6964.                           scddfget(dbf,0,name);
  6965.                           scddfget(dbf,1,&length);
  6966.                           scddfget(dbf,2,date);
  6967.                           scddfget(dbf,3,time);
  6968.                           scddfget(dbf,4,&attribute);
  6969.                           printf("%s %lf %s %s %lf\n",
  6970.                       name,length,date,time,attribute);
  6971.                           scddclose(dbf);
  6972.                         }
  6973.                         scdterm();
  6974.                       }
  6975.  
  6976.  
  6977.             scddrgetx_________________________________
  6978.  
  6979.                            USAGE     int scddrgetx(
  6980.                       int handle,
  6981.                       char *buffer,
  6982.                       long recno );
  6983.  
  6984.  
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.             100                 SoftC Database Library
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7001.  
  7002.  
  7003.             PROTOTYPE IN          sc_base.h
  7004.  
  7005.             DESCRIPTION           scddrgetx will read the data record
  7006.                       specified by "recno" from the data file associated
  7007.                       with "handle" into the user specified buffer.
  7008.  
  7009.             RETURN VALUES         SC_DELREC    inactive record read
  7010.                       SC_SUCCESS  data record read successfully
  7011.                       SC_RDFAIL   file read failure
  7012.                       SC_SKFAIL   file pointer reposition failed
  7013.                       SC_BADHNDL  invalid handle number
  7014.  
  7015.              SEE ALSO scddfget, scddfput, scddrget, scddrputx.
  7016.  
  7017.               EXAMPLE #include <stdio.h>
  7018.                       #include <softc.h>
  7019.                       #include <sc_base.h>
  7020.  
  7021.                       void main()
  7022.                       {
  7023.                         int dbf;
  7024.                         struct {
  7025.                           char status;
  7026.                           char name[65];
  7027.                           char length[10];
  7028.                           char date[9];
  7029.                           char time[9];
  7030.                           char attribute[2];
  7031.                         } buffer;
  7032.  
  7033.                         scdinit(20,0);
  7034.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7035.                           scddrgetx(dbf,buffer,1L);
  7036.                           printf("%s\n",buffer);
  7037.                           scddclose(dbf);
  7038.                         }
  7039.                         scdterm();
  7040.                       }
  7041.  
  7042.  
  7043.             scddrinfo_________________________________
  7044.  
  7045.                            USAGE     int scddrinfo(
  7046.                       int handle,
  7047.                       SC_DBFRINFO *rinfo );
  7048.  
  7049.  
  7050.  
  7051.  
  7052.  
  7053.  
  7054.  
  7055.  
  7056.  
  7057.             User's Reference Guide                 101
  7058.  
  7059.  
  7060.  
  7061.  
  7062.  
  7063.  
  7064.  
  7065.  
  7066.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7067.  
  7068.  
  7069.             PROTOTYPE IN          sc_base.h
  7070.  
  7071.             DESCRIPTION           scddrinfo gets the data record length,
  7072.                       the number of data fields per record, and the
  7073.                       address of the record buffer.
  7074.  
  7075.                       typedef struct {
  7076.  
  7077.  
  7078.                         int reclen;  /* record length */
  7079.  
  7080.  
  7081.                         int numflds; /* number of */
  7082.  
  7083.  
  7084.                                   /* fields */
  7085.  
  7086.  
  7087.                          char *bfr;  /* buffer address */
  7088.  
  7089.  
  7090.                       } SC_DBFRINFO;
  7091.  
  7092.               EXAMPLE #include <stdio.h>
  7093.                       #include <softc.h>
  7094.                       #include <sc_base.h>
  7095.  
  7096.                       void main()
  7097.                       {
  7098.                         int dbf;
  7099.                         SC_DBFRINFO rinfo;
  7100.  
  7101.                         scdinit(20,0);
  7102.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7103.                           scddrinfo(dbf,&rinfo);
  7104.                           printf("Record length = %d\n",rinfo.reclen);
  7105.                           printf("Number of fields =
  7106.                       %d\n",rinfo.numflds);
  7107.                           printf("Record buffer = %p\n",rinfo.bfr);
  7108.                           scddclose(dbf);
  7109.                         }
  7110.                         scdterm();
  7111.                       }
  7112.  
  7113.  
  7114.             scddrlock_________________________________
  7115.  
  7116.                            USAGE     int scddrlock(
  7117.                       int handle,
  7118.                       long record );
  7119.  
  7120.  
  7121.  
  7122.  
  7123.             102                 SoftC Database Library
  7124.  
  7125.  
  7126.  
  7127.  
  7128.  
  7129.  
  7130.  
  7131.  
  7132.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7133.  
  7134.  
  7135.             PROTOTYPE IN          sc_base.h
  7136.  
  7137.             DESCRIPTION           scddrlock will lock the specified
  7138.                       "record" in the data file for exclusive use by
  7139.                       this station.  This function should be used
  7140.                       immediately prior to updating a data file record.
  7141.                       A call to scddunlock should immediately follow the
  7142.                       write so that others may again access the data
  7143.                       record.
  7144.  
  7145.                       File sharing is enabled by opening the data file
  7146.                       with SC_SHARED in the command switch.
  7147.  
  7148.              SEE ALSO scddopenx, scddlock,scddunlock.
  7149.  
  7150.               EXAMPLE #include <stdio.h>
  7151.                       #include <softc.h>
  7152.                       #include <sc_base.h>
  7153.  
  7154.                       void main()
  7155.                       {
  7156.                         int dbf;
  7157.                         long record = 1L;
  7158.                         double length=1936, attribute=1;
  7159.                         char *data="TOC.DBF";
  7160.  
  7161.                         scdinit(20,0);
  7162.                         if (scddopenx(&dbf,data,SC_SHARED)==SC_SUCCESS)
  7163.                       {
  7164.                           scddfput(dbf,0,"MNO.XYZ");
  7165.                           scddfput(dbf,1,&length);
  7166.                           scddfput(dbf,2,"07/22/90");
  7167.                           scddfput(dbf,3,"20:10:45");
  7168.                           scddfput(dbf,4,&attribute);
  7169.                           scdnkmake(dbf,ndx,&key);
  7170.                           scdrlock(dbf,record);
  7171.                           scddrput(dbf,&record,SC_UPDATE);
  7172.                           scddunlock(dbf);
  7173.                           free(key);
  7174.                           scddclose(dbf);
  7175.                         }
  7176.                         scdterm();
  7177.                       }
  7178.  
  7179.  
  7180.             scddrnum__________________________________
  7181.  
  7182.                            USAGE     int scddrnum(
  7183.                       int handle,
  7184.                       long *position );
  7185.  
  7186.  
  7187.  
  7188.  
  7189.             User's Reference Guide                 103
  7190.  
  7191.  
  7192.  
  7193.  
  7194.  
  7195.  
  7196.  
  7197.  
  7198.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7199.  
  7200.  
  7201.             PROTOTYPE IN          sc_base.h
  7202.  
  7203.             DESCRIPTION           scddrnum returns the current position
  7204.                       (record number) in the data file.
  7205.  
  7206.              SEE ALSO scddbof, scddeof.
  7207.  
  7208.               EXAMPLE #include <stdio.h>
  7209.                       #include <softc.h>
  7210.                       #include <sc_base.h>
  7211.  
  7212.                       void main()
  7213.                       {
  7214.                         int dbf;
  7215.                         long position;
  7216.  
  7217.                         scdinit(20,0);
  7218.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7219.                           scddrget(dbf,4L);
  7220.                           scddrnum(dbf,&position);
  7221.                           printf("%ld\n",position);
  7222.                           scddclose(dbf);
  7223.                         }
  7224.                         scdterm();
  7225.                       }
  7226.  
  7227.  
  7228.             scddrput__________________________________
  7229.  
  7230.                            USAGE     int scddrput(
  7231.                       int handle,
  7232.                       long *recno,
  7233.                       int howto );
  7234.  
  7235.             PROTOTYPE IN          sc_base.h
  7236.  
  7237.             DESCRIPTION           scddrput will write the data record
  7238.                       specified by "recno" to the data file associated
  7239.                       with "handle" from the internal record buffer.
  7240.                       "howto" determines how the data record is to be
  7241.                       written:
  7242.  
  7243.                       "howto" =   action
  7244.  
  7245.  
  7246.  
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.             104                 SoftC Database Library
  7256.  
  7257.  
  7258.  
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7265.  
  7266.  
  7267.                       SC_ADD      append to end of file
  7268.  
  7269.  
  7270.                       SC_UPDATE   update current record
  7271.  
  7272.                       If a record update is occurring the data record
  7273.                       number passed in "recno" will be written in the
  7274.                       disk file.
  7275.  
  7276.                       Use scddrget to load a data record or scddfput or
  7277.                       scddfputs to fill the data record field by field.
  7278.  
  7279.              SEE ALSO scddfput, scddfputs, scddrget, scddrputx.
  7280.  
  7281.               EXAMPLE #include <stdio.h>
  7282.                       #include <softc.h>
  7283.                       #include <sc_base.h>
  7284.  
  7285.                       void main()
  7286.                       {
  7287.                         int dbf;
  7288.                         double length = 1200.0L, attribute = 1.0L;
  7289.                         long recno;
  7290.  
  7291.                         scdinit(20,0);
  7292.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7293.                           scddfput(dbf,0,"ABC.XYZ");
  7294.                           scddfput(dbf,1,&length);
  7295.                           scddfput(dbf,2,"07/21/90");
  7296.                           scddfput(dbf,3,"20:01:45");
  7297.                           scddfput(dbf,4,&attribute);
  7298.                           scddrput(dbf,&recno,SC_ADD);
  7299.                           scddclose(dbf);
  7300.                         }
  7301.                         scdterm();
  7302.                       }
  7303.  
  7304.  
  7305.             scddrputx_________________________________
  7306.  
  7307.                            USAGE     int scddrputx(
  7308.                       int handle,
  7309.                       char *buffer,
  7310.                       long *recno,
  7311.                       int howto );
  7312.  
  7313.             PROTOTYPE IN          sc_base.h
  7314.  
  7315.             DESCRIPTION           scddrputx will write the data record
  7316.                       specified by "recno" to the data file associated
  7317.                       with "handle" from the user specified buffer.
  7318.  
  7319.  
  7320.  
  7321.             User's Reference Guide                 105
  7322.  
  7323.  
  7324.  
  7325.  
  7326.  
  7327.  
  7328.  
  7329.  
  7330.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7331.  
  7332.  
  7333.                       "howto" determines how the data record is to be
  7334.                       written:
  7335.  
  7336.                       "howto" =   action
  7337.  
  7338.  
  7339.                       SC_ADD      append to end of file
  7340.  
  7341.  
  7342.                       SC_UPDATE   update current record
  7343.  
  7344.                       If a record update is occurring the data record
  7345.                       number passed in "recno" will be written in the
  7346.                       disk file.
  7347.  
  7348.                       Use scddrgetx to load a data record or scddfput or
  7349.                       scddfputs to fill the data record field by field.
  7350.  
  7351.  
  7352.  
  7353.  
  7354.  
  7355.  
  7356.  
  7357.  
  7358.  
  7359.  
  7360.  
  7361.  
  7362.  
  7363.  
  7364.  
  7365.  
  7366.  
  7367.  
  7368.  
  7369.  
  7370.  
  7371.  
  7372.  
  7373.  
  7374.  
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.  
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.  
  7387.             106                 SoftC Database Library
  7388.  
  7389.  
  7390.  
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7397.  
  7398.  
  7399.              SEE ALSO scddfput, scddfputs, scddrgetx, scddrput.
  7400.  
  7401.               EXAMPLE #include <stdio.h>
  7402.                       #include <softc.h>
  7403.                       #include <sc_base.h>
  7404.  
  7405.                       void main()
  7406.                       {
  7407.                         int dbf;
  7408.                         struct {
  7409.                           char status;
  7410.                           char name[65];
  7411.                           char length[10];
  7412.                           char date[9];
  7413.                           char time[9];
  7414.                           char attribute[2];
  7415.                         } buffer;
  7416.  
  7417.                         scdinit(20,0);
  7418.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7419.                           scddrgetx(dbf,buffer,1L);
  7420.                           strncpy(buffer.name,"ABC.XYZ",65);
  7421.                           scddrputx(dbf,buffer,&recno,SC_ADD);
  7422.                           scddclose(dbf);
  7423.                         }
  7424.                         scdterm();
  7425.                       }
  7426.  
  7427.  
  7428.             scddrstat_________________________________
  7429.  
  7430.                            USAGE     int scddrstat(
  7431.                       int handle );
  7432.  
  7433.             PROTOTYPE IN          sc_base.h
  7434.  
  7435.             DESCRIPTION           scddrstat returns an indicator as to
  7436.                       whether or not the current record loaded is active
  7437.                       or inactive (flagged as deleted).
  7438.  
  7439.             RETURN VALUE          SC_DELREC    record inactive
  7440.  
  7441.  
  7442.                       SC_SUCCESS  active record
  7443.  
  7444.              SEE ALSO scddrget
  7445.  
  7446.               EXAMPLE #include <stdio.h>
  7447.                       #include <softc.h>
  7448.                       #include <sc_base.h>
  7449.  
  7450.  
  7451.  
  7452.  
  7453.             User's Reference Guide                 107
  7454.  
  7455.  
  7456.  
  7457.  
  7458.  
  7459.  
  7460.  
  7461.  
  7462.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7463.  
  7464.  
  7465.                       void main()
  7466.                       {
  7467.                         int dbf;
  7468.  
  7469.                         scdinit(20,0);
  7470.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7471.                           scddrget(dbf,1L);
  7472.                           if (scddrstat(dbf) == SC_DELREC)
  7473.                             puts("Record is inactive.");
  7474.                           else
  7475.                             puts("Record is active.");
  7476.                           scddclose(dbf);
  7477.                         }
  7478.                         scdterm();
  7479.                       }
  7480.  
  7481.  
  7482.             scddrundel________________________________
  7483.  
  7484.                            USAGE     int scddrundel(
  7485.                       int handle,
  7486.                       long recno );
  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.             108                 SoftC Database Library
  7520.  
  7521.  
  7522.  
  7523.  
  7524.  
  7525.  
  7526.  
  7527.  
  7528.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7529.  
  7530.  
  7531.             PROTOTYPE IN          sc_base.h
  7532.  
  7533.             DESCRIPTION           scddrundel will remove the 'deleted'
  7534.                       flag from the data record specified by "recno".
  7535.  
  7536.              SEE ALSO scddrdel.
  7537.  
  7538.               EXAMPLE #include <stdio.h>
  7539.                       #include <softc.h>
  7540.                       #include <sc_base.h>
  7541.  
  7542.                       void main()
  7543.                       {
  7544.                         int dbf;
  7545.  
  7546.                         scdinit(20,0);
  7547.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7548.                           scddrundel(dbf,1L);
  7549.                           scddrget(dbf,1L);
  7550.                           puts(scemsg());
  7551.                           scddclose(dbf);
  7552.                         }
  7553.                         scdterm();
  7554.                       }
  7555.  
  7556.  
  7557.             scddsize__________________________________
  7558.  
  7559.                            USAGE     int scddsize(
  7560.                       int handle,
  7561.                       long *recsused );
  7562.  
  7563.             PROTOTYPE IN          sc_base.h
  7564.  
  7565.             DESCRIPTION           scddsize gets the number of records
  7566.                       "recsused" in the data file. This number will
  7567.                       include all records inactive as well as active
  7568.                       records.
  7569.  
  7570.               EXAMPLE #include <stdio.h>
  7571.                       #include <softc.h>
  7572.                       #include <sc_base.h>
  7573.  
  7574.                       void main()
  7575.                       {
  7576.                         int dbf;
  7577.                         long recsused;
  7578.  
  7579.                         scdinit(20,0);
  7580.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  7581.                           scddsize(dbf,&recsused);
  7582.  
  7583.  
  7584.  
  7585.             User's Reference Guide                 109
  7586.  
  7587.  
  7588.  
  7589.  
  7590.  
  7591.  
  7592.  
  7593.  
  7594.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7595.  
  7596.  
  7597.                           printf("%ld",recsused);
  7598.                           scddclose(dbf);
  7599.                         }
  7600.                         scdterm();
  7601.                       }
  7602.  
  7603.  
  7604.             scddunlock________________________________
  7605.  
  7606.                            USAGE     int scddunlock(
  7607.                       int handle );
  7608.  
  7609.             PROTOTYPE IN          sc_base.h
  7610.  
  7611.             DESCRIPTION           scddunlock will unlock the data
  7612.                       file/record for shared use by other stations.
  7613.                       This function should be used immediately after
  7614.                       writing to all required data, index and memo
  7615.                       files.
  7616.  
  7617.                       File sharing is enabled by opening the data file
  7618.                       with SC_SHARED in the command switch.  Any
  7619.                       associated index and memo files should also be
  7620.                       opened with SC_SHARED in the command switch.
  7621.  
  7622.              SEE ALSO scddopenx, scddlock,scddrlock.
  7623.  
  7624.               EXAMPLE #include <stdio.h>
  7625.                       #include <softc.h>
  7626.                       #include <sc_base.h>
  7627.  
  7628.                       void main()
  7629.                       {
  7630.                         int dbf, ndx;
  7631.                         char *key,*data="TOC.DBF",*index="TOCNAME.NDX";
  7632.                         long record;
  7633.                         double length = 2367, attribute = 1;
  7634.  
  7635.                         scdinit(20,0);
  7636.                         if (scddopenx(&dbf,data,SC_SHARED)==SC_SUCCESS)
  7637.                       {
  7638.                           if
  7639.                       (scdnopenx(&ndx,index,SC_SHARED)==SC_SUCCESS) {
  7640.                             scddfput(dbf,0,"ABC.XYZ");
  7641.                             scddfput(dbf,1,&length);
  7642.                             scddfput(dbf,2,"07/21/90");
  7643.                             scddfput(dbf,3,"20:01:45");
  7644.                             scddfput(dbf,4,&attribute);
  7645.                             scdnkmake(dbf,ndx,&key);
  7646.                             scddlock(dbf);
  7647.                             scddrput(dbf,&record,SC_ADD);
  7648.  
  7649.  
  7650.  
  7651.             110                 SoftC Database Library
  7652.  
  7653.  
  7654.  
  7655.  
  7656.  
  7657.  
  7658.  
  7659.  
  7660.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7661.  
  7662.  
  7663.                             scdnkadd(ndx,key,record);
  7664.                             scddunlock(dbf);
  7665.                             free(key);
  7666.                             scdnclose(ndx);
  7667.                           }
  7668.                           scddclose(dbf);
  7669.                         }
  7670.                         scdterm();
  7671.                       }
  7672.  
  7673.  
  7674.             scdibfrsz_________________________________
  7675.  
  7676.                            USAGE     int scdibfrsz(
  7677.                       int handle,
  7678.                       int *numpgs,
  7679.                       int command );
  7680.  
  7681.             PROTOTYPE IN          sc_base.h
  7682.  
  7683.             DESCRIPTION           scdibfrsz will either get (SC_GETSZ)
  7684.                       or set (SC_SETSZ) the maximum number of index
  7685.                       pages the library file manager can keep in memory
  7686.                       and returns it via "numpgs".  This is under
  7687.                       control of "command".
  7688.  
  7689.               EXAMPLE /* Get Size */
  7690.                       #include <stdio.h>
  7691.                       #include <softc.h>
  7692.                       #include <sc_base.h>
  7693.  
  7694.                       void main()
  7695.                       {
  7696.                         int idx, numpgs;
  7697.                         char *index="TOCNAME.IDX";
  7698.  
  7699.                         scdinit(20,0);
  7700.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  7701.                       {
  7702.                           scdibfrsz(idx,&numpgs,SC_GETSZ) == SC_SUCCESS)
  7703.                           printf("Maximum number of pages =
  7704.                       %d\n",numpgs);
  7705.                           scdiclose(idx);
  7706.                         }
  7707.                         scdterm();
  7708.                       }
  7709.  
  7710.                       /* Set Size */
  7711.                       #include <stdio.h>
  7712.                       #include <softc.h>
  7713.                       #include <sc_base.h>
  7714.  
  7715.  
  7716.  
  7717.             User's Reference Guide                 111
  7718.  
  7719.  
  7720.  
  7721.  
  7722.  
  7723.  
  7724.  
  7725.  
  7726.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7727.  
  7728.  
  7729.  
  7730.                       void main()
  7731.                       {
  7732.                         char idx,numpgs=5,*index="TOCNAME.IDX";
  7733.  
  7734.                         scdinit(20,0);
  7735.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  7736.                       {
  7737.                           scdibfrsz(idx,&numpgs,SC_SETSZ);
  7738.                           printf("New max = %d\n",numpgs);
  7739.                           scdiclose(idx);
  7740.                         }
  7741.                         scdterm();
  7742.                       }
  7743.  
  7744.  
  7745.             scdiclose_________________________________
  7746.  
  7747.                            USAGE     int scdiclose(
  7748.                       int handle );
  7749.  
  7750.             PROTOTYPE IN          sc_base.h
  7751.  
  7752.             DESCRIPTION           scdiclose closes an index file and
  7753.                       frees all allocated memory associated with the
  7754.                       index file specified by "handle".
  7755.  
  7756.               EXAMPLE #include <stdio.h>
  7757.                       #include <softc.h>
  7758.                       #include <sc_base.h>
  7759.  
  7760.                       void main()
  7761.                       {
  7762.                         int idx;
  7763.                         char *index="TOCNAME.IDX";
  7764.  
  7765.                         scdinit(20,0);
  7766.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  7767.                           scdiclose(idx);
  7768.                         scdterm();
  7769.                       }
  7770.  
  7771.  
  7772.             scdicreate________________________________
  7773.  
  7774.                            USAGE     int scdicreate(
  7775.                       char *filename,
  7776.                       int keytype,
  7777.                       char *keyexpr,
  7778.                       int keylen );
  7779.  
  7780.  
  7781.  
  7782.  
  7783.             112                 SoftC Database Library
  7784.  
  7785.  
  7786.  
  7787.  
  7788.  
  7789.  
  7790.  
  7791.  
  7792.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7793.  
  7794.  
  7795.             PROTOTYPE IN          sc_base.h
  7796.  
  7797.             DESCRIPTION           scdicreate creates an index file.
  7798.                       "keyexpr" will be translated to all upper case
  7799.                       when the index file is created.
  7800.  
  7801.                       If "keytype" is SC_CKEY, then "keyexpr" must be an
  7802.                       ASCIIZ string consisting of one or more field
  7803.                       names from the data record. All fields included in
  7804.                       the expression must be of type 'c' or be
  7805.                       translated into type 'c'. No check is made to
  7806.                       verify this. "keyexpr" cannot be longer that 220
  7807.                       characters. "keylen" cannot exceed 100.
  7808.  
  7809.                       If "keytype" is SC_DKEY or SC_NKEY, then "keyexpr"
  7810.                       should consist of only one data field. "keylen"
  7811.                       will automatically be set to 8 (numeric and date
  7812.                       keys are stored as modified doubles).
  7813.  
  7814.                       If "keytype" is SC_LKEY, then "keyexpr" should
  7815.                       consist of only one data field. "keylen" will
  7816.                       automatically be set to 1 (logical keys are stored
  7817.                       as characters).
  7818.  
  7819.                       When unique keys are required, OR SC_UNIQUE with
  7820.                       "keytype".
  7821.  
  7822.                 NOTES scdicreate will create a new index file even if
  7823.                       one had already existed.
  7824.  
  7825.                       "keyexpr" is NOT checked for validity during the
  7826.                       file creation process. Currently only the
  7827.                       scdikmake function uses "keyexpr".
  7828.  
  7829.  
  7830.  
  7831.  
  7832.  
  7833.  
  7834.  
  7835.  
  7836.  
  7837.  
  7838.  
  7839.  
  7840.  
  7841.  
  7842.  
  7843.  
  7844.  
  7845.  
  7846.  
  7847.  
  7848.  
  7849.             User's Reference Guide                 113
  7850.  
  7851.  
  7852.  
  7853.  
  7854.  
  7855.  
  7856.  
  7857.  
  7858.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7859.  
  7860.  
  7861.              SEE ALSO scdikmake.
  7862.  
  7863.               EXAMPLE #include <sc_base.h>
  7864.  
  7865.                       void main()
  7866.                       {
  7867.                         scdinit(20,0);
  7868.                         scdicreate("TOCDATE.IDX",SC_CKEY,"dtoc(date) +
  7869.                       time",16);
  7870.                         scdterm();
  7871.                       }
  7872.  
  7873.  
  7874.             scdiexpr__________________________________
  7875.  
  7876.                            USAGE     int scdiexpr(
  7877.                       int handle,
  7878.                       char *keyexpr );
  7879.  
  7880.             PROTOTYPE IN          sc_base.h
  7881.  
  7882.             DESCRIPTION           scdiexpr gets the index key expression
  7883.                       and returns it as an ASCIIZ string into a user
  7884.                       supplied buffer "keyexpr". The user must ensure
  7885.                       that the buffer is large enough (the key
  7886.                       expression length can be determined via a call to
  7887.                       scdiinfo) to hold the entire key expression.
  7888.  
  7889.                 NOTES A NULL byte will be appended to the end of the
  7890.                       expression string returned. If you are dynamically
  7891.                       allocating memory be sure to make the buffer large
  7892.                       enough.
  7893.  
  7894.              SEE ALSO scdiinfo.
  7895.  
  7896.               EXAMPLE #include <stdio.h>
  7897.                       #include <softc.h>
  7898.                       #include <sc_base.h>
  7899.  
  7900.                       void main()
  7901.                       {
  7902.                         int idx;
  7903.                         char buffer[512],*index="TOCNAME.IDX";
  7904.  
  7905.                         scdinit(20,0);
  7906.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  7907.                       {
  7908.                           scdiexpr(idx,buffer);
  7909.                           printf("key expression = %s",buffer);
  7910.                           scdiclose(idx);
  7911.                         }
  7912.  
  7913.  
  7914.  
  7915.             114                 SoftC Database Library
  7916.  
  7917.  
  7918.  
  7919.  
  7920.  
  7921.  
  7922.  
  7923.  
  7924.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  7925.  
  7926.  
  7927.                         scdterm();
  7928.                       }
  7929.  
  7930.  
  7931.             scdiflush_________________________________
  7932.  
  7933.                            USAGE     int scdiflush(
  7934.                       int handle );
  7935.  
  7936.  
  7937.  
  7938.  
  7939.  
  7940.  
  7941.  
  7942.  
  7943.  
  7944.  
  7945.  
  7946.  
  7947.  
  7948.  
  7949.  
  7950.  
  7951.  
  7952.  
  7953.  
  7954.  
  7955.  
  7956.  
  7957.  
  7958.  
  7959.  
  7960.  
  7961.  
  7962.  
  7963.  
  7964.  
  7965.  
  7966.  
  7967.  
  7968.  
  7969.  
  7970.  
  7971.  
  7972.  
  7973.  
  7974.  
  7975.  
  7976.  
  7977.  
  7978.  
  7979.  
  7980.  
  7981.             User's Reference Guide                 115
  7982.  
  7983.  
  7984.  
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  7991.  
  7992.  
  7993.             PROTOTYPE IN          sc_base.h
  7994.  
  7995.             DESCRIPTION           scdiflush will write the contents of
  7996.                       the page cache to disk.  A page cache will be used
  7997.                       only if the index file was opened with SC_BUFFER
  7998.                       in the command field.
  7999.  
  8000.              SEE ALSO scdiopenx
  8001.  
  8002.               EXAMPLE #include <string.h>
  8003.                       #include <softc.h>
  8004.                       #include <sc_base.h>
  8005.  
  8006.                       void main()
  8007.                       {
  8008.                         int dbf, idx;
  8009.                         char
  8010.                       *key,name[65],*index="TOCNAME.IDX",*data="TOC.DBF"
  8011.                       ;
  8012.                         long record;
  8013.  
  8014.                         scdinit(20,0);
  8015.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  8016.                       {
  8017.                           if
  8018.                       (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS) {
  8019.                             strcpy(name,"TOC.DBF");
  8020.                             scddfput(dbf,0,name);
  8021.                             scddrput(dbf,&record,SC_ADD);
  8022.                             scdikmake(dbf,idx,&key);
  8023.                             scdikadd(idx,key,record);
  8024.                             free(key);
  8025.                             scdiflush(idx);
  8026.                             scdiclose(idx);
  8027.                           }
  8028.                           scddclose(dbf);
  8029.                         }
  8030.                         scdterm();
  8031.                       }
  8032.  
  8033.  
  8034.             scdihget__________________________________
  8035.  
  8036.  
  8037.             USAGEint scdihget(
  8038.                       int handle );
  8039.  
  8040.             PROTOTYPE IN          sc_base.h
  8041.  
  8042.             DESCRIPTION           scdihget will read the index file
  8043.                       header. This function should be called after the
  8044.  
  8045.  
  8046.  
  8047.             116                 SoftC Database Library
  8048.  
  8049.  
  8050.  
  8051.  
  8052.  
  8053.  
  8054.  
  8055.  
  8056.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8057.  
  8058.  
  8059.                       data file has been locked in order to reload the
  8060.                       current file header information.
  8061.  
  8062.             RETURN VALUES         SC_SUCCESS   header read successfully
  8063.                       SC_RDFAIL   file read failure
  8064.                       SC_SKFAIL   file pointer reposition failed
  8065.                       SC_BADHNDL  invalid handle number
  8066.  
  8067.              SEE ALSO scddlock.
  8068.  
  8069.               EXAMPLE #include <stdio.h>
  8070.                       #include <softc.h>
  8071.                       #include <sc_base.h>
  8072.  
  8073.                       void main()
  8074.                       {
  8075.                         int dbf, idx;
  8076.  
  8077.                         scdinit(20,0);
  8078.                         if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) ==
  8079.                       SC_SUCCESS) {
  8080.                           scdiopenx(&idx,"TOCNAME.IDX",SC_SHARED);
  8081.                           scddlock(dbf);
  8082.                           scddhget(dbf);
  8083.                           scdihget(ntx);
  8084.                       /* append records - add keys - etc. */
  8085.                           scddunlock(dbf);
  8086.                           scddclose(dbf);
  8087.                         }
  8088.                         scdterm();
  8089.                       }
  8090.  
  8091.  
  8092.             scdiindex_________________________________
  8093.  
  8094.                            USAGE     int scdiindex(
  8095.                       int datafile,
  8096.                       char filename,
  8097.                       char keytype,
  8098.                       char keyexpr,
  8099.                       int keylen );
  8100.  
  8101.             PROTOTYPE IN          sc_base.h
  8102.  
  8103.             DESCRIPTION           scdiindex will create and build a
  8104.                       FoxBase/FoxPro index file. A blank file will be
  8105.                       created using "filename", "keytype", "keyexpr",
  8106.                       and "keylen".  The resultant file will be opened,
  8107.                       and the "datafile" will be read sequentially
  8108.                       building keys from each data record.  The index
  8109.  
  8110.  
  8111.  
  8112.  
  8113.             User's Reference Guide                 117
  8114.  
  8115.  
  8116.  
  8117.  
  8118.  
  8119.  
  8120.  
  8121.  
  8122.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8123.  
  8124.  
  8125.                       file will be closed at exit.  The "datafile" must
  8126.                       be open prior to the function call.
  8127.  
  8128.               EXAMPLE #include <softc.h>
  8129.                       #include <sc_base.h>
  8130.  
  8131.                       void main()
  8132.                       {
  8133.                         int dbf;
  8134.                         char *index="TOCNAME.IDX",*data="TOC.DBF";
  8135.  
  8136.                         scdinit(20,0);
  8137.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  8138.                       {
  8139.                           scdiindex(dbf,index,SC_CKEY,"NAME",64);
  8140.                           scddclose(dbf);
  8141.                         }
  8142.                         scdterm();
  8143.                       }
  8144.  
  8145.  
  8146.             scdiinfo__________________________________
  8147.  
  8148.                            USAGE     int scdiinfo(
  8149.                       int handle,
  8150.                       SC_IDXINFO *info );
  8151.  
  8152.             PROTOTYPE IN          sc_base.h
  8153.  
  8154.             DESCRIPTION           scdiinfo gets the filename of the
  8155.                       index file associated with "handle", the index key
  8156.                       type, the maximum index key length, and the length
  8157.                       of the index key expression and returns in "info":
  8158.  
  8159.                       typedef struct {
  8160.                         char fname[80];   /* file name */
  8161.                         char keytype;     /* key type (C,D,L,N) */
  8162.                         char keylen; /* key length */
  8163.                         char exprlen;     /* expression length */
  8164.                         SC_FLAGS flags;   /* misc. flags */
  8165.                       } SC_IDXINFO;
  8166.  
  8167.  
  8168.  
  8169.  
  8170.  
  8171.  
  8172.  
  8173.  
  8174.  
  8175.  
  8176.  
  8177.  
  8178.  
  8179.             118                 SoftC Database Library
  8180.  
  8181.  
  8182.  
  8183.  
  8184.  
  8185.  
  8186.  
  8187.  
  8188.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8189.  
  8190.  
  8191.                 NOTES If you are using the expression length to
  8192.                       dynamically allocate memory to hold the key
  8193.                       expression be sure to add one to the length before
  8194.                       allocation.
  8195.  
  8196.              SEE ALSO scdiopenx.
  8197.  
  8198.               EXAMPLE #include <stdio.h>
  8199.                       #include <softc.h>
  8200.                       #include <sc_base.h>
  8201.  
  8202.                       void main()
  8203.                       {
  8204.                         int idx;
  8205.                         SC_IDXINFO info;
  8206.                         char *index="TOCNAME.IDX";
  8207.  
  8208.                         scdinit(20,0);
  8209.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8210.                       {
  8211.                           scdiinfo(idx,&info);
  8212.                           printf("File name = %s\n",info.fname);
  8213.                           printf("Index key type = %c\n",info.keytype);
  8214.                           printf("Maximum key length =
  8215.                       %d\n",info.keylen);
  8216.                           printf("Key expression length =
  8217.                       %d\n",info.exprlen);
  8218.                           scdiclose(idx);
  8219.                         }
  8220.                         scdterm();
  8221.                       }
  8222.  
  8223.  
  8224.             scdikadd__________________________________
  8225.  
  8226.                            USAGE     int scdikadd(
  8227.                       int handle,
  8228.                       void *key,
  8229.                       long recno );
  8230.  
  8231.             PROTOTYPE IN          sc_base.h
  8232.  
  8233.             DESCRIPTION           scdikadd will add "key" to the index
  8234.                       file specified by "handle". "recno" is the data
  8235.                       record number to be associated with "key" (the
  8236.                       data record pointed to by "recno" must exist prior
  8237.                       to calling scdikadd).
  8238.  
  8239.                 NOTES When adding character keys it is necessary  to
  8240.                       pad  the key string to size with spaces (" "), the
  8241.                       function will not automatically do this for you.
  8242.  
  8243.  
  8244.  
  8245.             User's Reference Guide                 119
  8246.  
  8247.  
  8248.  
  8249.  
  8250.  
  8251.  
  8252.  
  8253.  
  8254.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8255.  
  8256.  
  8257.                       This differs from the dBASE and Clipper
  8258.                       corresponding functions.
  8259.  
  8260.              SEE ALSO scdikdate, scdikmake,scdiknum.
  8261.  
  8262.               EXAMPLE #include <softc.h>
  8263.                       #include <sc_base.h>
  8264.  
  8265.                       void main()
  8266.                       {
  8267.                         int dbf, idx;
  8268.                         long recno;
  8269.                         char key[8],*index="TOCLNGTH.IDX";
  8270.                         double length = 123.67L
  8271.  
  8272.                         scdinit(20,0);
  8273.                         if (scddopenx(&dbf, "TOC.DBF",0) == SC_SUCCESS)
  8274.                       {
  8275.                           if
  8276.                       (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS) {
  8277.                             scddfput(dbf,1,&length);
  8278.                             if (scddrput(dbf,&recno,SC_ADD) ==
  8279.                       SC_SUCCESS) {
  8280.                               scdiknum(key,length);
  8281.                               scdikadd(idx,key,recno);
  8282.                             }
  8283.                             scdiclose(idx);
  8284.                           }
  8285.                           scddclose(dbf)
  8286.                         }
  8287.                         scdterm();
  8288.                       }
  8289.  
  8290.  
  8291.             scdikbot__________________________________
  8292.  
  8293.                            USAGE     int scdikbot(
  8294.                       int handle,
  8295.                       void *key,
  8296.                       long *recno );
  8297.  
  8298.             PROTOTYPE IN          sc_base.h
  8299.  
  8300.             DESCRIPTION           scdikbot will set the current key
  8301.                       pointer to the last logical key in the index and
  8302.                       return the key value "key" and data record number
  8303.                       "recno" associated with the new current key.
  8304.  
  8305.                 NOTES The user must ensure that the buffer used to
  8306.                       return the key is large enough to hold the entire
  8307.  
  8308.  
  8309.  
  8310.  
  8311.             120                 SoftC Database Library
  8312.  
  8313.  
  8314.  
  8315.  
  8316.  
  8317.  
  8318.  
  8319.  
  8320.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8321.  
  8322.  
  8323.                       key. The maximum length of the key can be
  8324.                       determined via a call to scdiinfo.
  8325.  
  8326.                       Numeric keys are returned as doubles, and
  8327.                       character keys are returned as strings.
  8328.  
  8329.              SEE ALSO scdiinfo.
  8330.  
  8331.               EXAMPLE #include <stdio.h>
  8332.                       #include <softc.h>
  8333.                       #include <sc_base.h>
  8334.  
  8335.                       void main()
  8336.                       {
  8337.                         int idx;
  8338.                         char name[65],*index="TOCNAME.IDX";
  8339.                         long recno;
  8340.  
  8341.                         scdinit(20,0);
  8342.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8343.                       {
  8344.                           name[64] = 0;
  8345.                           scdikbot(idx,name,&recno);
  8346.                           printf("%s %ld\n",name,recno);
  8347.                           scdiclose(idx);
  8348.                         }
  8349.                         scdterm();
  8350.                       }
  8351.  
  8352.  
  8353.             scdikcur__________________________________
  8354.  
  8355.                            USAGE     int scdikcur(
  8356.                       int handle,
  8357.                       void *key,
  8358.                       long *recno );
  8359.  
  8360.             PROTOTYPE IN          sc_base.h
  8361.  
  8362.             DESCRIPTION           scdikcur will return the key value
  8363.                       "key" and data record number "recno" associated
  8364.                       with the current key in the index file.
  8365.  
  8366.                       The current key pointer must be set by a call to
  8367.                       either scdikfind, scdiktop, scdikbot, scdiknext,
  8368.                       or scdikprev before calling scdikcur.
  8369.  
  8370.                 NOTES The user must ensure that the buffer used to
  8371.                       return the key is large enough to hold the entire
  8372.  
  8373.  
  8374.  
  8375.  
  8376.  
  8377.             User's Reference Guide                 121
  8378.  
  8379.  
  8380.  
  8381.  
  8382.  
  8383.  
  8384.  
  8385.  
  8386.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8387.  
  8388.  
  8389.                       key. The maximum length of the key can be
  8390.                       determined via a call to scdiinfo.
  8391.  
  8392.              SEE ALSO scdiinfo, scdikfind, scdiktop, scdikbot,
  8393.                       scdiknext, scdikprev.
  8394.  
  8395.               EXAMPLE #include <stdio.h>
  8396.                       #include <softc.h>
  8397.                       #include <sc_base.h>
  8398.  
  8399.                       void main()
  8400.                       {
  8401.                         int idx;
  8402.                         char date[17],dat[17],*index="TOCDATE.IDX";
  8403.                         long recno, recn;
  8404.  
  8405.                         scdinit(20,0);
  8406.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8407.                       {
  8408.                           date[16] = 0;
  8409.                           dat[16] = 0;
  8410.                           scdiktop(idx,date,&recno);
  8411.                           scdikcur(idx,dat,&recn);
  8412.                           printf("%s %s %ld %ld\n",
  8413.                       date,dat,recno,recn);
  8414.                           scdiclose(idx);
  8415.                         }
  8416.                         scdterm();
  8417.                       }
  8418.  
  8419.  
  8420.             scdikdate_________________________________
  8421.  
  8422.                            USAGE     int scdikdate(
  8423.                       char *key,
  8424.                       char *string,
  8425.                       int format );
  8426.  
  8427.             PROTOTYPE IN          sc_base.h
  8428.  
  8429.             DESCRIPTION           scdikdate will translate an ASCIIZ
  8430.                       date string "string" of style "format" into a
  8431.                       valid FoxBase/FoxPro date key "key".
  8432.  
  8433.                       Date string styles:
  8434.  
  8435.  
  8436.  
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.             122                 SoftC Database Library
  8444.  
  8445.  
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8453.  
  8454.  
  8455.                       SC_GREGOR   mm/dd/yy
  8456.  
  8457.  
  8458.                       SC_GREGORL  mm/dd/yyyy
  8459.  
  8460.  
  8461.                       SC_JULIAN   yyyy/ddd
  8462.  
  8463.  
  8464.                       SC_YMD      yyyymmdd
  8465.  
  8466.  
  8467.                       SC_DMY      ddmmyy
  8468.  
  8469.              SEE ALSO scdikmake, scdiknum.
  8470.  
  8471.               EXAMPLE #include <softc.h>
  8472.                       #include <sc_base.h>
  8473.  
  8474.                       void main()
  8475.                       {
  8476.                         int dbf, idx;
  8477.                         long recno;
  8478.                         char key[8],*index="TOCFDATE.IDX";
  8479.  
  8480.                         scdinit(20,0);
  8481.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  8482.                           if
  8483.                       (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS) {
  8484.                             scddfput(dbf,2,"07/21/90);
  8485.                             .
  8486.                             .
  8487.                             .
  8488.                             if (scddrput(dbf,&recno,SC_ADD) ==
  8489.                       SC_SUCCESS) {
  8490.                               scdikdate(key, "07/21/90", SC_GREGOR);
  8491.                               scdikadd(idx,key,recno);
  8492.                             }
  8493.                             scdiclose(idx);
  8494.                           }
  8495.                           scddclose(dbf)
  8496.                         }
  8497.                         scdterm();
  8498.                       }
  8499.  
  8500.  
  8501.             scdikdel__________________________________
  8502.  
  8503.                            USAGE     int scdikdel(
  8504.                       char handle,
  8505.  
  8506.  
  8507.  
  8508.  
  8509.             User's Reference Guide                 123
  8510.  
  8511.  
  8512.  
  8513.  
  8514.  
  8515.  
  8516.  
  8517.  
  8518.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8519.  
  8520.  
  8521.                       void *key,
  8522.                       long recno );
  8523.  
  8524.             PROTOTYPE IN          sc_base.h
  8525.  
  8526.             DESCRIPTION           scdikdel will remove "key" from the
  8527.                       index file specified by "handle". "recno" is used
  8528.                       along with "key" to ensure that the proper key has
  8529.                       been removed from the index file.
  8530.  
  8531.                 NOTES When deleting character keys it is necessary  to
  8532.                       pad  the key string to size with spaces (" "), the
  8533.                       function will not automatically do this for you.
  8534.                       This differs from the corresponding dBASE and
  8535.                       Clipper functions.
  8536.  
  8537.              SEE ALSO scdikadd.
  8538.  
  8539.               EXAMPLE #include <string.h>
  8540.                       #include <sc_base.h>
  8541.  
  8542.                       void main()
  8543.                       {
  8544.                         int idx;
  8545.                         char name[65],*index="TOCNAME.IDX";
  8546.  
  8547.                         scdinit(20,0);
  8548.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8549.                       {
  8550.                           strcpy(name,"ABC.DEF");
  8551.                           scdikdel(idx,name,3L);
  8552.                           scdiclose(idx);
  8553.                         }
  8554.                         scdterm();
  8555.                       }
  8556.  
  8557.  
  8558.             scdikfind_________________________________
  8559.  
  8560.                            USAGE     int scdikfind(
  8561.                       int handle,
  8562.                       void *key,
  8563.                       long *recno,
  8564.                       int method );
  8565.  
  8566.             PROTOTYPE IN          sc_base.h
  8567.  
  8568.             DESCRIPTION           scdikfind supports two key search
  8569.                       methods (determined by "method"): SC_EXACT - find
  8570.                       an exact match with "key" and "recno", and
  8571.                       SC_FIRST - find the first logical occurrence of
  8572.  
  8573.  
  8574.  
  8575.             124                 SoftC Database Library
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8585.  
  8586.  
  8587.                       "key" in the index and return the associated
  8588.                       record number "recno" if found.
  8589.  
  8590.                       If a match cannot be found, the current key will
  8591.                       be the physical key which would immediately
  8592.                       precede "key". The current key's value and data
  8593.                       record number will be returned in "key" and
  8594.                       "recno".
  8595.  
  8596.                 NOTES The user must ensure that the buffer used to
  8597.                       return the key is large enough to hold the entire
  8598.                       key. The maximum length of the key can be
  8599.                       determined via a call to scdiinfo.
  8600.  
  8601.                       When searching using character keys it is
  8602.                       necessary  to  pad  the key string to size with
  8603.                       spaces (" "), the function will not automatically
  8604.                       do this for you. Because of the above restriction,
  8605.                       searching for partial keys is not currently
  8606.                       supported.
  8607.  
  8608.                       Numeric keys are returned as doubles, and
  8609.                       character keys are returned as strings.
  8610.  
  8611.  
  8612.  
  8613.  
  8614.  
  8615.  
  8616.  
  8617.  
  8618.  
  8619.  
  8620.  
  8621.  
  8622.  
  8623.  
  8624.  
  8625.  
  8626.  
  8627.  
  8628.  
  8629.  
  8630.  
  8631.  
  8632.  
  8633.  
  8634.  
  8635.  
  8636.  
  8637.  
  8638.  
  8639.  
  8640.  
  8641.             User's Reference Guide                 125
  8642.  
  8643.  
  8644.  
  8645.  
  8646.  
  8647.  
  8648.  
  8649.  
  8650.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8651.  
  8652.  
  8653.              SEE ALSO scdiinfo.
  8654.  
  8655.               EXAMPLE #include <stdio.h>
  8656.                       #include <string.h>
  8657.                       #include <softc.h>
  8658.                       #include <sc_base.h>
  8659.  
  8660.                       void main()
  8661.                       {
  8662.                         int idx;
  8663.                         char name[65],*index="TOCNAME.IDX";
  8664.                         long recno;
  8665.  
  8666.                         scdinit(20,0);
  8667.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8668.                       {
  8669.                           strcpy(name,"ABCDE");
  8670.                           recno = 7L;
  8671.                           if (scdikfind(idx, name, &recno, SC_FIRST) !=
  8672.                       SC_SUCCESS)
  8673.                             puts(scemsg());
  8674.                           scdiclose(idx);
  8675.                         }
  8676.                         scdterm();
  8677.                       }
  8678.  
  8679.  
  8680.             scdikmake_________________________________
  8681.  
  8682.                            USAGE     int scdikmake(
  8683.                       int datahandle,
  8684.                       int indexhandle,
  8685.                       void **key );
  8686.  
  8687.             PROTOTYPE IN          sc_base.h
  8688.  
  8689.             DESCRIPTION           scdikmake will build an index key
  8690.                       using the key expression of the index file
  8691.                       specified by "indexhandle" and the data found in
  8692.                       the record buffer of the data file "datahandle".
  8693.                       Memory space for the "key" will be allocated and
  8694.                       the address of this block will be returned.
  8695.  
  8696.                       The key expression can consist of either the data
  8697.                       field name or one of five FoxBase/FoxPro functions
  8698.                       or a combination thereof. Data field types of
  8699.                       date, numeric, character or logical are allowed.
  8700.                       FoxBase/FoxPro functions: dtoc, left, right, str,
  8701.                       and substr are currently supported by scdikmake.
  8702.  
  8703.  
  8704.  
  8705.  
  8706.  
  8707.             126                 SoftC Database Library
  8708.  
  8709.  
  8710.  
  8711.  
  8712.  
  8713.  
  8714.  
  8715.  
  8716.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8717.  
  8718.  
  8719.                       Following is a brief description of the five
  8720.                       expression functions:
  8721.  
  8722.                       dtoc will convert data from a date field to an
  8723.                       ASCIIZ string of the format mm/dd/yy. Syntax is:
  8724.  
  8725.                       dtoc(field_name)
  8726.  
  8727.                       left will return the left portion of a character
  8728.                       field as an ASCIIZ string. The number of
  8729.                       characters returned is specified after the field
  8730.                       name. Syntax is:
  8731.  
  8732.                       left(field_name,number)
  8733.  
  8734.                       right will return the right portion of a character
  8735.                       field as an ASCIIZ string. The number of
  8736.                       characters returned is specified after the field
  8737.                       name. This is a count from the right side of the
  8738.                       field. Syntax is:
  8739.  
  8740.                       right(field_name,number)
  8741.  
  8742.                       str will convert a numeric field to an ASCIIZ
  8743.                       string. The total length of the string and the
  8744.                       number of decimal places are optional parameters.
  8745.                       The default string length is 10 and the number of
  8746.                       decimal places is 0. Syntax is:
  8747.  
  8748.                       str(field_name,length,decimal_places)
  8749.  
  8750.                       substr will return the middle portion of a
  8751.                       character field. The starting offset into the
  8752.                       field is a required parameter. The number of
  8753.                       characters to be used is an optional parameter
  8754.                       whose default value is the remainder of the field.
  8755.                       Syntax is:
  8756.  
  8757.                       substr(field_name,start,count)
  8758.  
  8759.                       An example of a more complex key expression:
  8760.  
  8761.                       right(dtoc(date),2)+left(dtoc(date,2)
  8762.  
  8763.                       This expression would cause scdikmake to create an
  8764.                       index key string consisting of the year and month
  8765.                       ("yymm"). For example if date equals "2/13/89" the
  8766.                       resultant key would be "8902".
  8767.  
  8768.                 NOTES For key expressions consisting of only one data
  8769.                       field scdikmake is probably an overkill. You can
  8770.  
  8771.  
  8772.  
  8773.             User's Reference Guide                 127
  8774.  
  8775.  
  8776.  
  8777.  
  8778.  
  8779.  
  8780.  
  8781.  
  8782.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8783.  
  8784.  
  8785.                       easily generate these keys yourself. See scdikdate
  8786.                       for information on date string to key translation,
  8787.                       and scdiknum for numeric field to key translation.
  8788.                       scdikmake is a fairly large module and if not
  8789.                       needed probably should not be used. This function
  8790.                       is best used when the key expression is more
  8791.                       complex.
  8792.  
  8793.                       Memory is allocated for the generated key and it
  8794.                       is the responsibility of the caller to free this
  8795.                       memory when finished.
  8796.  
  8797.              SEE ALSO scdicreate, scdikdate, scdiknum.
  8798.  
  8799.               EXAMPLE #include <sc_base.h>
  8800.  
  8801.                       void main()
  8802.                       {
  8803.                         int idx, dbf;
  8804.                         char *key,name[65],*index="TOCNAME.IDX";
  8805.                         long recno;
  8806.  
  8807.                         scdinit(20,0);
  8808.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  8809.                           if
  8810.                       (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS) {
  8811.                             scddfput(dbf,0,name);
  8812.                             scddrput(dbf,&recno,SC_ADD);
  8813.                             scdikmake(dbf,idx,(void **) &key);
  8814.                             scdikadd(idx,key,recno);
  8815.                             free(key);    /* free memory allocated for
  8816.                       key */
  8817.                             scdiclose(idx);
  8818.                           }
  8819.                           scddclose(dbf);
  8820.                         }
  8821.                         scdterm();
  8822.                       }
  8823.  
  8824.  
  8825.             scdiknext_________________________________
  8826.  
  8827.                            USAGE     int scdiknext(
  8828.                       int handle,
  8829.                       void *key,
  8830.                       long *recno );
  8831.  
  8832.             PROTOTYPE IN          sc_base.h
  8833.  
  8834.             DESCRIPTION           scdiknext will increment the key
  8835.                       pointer and return the key value "key" and data
  8836.  
  8837.  
  8838.  
  8839.             128                 SoftC Database Library
  8840.  
  8841.  
  8842.  
  8843.  
  8844.  
  8845.  
  8846.  
  8847.  
  8848.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8849.  
  8850.  
  8851.                       record number "recno" associated with the new
  8852.                       current key.
  8853.  
  8854.                       If scdiknext is called immediately after opening
  8855.                       the index file the first logical key will be
  8856.                       returned.
  8857.  
  8858.                 NOTES The user must ensure that the buffer used to
  8859.                       return the key is large enough to hold the entire
  8860.                       key. The maximum length of the key can be
  8861.                       determined via a call to scdiinfo.
  8862.  
  8863.                       Numeric keys are returned as doubles, and
  8864.                       character keys are returned as strings.
  8865.  
  8866.              SEE ALSO scdiinfo.
  8867.  
  8868.               EXAMPLE /* Character Key Example */
  8869.                       #include <stdio.h>
  8870.                       #include <softc.h>
  8871.                       #include <sc_base.h>
  8872.  
  8873.                       void main()
  8874.                       {
  8875.                         int idx;
  8876.                         char name[65],*index="TOCNAME.IDX";
  8877.                         long recno;
  8878.  
  8879.                         scdinit(20,0);
  8880.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8881.                       {
  8882.                           scdiknext(idx,name,&recno);    /* return first
  8883.                       key */
  8884.                           printf("%s %ld\n",name,recno);
  8885.                           scdiclose(idx);
  8886.                         }
  8887.                         scdterm();
  8888.                       }
  8889.  
  8890.                       /*  Numeric Key Example */
  8891.                       #include <stdio.h>
  8892.                       #include <softc.h>
  8893.                       #include <sc_base.h>
  8894.  
  8895.                       void main()
  8896.                       {
  8897.                         int idx;
  8898.                         double numeric;
  8899.                         long recno;
  8900.                         char *index="TOCLNGTH.IDX";
  8901.  
  8902.  
  8903.  
  8904.  
  8905.             User's Reference Guide                 129
  8906.  
  8907.  
  8908.  
  8909.  
  8910.  
  8911.  
  8912.  
  8913.  
  8914.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  8915.  
  8916.  
  8917.  
  8918.                         scdinit(20,0);
  8919.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  8920.                       {
  8921.                           scdiknext(idx,&numeric,&recno);     /* return
  8922.                       first key */
  8923.                           printf("%lf %ld\n",numeric,recno);
  8924.                           scdiclose(idx);
  8925.                         }
  8926.                         scdterm();
  8927.                       }
  8928.  
  8929.  
  8930.             scdiknum__________________________________
  8931.  
  8932.                            USAGE     int scdiknum(
  8933.                       char *key,
  8934.                       double value );
  8935.  
  8936.             PROTOTYPE IN          sc_base.h
  8937.  
  8938.             DESCRIPTION           scdiknum will translate a 'C' double
  8939.                       "value" to a FoxBase/FoxPro numeric "key".
  8940.  
  8941.              SEE ALSO scdicreate, scdikdate, scdikmake.
  8942.  
  8943.               EXAMPLE #include <softc.h>
  8944.                       #include <sc_base.h>
  8945.  
  8946.                       void main()
  8947.                       {
  8948.                         int dbf, idx;
  8949.                         long recno;
  8950.                         char key[8],*index="TOCLNGTH.IDX";
  8951.                         double length = 123.67L
  8952.  
  8953.                         scdinit(20,0);
  8954.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  8955.                           if
  8956.                       (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS) {
  8957.                             scddfput(dbf,1,&length);
  8958.                             if (scddrput(dbf,&recno,SC_ADD) ==
  8959.                       SC_SUCCESS) {
  8960.                               scdiknum(key,length);
  8961.                               scdikadd(idx,key,recno);
  8962.                             }
  8963.                             scdiclose(idx);
  8964.                           }
  8965.                           scddclose(dbf)
  8966.                         }
  8967.  
  8968.  
  8969.  
  8970.  
  8971.             130                 SoftC Database Library
  8972.  
  8973.  
  8974.  
  8975.  
  8976.  
  8977.  
  8978.  
  8979.  
  8980.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  8981.  
  8982.  
  8983.                         scdterm();
  8984.                       }
  8985.  
  8986.  
  8987.             scdikprev_________________________________
  8988.  
  8989.                            USAGE     int scdikprev(
  8990.                       int handle,
  8991.                       void *key,
  8992.                       long *recno );
  8993.  
  8994.             PROTOTYPE IN          sc_base.h
  8995.  
  8996.             DESCRIPTION           scdikprev will decrement the key
  8997.                       pointer and return the key value "key" and data
  8998.                       record number "recno" associated with the new
  8999.                       current key.
  9000.  
  9001.                       If scdikprev is called immediately after opening
  9002.                       the index file the last logical key will be
  9003.                       returned.
  9004.  
  9005.                 NOTES The user must ensure that the buffer used to
  9006.                       return the key is large enough to hold the entire
  9007.                       key. The maximum length of the key can be
  9008.                       determined via a call to scdiinfo.
  9009.  
  9010.                       Numeric keys are returned as doubles, and
  9011.                       character keys are returned as strings.
  9012.  
  9013.              SEE ALSO scdiinfo.
  9014.  
  9015.               EXAMPLE /*  Character Key Example */
  9016.                       #include <stdio.h>
  9017.                       #include <softc.h>
  9018.                       #include <sc_base.h>
  9019.  
  9020.                       void main()
  9021.                       {
  9022.                         int idx;
  9023.                         char name[65];
  9024.                         long recno;
  9025.                         char *index="TOCNAME.IDX";
  9026.  
  9027.                         scdinit(20,0);
  9028.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  9029.                       {
  9030.                           scdikprev(idx, name, &recno);  /* get last key
  9031.                       */
  9032.                           printf("%s %ld\n",name,recno);
  9033.                           scdiclose(idx);
  9034.  
  9035.  
  9036.  
  9037.             User's Reference Guide                 131
  9038.  
  9039.  
  9040.  
  9041.  
  9042.  
  9043.  
  9044.  
  9045.  
  9046.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9047.  
  9048.  
  9049.                         }
  9050.                         scdterm();
  9051.                       }
  9052.  
  9053.                       /*  Numeric Key Example */
  9054.                       #include <stdio.h>
  9055.                       #include <softc.h>
  9056.                       #include <sc_base.h>
  9057.  
  9058.                       void main()
  9059.                       {
  9060.                         int idx;
  9061.                         double length;
  9062.                         long recno;
  9063.                         char *index="TOCLNGTH.IDX";
  9064.  
  9065.                         scdinit(20,0);
  9066.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  9067.                       {
  9068.                           scdikprev(idx,&length,&recno); /* get last key
  9069.                       */
  9070.                           printf("%lf %ld\n",length,recno);
  9071.                           scdiclose(idx);
  9072.                         }
  9073.                         scdterm();
  9074.                       }
  9075.  
  9076.  
  9077.             scdiktop__________________________________
  9078.  
  9079.                            USAGE     int scdiktop(
  9080.                       int handle,
  9081.                       void *key,
  9082.                       long *recno );
  9083.  
  9084.             PROTOTYPE IN          sc_base.h
  9085.  
  9086.             DESCRIPTION           scdiktop will set the current key
  9087.                       pointer to the first logical key in the index and
  9088.                       return the key value "key" and data record number
  9089.                       "recno" associated with the new current key.
  9090.  
  9091.                 NOTES The user must ensure that the buffer used to
  9092.                       return the key is large enough to hold the entire
  9093.                       key. The maximum length of the key can be
  9094.                       determined via a call to scdiinfo.
  9095.  
  9096.                       Numeric keys are returned as doubles, and
  9097.                       character keys are returned as strings.
  9098.  
  9099.  
  9100.  
  9101.  
  9102.  
  9103.             132                 SoftC Database Library
  9104.  
  9105.  
  9106.  
  9107.  
  9108.  
  9109.  
  9110.  
  9111.  
  9112.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9113.  
  9114.  
  9115.              SEE ALSO scdiinfo.
  9116.  
  9117.               EXAMPLE /*  Character Key Example */
  9118.                       #include <stdio.h>
  9119.                       #include <softc.h>
  9120.                       #include <sc_base.h>
  9121.  
  9122.                       void main()
  9123.                       {
  9124.                         int idx;
  9125.                         char name[65],*index="TOCNAME.IDX";
  9126.                         long recno;
  9127.  
  9128.                         scdinit(20,0);
  9129.                         if (scdiopenx(&idx,index,SC_BUFFER) ==
  9130.                       SC_SUCCESS) {
  9131.                           name[64] = 0;
  9132.                           scdiktop(idx,name,&recno);
  9133.                           printf("%s %ld\n",name,recno);
  9134.                           scdiclose(idx);
  9135.                         }
  9136.                         scdterm();
  9137.                       }
  9138.  
  9139.                       /*  Numeric Key Example */
  9140.                       #include <stdio.h>
  9141.                       #include <softc.h>
  9142.                       #include <sc_base.h>
  9143.  
  9144.                       void main()
  9145.                       {
  9146.                         int idx;
  9147.                         double length;
  9148.                         long recno;
  9149.                         char *index="TOCLNGTH.IDX";
  9150.  
  9151.                         scdinit(20,0);
  9152.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  9153.                       {
  9154.                           scdiktop(idx,&length,&recno);
  9155.                           printf("%lf %ld\n",length,recno);
  9156.                           scdiclose(idx);
  9157.                         }
  9158.                         scdterm();
  9159.                       }
  9160.  
  9161.  
  9162.  
  9163.  
  9164.  
  9165.  
  9166.  
  9167.  
  9168.  
  9169.             User's Reference Guide                 133
  9170.  
  9171.  
  9172.  
  9173.  
  9174.  
  9175.  
  9176.  
  9177.  
  9178.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9179.  
  9180.  
  9181.             scdinit___________________________________
  9182.  
  9183.                            USAGE     int scdinit(
  9184.                       int files,
  9185.                       int command );
  9186.  
  9187.             PROTOTYPE IN          sc_base.h
  9188.  
  9189.             DESCRIPTION           scdinit should be called once and only
  9190.                       once at the beginning of the program. The maximum
  9191.                       number of simultaneously open "files" is passed.
  9192.                       This function sets up the SoftC Database Library
  9193.                       file manager environment for processing. Memory
  9194.                       will be allocated for a variety of control
  9195.                       structures used internally by the file manager.
  9196.  
  9197.                       If the "command" switch SC_USEXHNDL is passed,
  9198.                       more than 20 (the default) open files per program
  9199.                       is allowed. A larger handle table will be
  9200.                       allocated and the DOS PSP will be changed.
  9201.  
  9202.                 NOTES The first five file handles per program are taken
  9203.                       up with printer, console, auxiliary port, etc.
  9204.                       leaving only 15 file handles available per program
  9205.                       in the default state.  This implies that files
  9206.                       cannot be less than five.
  9207.  
  9208.                       Neither Microsoft C 5.x/6.0 nor Turbo C 2.0
  9209.                       support more than 20 open files. In other words if
  9210.                       you want to open more than 20 files you have to go
  9211.                       directly to DOS.
  9212.  
  9213.              SEE ALSO scdterm.
  9214.  
  9215.               EXAMPLE #include <sc_base.h>
  9216.  
  9217.                       void main()
  9218.                       {
  9219.                         scdinit(20,0);
  9220.                         scdterm();
  9221.                       }
  9222.  
  9223.  
  9224.             scdiopenx_________________________________
  9225.  
  9226.                            USAGE     int scdiopenx(
  9227.                       int *handle,
  9228.                       char *filename,
  9229.                       int command );
  9230.  
  9231.  
  9232.  
  9233.  
  9234.  
  9235.             134                 SoftC Database Library
  9236.  
  9237.  
  9238.  
  9239.  
  9240.  
  9241.  
  9242.  
  9243.  
  9244.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9245.  
  9246.  
  9247.             PROTOTYPE IN          sc_base.h
  9248.  
  9249.             DESCRIPTION           scdiopenx opens a FoxBase/FoxPro
  9250.                       index file. Memory will be allocated for a file
  9251.                       packet, I/O buffers, and other miscellaneous
  9252.                       structures for use internally by the SoftC
  9253.                       Database Library file manager. The index file will
  9254.                       be tested as much as possible to insure that it is
  9255.                       a legitimate FoxBase/FoxPro index file.
  9256.  
  9257.                       A block of memory large enough to hold at least 4
  9258.                       pages (2048 bytes) will be allocated during the
  9259.                       open. Four pages is the minimum number of buffers
  9260.                       required to add or delete index keys.
  9261.  
  9262.                       The file will be opened under control of the
  9263.                       "command" parameter.  Using SC_RDWR opens the file
  9264.                       for both read and write access.  SC_RDONLY
  9265.                       overrides SC_RDWR and causes the file to be opened
  9266.                       for read access only.  Any attempt to write to a
  9267.                       read only file will result in an error
  9268.                       (SC_READOLY).
  9269.  
  9270.                       Using SC_BUFFER opens the file with I/O caching
  9271.                       enabled.  Memory for up  to 10 pages will be
  9272.                       allocated during the open.  Caching of page I/O
  9273.                       greatly increases the speed of file access.
  9274.                       Typically this mode is used with single user
  9275.                       files.  SC_FLUSH overrides SC_BUFFER and causes
  9276.                       the file to be opened with no caching.  This mode
  9277.                       is generally used with file sharing, although it
  9278.                       is not required.
  9279.  
  9280.                       Using SC_EXCLUDE opens the file for exclusive use
  9281.                       of this station (single user).  SC_SHARED
  9282.                       overrides SC_EXCLUDE and opens the file in multi-
  9283.                       user mode.  This mode is used when a LAN file is
  9284.                       to be shared with other stations.
  9285.  
  9286.                 NOTES The index expression will be translated to upper
  9287.                       case after being read from the index file.
  9288.  
  9289.               EXAMPLE #include <softc.h>
  9290.                       #include <sc_base.h>
  9291.  
  9292.                       void main()
  9293.                       {
  9294.                         int idx;
  9295.                         char *index="UNKNOWN.IDX";
  9296.  
  9297.                         scdinit(20,0);
  9298.  
  9299.  
  9300.  
  9301.             User's Reference Guide                 135
  9302.  
  9303.  
  9304.  
  9305.  
  9306.  
  9307.  
  9308.  
  9309.  
  9310.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9311.  
  9312.  
  9313.                         if (scdiopenx(&idx,index,SC_BUFFER)==SC_SUCCESS)
  9314.                       {
  9315.                           scdiclose(idx);
  9316.                         }
  9317.                         scdterm();
  9318.                       }
  9319.  
  9320.  
  9321.             scdnbfrsz_________________________________
  9322.  
  9323.                            USAGE     int scdnbfrsz(
  9324.                       int handle,
  9325.                       int *numpgs,
  9326.                       int command );
  9327.  
  9328.             PROTOTYPE IN          sc_base.h
  9329.  
  9330.             DESCRIPTION           scdnbfrsz will either get (SC_GETSZ)
  9331.                       or set (SC_SETSZ) the maximum number of index
  9332.                       pages the library file manager can keep in memory
  9333.                       and returns it via "numpgs".  This is under
  9334.                       control of "command".
  9335.  
  9336.               EXAMPLE /* Get Size */
  9337.                       #include <stdio.h>
  9338.                       #include <softc.h>
  9339.                       #include <sc_base.h>
  9340.  
  9341.                       void main()
  9342.                       {
  9343.                         int ndx, numpgs;
  9344.                         char *index="TOCNAME.NDX";
  9345.  
  9346.                         scdinit(20,0);
  9347.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9348.                       {
  9349.                           scdnbfrsz(ndx,&numpgs,SC_GETSZ) == SC_SUCCESS)
  9350.                           printf("Maximum number of pages =
  9351.                       %d\n",numpgs);
  9352.                           scdnclose(ndx);
  9353.                         }
  9354.                         scdterm();
  9355.                       }
  9356.  
  9357.                       /* Set Size */
  9358.                       #include <stdio.h>
  9359.                       #include <softc.h>
  9360.                       #include <sc_base.h>
  9361.  
  9362.                       void main()
  9363.  
  9364.  
  9365.  
  9366.  
  9367.             136                 SoftC Database Library
  9368.  
  9369.  
  9370.  
  9371.  
  9372.  
  9373.  
  9374.  
  9375.  
  9376.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9377.  
  9378.  
  9379.                       {
  9380.                         int ndx, numpgs = 5;
  9381.                         char *index="TOCNAME.NDX";
  9382.  
  9383.                         scdinit(20,0);
  9384.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9385.                       {
  9386.                           scdnbfrsz(ndx,&numpgs,SC_SETSZ);
  9387.                           printf("New max = %d\n",numpgs);
  9388.                           scdnclose(ndx);
  9389.                         }
  9390.                         scdterm();
  9391.                       }
  9392.  
  9393.  
  9394.             scdnclose_________________________________
  9395.  
  9396.                            USAGE     int scdnclose(
  9397.                       int handle );
  9398.  
  9399.             PROTOTYPE IN          sc_base.h
  9400.  
  9401.             DESCRIPTION           scdnclose closes an index file and
  9402.                       frees all allocated memory associated with index
  9403.                       file.
  9404.  
  9405.               EXAMPLE #include <softc.h>
  9406.                       #include <sc_base.h>
  9407.  
  9408.                       void main()
  9409.                       {
  9410.                         int ndx;
  9411.                         char *index="TOCNAME.NDX";
  9412.  
  9413.                         scdinit(20,0);
  9414.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9415.                           scdnclose(ndx);
  9416.                         scdterm();
  9417.                       }
  9418.  
  9419.  
  9420.             scdncreate________________________________
  9421.  
  9422.                            USAGE     int scdncreate(
  9423.                       char *filename,
  9424.                       char keytype,
  9425.                       char *keyexpr,
  9426.                       int keylen );
  9427.  
  9428.  
  9429.  
  9430.  
  9431.  
  9432.  
  9433.             User's Reference Guide                 137
  9434.  
  9435.  
  9436.  
  9437.  
  9438.  
  9439.  
  9440.  
  9441.  
  9442.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9443.  
  9444.  
  9445.             PROTOTYPE IN          sc_base.h
  9446.  
  9447.             DESCRIPTION           scdncreate creates an index file.
  9448.                       "keyexpr" will be translated to all upper case
  9449.                       when the index file is created.
  9450.  
  9451.                       If "keytype" is SC_CKEY, then "keyexpr" must be an
  9452.                       ASCIIZ string consisting of one or more field
  9453.                       names from the data record. All fields included in
  9454.                       the expression must be of type 'c' or be
  9455.                       translated into type 'c'. No check is made to
  9456.                       verify this. "keyexpr" cannot be longer that 220
  9457.                       characters. "keylen" cannot exceed 100.
  9458.  
  9459.                       If "keytype" is SC_DKEY or SC_NKEY, then "keyexpr"
  9460.                       should consist of only one data field. "keylen"
  9461.                       will automatically be set to 8 (numeric and date
  9462.                       keys are stored as doubles). For both date and
  9463.                       numeric keys "keytype" will be forced to 'n'.
  9464.  
  9465.                       When unique keys are required, OR SC_UNIQUE with
  9466.                       "keytype".
  9467.  
  9468.                 NOTES scdncreate will create a new index file even if
  9469.                       one had already existed.
  9470.  
  9471.                       "keyexpr" is used by dBASE. "keyexpr" is NOT
  9472.                       checked for validity during the file creation
  9473.                       process. Currently only the scdnkmake function
  9474.                       uses "keyexpr".
  9475.  
  9476.              SEE ALSO scdnkmake.
  9477.  
  9478.               EXAMPLE #include <sc_base.h>
  9479.  
  9480.                       void main()
  9481.                       {
  9482.                         scdinit(20,0);
  9483.                         scdncreate("TOCDATE.NDX",'c',"dtoc(date) +
  9484.                       time",16);
  9485.                         scdterm();
  9486.                       }
  9487.  
  9488.  
  9489.             scdnexpr__________________________________
  9490.  
  9491.                            USAGE     int scdnexpr(
  9492.                       int handle,
  9493.                       char *keyexpr );
  9494.  
  9495.  
  9496.  
  9497.  
  9498.  
  9499.             138                 SoftC Database Library
  9500.  
  9501.  
  9502.  
  9503.  
  9504.  
  9505.  
  9506.  
  9507.  
  9508.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9509.  
  9510.  
  9511.             PROTOTYPE IN          sc_base.h
  9512.  
  9513.             DESCRIPTION           scdnexpr gets the index key expression
  9514.                       and returns it as an ASCIIZ string into a user
  9515.                       supplied buffer "keyexpr". The user must ensure
  9516.                       that the buffer is large enough (the key
  9517.                       expression length can be determined via a call to
  9518.                       scdninfo) to hold the entire key expression.
  9519.  
  9520.                 NOTES A NULL byte will be appended to the end of the
  9521.                       expression string returned. If you are dynamically
  9522.                       allocating memory be sure to make the buffer large
  9523.                       enough.
  9524.  
  9525.              SEE ALSO scdninfo.
  9526.  
  9527.               EXAMPLE #include <stdio.h>
  9528.                       #include <softc.h>
  9529.                       #include <sc_base.h>
  9530.  
  9531.                       void main()
  9532.                       {
  9533.                         int ndx;
  9534.                         char buffer[512],*index="TOCNAME.NDX";
  9535.  
  9536.                         scdinit(20,0);
  9537.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9538.                       {
  9539.                           scdnexpr(ndx,buffer);
  9540.                           printf("key expression = %s",buffer);
  9541.                           scdnclose(ndx);
  9542.                         }
  9543.                         scdterm();
  9544.                       }
  9545.  
  9546.  
  9547.             scdnflush_________________________________
  9548.  
  9549.                            USAGE     int scdnflush(
  9550.                       int handle );
  9551.  
  9552.  
  9553.  
  9554.  
  9555.  
  9556.  
  9557.  
  9558.  
  9559.  
  9560.  
  9561.  
  9562.  
  9563.  
  9564.  
  9565.             User's Reference Guide                 139
  9566.  
  9567.  
  9568.  
  9569.  
  9570.  
  9571.  
  9572.  
  9573.  
  9574.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9575.  
  9576.  
  9577.             PROTOTYPE IN          sc_base.h
  9578.  
  9579.             DESCRIPTION           scdnflush will write the contents of
  9580.                       the I/O cache to disk.  An I/O cache will be used
  9581.                       only if the index file was opened with SC_BUFFER
  9582.                       in the command field.
  9583.  
  9584.              SEE ALSO scdnopenx
  9585.  
  9586.               EXAMPLE #include <string.h>
  9587.                       #include <softc.h>
  9588.                       #include <sc_base.h>
  9589.  
  9590.                       void main()
  9591.                       {
  9592.                         int dbf, ndx;
  9593.                         char *key,*index="TOCNAME.NDX",*data="TOC.DBF";
  9594.                         long record;
  9595.  
  9596.                         scdinit(20,0);
  9597.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  9598.                       {
  9599.                           if
  9600.                       (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS) {
  9601.                             scddfput(dbf,0,"TOC.DBF");
  9602.                             scddrput(dbf,&record,SC_ADD);
  9603.                             scdnkmake(dbf,ndx,&key);
  9604.                             scdnkadd(ndx,key,record);
  9605.                             free(key);
  9606.                             scdnflush(ndx);
  9607.                             scdnclose(ndx);
  9608.                           }
  9609.                           scddclose(dbf);
  9610.                         }
  9611.                         scdterm();
  9612.                       }
  9613.  
  9614.  
  9615.             scdnhget__________________________________
  9616.  
  9617.  
  9618.             USAGEint scdnhget(
  9619.                       int handle );
  9620.  
  9621.             PROTOTYPE IN          sc_base.h
  9622.  
  9623.             DESCRIPTION           scdnhget will read the index file
  9624.                       header. This function should be called after the
  9625.                       data file has been locked in order to reload the
  9626.                       current file header information.
  9627.  
  9628.  
  9629.  
  9630.  
  9631.             140                 SoftC Database Library
  9632.  
  9633.  
  9634.  
  9635.  
  9636.  
  9637.  
  9638.  
  9639.  
  9640.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9641.  
  9642.  
  9643.             RETURN VALUES         SC_SUCCESS   header read successfully
  9644.                       SC_RDFAIL   file read failure
  9645.                       SC_SKFAIL   file pointer reposition failed
  9646.                       SC_BADHNDL  invalid handle number
  9647.  
  9648.              SEE ALSO scddlock.
  9649.  
  9650.               EXAMPLE #include <stdio.h>
  9651.                       #include <softc.h>
  9652.                       #include <sc_base.h>
  9653.  
  9654.                       void main()
  9655.                       {
  9656.                         int dbf, ndx;
  9657.  
  9658.                         scdinit(20,0);
  9659.                         if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) ==
  9660.                       SC_SUCCESS) {
  9661.                           scdnopenx(&ndx,"TOCNAME.NDX",SC_SHARED);
  9662.                           scddlock(dbf);
  9663.                           scddhget(dbf);
  9664.                           scdnhget(ntx);
  9665.                       /* append records - add keys - etc. */
  9666.                           scddunlock(dbf);
  9667.                           scddclose(dbf);
  9668.                         }
  9669.                         scdterm();
  9670.                       }
  9671.  
  9672.  
  9673.             scdnindex_________________________________
  9674.  
  9675.                            USAGE     int scdnindex(
  9676.                       int datafile,
  9677.                       char filename,
  9678.                       char keytype,
  9679.                       char keyexpr,
  9680.                       char keylen );
  9681.  
  9682.  
  9683.  
  9684.  
  9685.  
  9686.  
  9687.  
  9688.  
  9689.  
  9690.  
  9691.  
  9692.  
  9693.  
  9694.  
  9695.  
  9696.  
  9697.             User's Reference Guide                 141
  9698.  
  9699.  
  9700.  
  9701.  
  9702.  
  9703.  
  9704.  
  9705.  
  9706.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9707.  
  9708.  
  9709.             PROTOTYPE IN          sc_base.h
  9710.  
  9711.             DESCRIPTION           scdnindex will create and build an
  9712.                       dBASE index file. A blank file will be created
  9713.                       using "filename", "keytype", "keyexpr", and
  9714.                       "keylen".  The resultant file will be opened, and
  9715.                       the "datafile" will be read sequentially building
  9716.                       keys from each data record.  The index file will
  9717.                       be closed at exit.  The "datafile" must be open
  9718.                       prior to the function call.
  9719.  
  9720.               EXAMPLE #include <sc_base.h>
  9721.  
  9722.                       void main()
  9723.                       {
  9724.                         int dbf;
  9725.                         char *data="TOC.DBF";
  9726.  
  9727.                         scdinit(20,0);
  9728.                         if (scddopenx(&dbf,data,SC_BUFFER)==SC_SUCCESS)
  9729.                       {
  9730.                           scdnindex(dbf, "TOCNAME.NDX", SC_CKEY, "NAME",
  9731.                       64);
  9732.                           scddclose(dbf);
  9733.                         }
  9734.                         scdterm();
  9735.                       }
  9736.  
  9737.  
  9738.             scdninfo__________________________________
  9739.  
  9740.                            USAGE     int scdninfo(
  9741.                       int handle,
  9742.                       SC_NDXINFO *info );
  9743.  
  9744.             PROTOTYPE IN          sc_base.h
  9745.  
  9746.             DESCRIPTION           scdninfo gets the filename of the
  9747.                       index file associated with "handle", the index key
  9748.                       type, the maximum index key length, and the length
  9749.                       of the index key expression.
  9750.  
  9751.                       typedef struct {
  9752.                         char fname[80];   /* file name */
  9753.                         char keytype;     /* key type (C or N) */
  9754.                         char keylen; /* key length */
  9755.                         char exprlen;     /* expression length */
  9756.                         SC_FLAGS flags;   /* misc. flags */
  9757.                       } SC_NDXINFO;
  9758.  
  9759.  
  9760.  
  9761.  
  9762.  
  9763.             142                 SoftC Database Library
  9764.  
  9765.  
  9766.  
  9767.  
  9768.  
  9769.  
  9770.  
  9771.  
  9772.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9773.  
  9774.  
  9775.                 NOTES If you are using the expression length to
  9776.                       dynamically allocate memory to hold the key
  9777.                       expression be sure to add one to the length before
  9778.                       allocation.
  9779.  
  9780.              SEE ALSO scdnopenx.
  9781.  
  9782.               EXAMPLE #include <stdio.h>
  9783.                       #include <softc.h>
  9784.                       #include <sc_base.h>
  9785.  
  9786.                       void main()
  9787.                       {
  9788.                         int ndx;
  9789.                         SC_NDXINFO info;
  9790.                         char *index="TOCNAME.NDX";
  9791.  
  9792.                         scdinit(20,0);
  9793.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9794.                       {
  9795.                           scdninfo(ndx,&info);
  9796.                           printf("File name = %s\n",info.fname);
  9797.                           printf("Index key type = %c\n",info.keytype);
  9798.                           printf("Maximum key length =
  9799.                       %d\n",info.keylen);
  9800.                           printf("Key expression length =
  9801.                       %d\n",info.exprlen);
  9802.                           scdnclose(ndx);
  9803.                         }
  9804.                         scdterm();
  9805.                       }
  9806.  
  9807.  
  9808.             scdnkadd__________________________________
  9809.  
  9810.                            USAGE     int scdnkadd(
  9811.                       int handle,
  9812.                       void *key,
  9813.                       long recno );
  9814.  
  9815.  
  9816.  
  9817.  
  9818.  
  9819.  
  9820.  
  9821.  
  9822.  
  9823.  
  9824.  
  9825.  
  9826.  
  9827.  
  9828.  
  9829.             User's Reference Guide                 143
  9830.  
  9831.  
  9832.  
  9833.  
  9834.  
  9835.  
  9836.  
  9837.  
  9838.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9839.  
  9840.  
  9841.             PROTOTYPE IN          sc_base.h
  9842.  
  9843.             DESCRIPTION           scdnkadd will add "key" to the index
  9844.                       file specified by "handle". "recno" is the data
  9845.                       record number to be associated with "key" (the
  9846.                       data record pointed to by "recno" must exist prior
  9847.                       to calling scdnkadd).
  9848.  
  9849.                 NOTES When adding character keys it is not necessary  to
  9850.                       pad  the key string to size with spaces (" "), the
  9851.                       function will automatically do this for you.
  9852.  
  9853.              SEE ALSO scdnkdate, scdnkmake.
  9854.  
  9855.               EXAMPLE #include <string.h>
  9856.                       #include <softc.h>
  9857.                       #include <sc_base.h>
  9858.  
  9859.                       void main()
  9860.                       {
  9861.                         int dbf, ndx;
  9862.                         char name[65],*index="TOCNAME.NDX";
  9863.                         long recno;
  9864.  
  9865.                         scdinit(20,0);
  9866.                         if (scddopenx(&dbf,"TOC.DBF",0)==SC_SUCCESS) {
  9867.                           if
  9868.                       (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS) {
  9869.                             strcpy(name,"XYZ.BAK");
  9870.                             scddfput(dbf,0,name);
  9871.                             if (scddrput(dbf, &recno, SC_ADD) ==
  9872.                       SC_SUCCESS)
  9873.                               scdnkadd(ndx,name,recno);
  9874.                             scdnclose(ndx);
  9875.                           }
  9876.                           scddclose(dbf)
  9877.                         }
  9878.                         scdterm();
  9879.                       }
  9880.  
  9881.  
  9882.             scdnkbot__________________________________
  9883.  
  9884.                            USAGE     int scdnkbot(
  9885.                       int handle,
  9886.                       void *key,
  9887.                       long *recno );
  9888.  
  9889.  
  9890.  
  9891.  
  9892.  
  9893.  
  9894.  
  9895.             144                 SoftC Database Library
  9896.  
  9897.  
  9898.  
  9899.  
  9900.  
  9901.  
  9902.  
  9903.  
  9904.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  9905.  
  9906.  
  9907.             PROTOTYPE IN          sc_base.h
  9908.  
  9909.             DESCRIPTION           scdnkbot will set the current key
  9910.                       pointer to the last logical key in the index and
  9911.                       return the key value "key" and data record number
  9912.                       "recno" associated with the new current key.
  9913.  
  9914.                 NOTES The user must ensure that the buffer used to
  9915.                       return the key is large enough to hold the entire
  9916.                       key. The maximum length of the key can be
  9917.                       determined via a call to scdninfo.
  9918.  
  9919.                       Numeric keys are returned as doubles, and
  9920.                       character keys are returned as strings.
  9921.  
  9922.              SEE ALSO scdninfo.
  9923.  
  9924.               EXAMPLE /*  Character Key Example */
  9925.                       #include <stdio.h>
  9926.                       #include <softc.h>
  9927.                       #include <sc_base.h>
  9928.  
  9929.                       void main()
  9930.                       {
  9931.                         int ndx;
  9932.                         char name[65],*index="TOCNAME.NDX";
  9933.                         long recno;
  9934.  
  9935.                         scdinit(20,0);
  9936.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9937.                       {
  9938.                           name[64] = 0;
  9939.                           scdnkbot(ndx,name,&recno);
  9940.                           printf("%s %ld\n",name,recno);
  9941.                           scdnclose(ndx);
  9942.                         }
  9943.                         scdterm();
  9944.                       }
  9945.  
  9946.                       /*  Numeric Key Example  */
  9947.                       #include <stdio.h>
  9948.                       #include <softc.h>
  9949.                       #include <sc_base.h>
  9950.  
  9951.                       void main()
  9952.                       {
  9953.                         int ndx;
  9954.                         double length;
  9955.                         long recno;
  9956.                         char *index="TOCLNGTH.NDX";
  9957.  
  9958.  
  9959.  
  9960.  
  9961.             User's Reference Guide                 145
  9962.  
  9963.  
  9964.  
  9965.  
  9966.  
  9967.  
  9968.  
  9969.  
  9970.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  9971.  
  9972.  
  9973.                         scdinit(20,0);
  9974.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  9975.                       {
  9976.                           scdnkbot(ndx,&length,&recno);
  9977.                           printf("%lf %ld\n",length,recno);
  9978.                           scdnclose(ndx);
  9979.                         }
  9980.                         scdterm();
  9981.                       }
  9982.  
  9983.  
  9984.             scdnkcur__________________________________
  9985.  
  9986.                            USAGE     int scdnkcur(
  9987.                       int handle,
  9988.                       void *key,
  9989.                       long *recno );
  9990.  
  9991.             PROTOTYPE IN          sc_base.h
  9992.  
  9993.             DESCRIPTION           scdnkcur will return the key value
  9994.                       "key" and data record number "recno" associated
  9995.                       with the current key in the index file.
  9996.  
  9997.                       The current key pointer must be set by a call to
  9998.                       either scdnkfind, scdnktop, scdnkbot, scdnknext,
  9999.                       or scdnkprev before calling scdnkcur.
  10000.  
  10001.                 NOTES The user must ensure that the buffer used to
  10002.                       return the key is large enough to hold the entire
  10003.                       key. The maximum length of the key can be
  10004.                       determined via a call to scdninfo.
  10005.  
  10006.              SEE ALSO scdninfo, scdnkfind, scdnktop, scdnkbot,
  10007.                       scdnknext, scdnkprev.
  10008.  
  10009.               EXAMPLE #include <stdio.h>
  10010.                       #include <softc.h>
  10011.                       #include <sc_base.h>
  10012.  
  10013.                       void main()
  10014.                       {
  10015.                         int ndx;
  10016.                         char name[65],nam[65],*index="TOCNAME.NDX";
  10017.                         long recno, recn;
  10018.  
  10019.                         scdinit(20,0);
  10020.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  10021.                       {
  10022.                           name[64] = 0;
  10023.  
  10024.  
  10025.  
  10026.  
  10027.             146                 SoftC Database Library
  10028.  
  10029.  
  10030.  
  10031.  
  10032.  
  10033.  
  10034.  
  10035.  
  10036.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10037.  
  10038.  
  10039.                           nam[64] = 0;
  10040.                           scdnktop(ndx,name,&recno);
  10041.                           scdnkcur(ndx,nam,&recn);
  10042.                           printf("%s %s %ld %ld\n",name,nam,recno,recn);
  10043.                           scdnclose(ndx);
  10044.                         }
  10045.                         scdterm();
  10046.                       }
  10047.  
  10048.  
  10049.             scdnkdate_________________________________
  10050.  
  10051.                            USAGE     int scdnkdate(
  10052.                       double *key,
  10053.                       char *string,
  10054.                       int format );
  10055.  
  10056.             PROTOTYPE IN          sc_base.h
  10057.  
  10058.             DESCRIPTION           scdnkdate will translate an ASCIIZ
  10059.                       date string "string" of style "format" into a
  10060.                       valid dBASE date key "key".
  10061.  
  10062.                       Date string styles:
  10063.  
  10064.  
  10065.                       SC_GREGOR   mm/dd/yy
  10066.  
  10067.  
  10068.                       SC_GREGORL  mm/dd/yyyy
  10069.  
  10070.  
  10071.                       SC_JULIAN   yyyy/ddd
  10072.  
  10073.  
  10074.                       SC_YMD      yyyymmdd
  10075.  
  10076.  
  10077.                       SC_DMY      ddmmyy
  10078.  
  10079.               EXAMPLE #include <stdio.h>
  10080.                       #include <softc.h>
  10081.                       #include <sc_base.h>
  10082.  
  10083.                       void main()
  10084.                       {
  10085.                         double key;
  10086.  
  10087.                         scdinit(20,0);
  10088.                         scdnkdate(&key,"19890801");
  10089.  
  10090.  
  10091.  
  10092.  
  10093.             User's Reference Guide                 147
  10094.  
  10095.  
  10096.  
  10097.  
  10098.  
  10099.  
  10100.  
  10101.  
  10102.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10103.  
  10104.  
  10105.                         printf("%lf",key);
  10106.                         scdterm();
  10107.                       }
  10108.  
  10109.  
  10110.             scdnkdel__________________________________
  10111.  
  10112.                            USAGE     int scdnkdel(
  10113.                       int handle,
  10114.                       void *key,
  10115.                       long recno );
  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.             148                 SoftC Database Library
  10160.  
  10161.  
  10162.  
  10163.  
  10164.  
  10165.  
  10166.  
  10167.  
  10168.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10169.  
  10170.  
  10171.             PROTOTYPE IN          sc_base.h
  10172.  
  10173.             DESCRIPTION           scdnkdel will remove "key" from the
  10174.                       index file specified by "handle". "recno" is used
  10175.                       along with "key" to ensure that the proper key has
  10176.                       been removed from the index file.
  10177.  
  10178.                 NOTES When deleting character keys it is not necessary
  10179.                       to  pad  the key string to size with spaces (" "),
  10180.                       the function will automatically do this for you.
  10181.  
  10182.              SEE ALSO scdnkadd.
  10183.  
  10184.               EXAMPLE #include <string.h>
  10185.                       #include <softc.h>
  10186.                       #include <sc_base.h>
  10187.  
  10188.                       void main()
  10189.                       {
  10190.                         int ndx;
  10191.                         char date[16],*index="TOCDATE.NDX";
  10192.                         long recno;
  10193.  
  10194.                         scdinit(20,0);
  10195.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  10196.                       {
  10197.                           strcpy(date,"12/02/8809:33:01");
  10198.                           recno = 71L;
  10199.                           scdnkdel(ndx,date,recno);
  10200.                           scdnclose(ndx);
  10201.                         }
  10202.                         scdterm();
  10203.                       }
  10204.  
  10205.  
  10206.             scdnkfind_________________________________
  10207.  
  10208.                            USAGE     int scdnkfind(
  10209.                       int handle,
  10210.                       void *key,
  10211.                       long *recno,
  10212.                       int method );
  10213.  
  10214.  
  10215.  
  10216.  
  10217.  
  10218.  
  10219.  
  10220.  
  10221.  
  10222.  
  10223.  
  10224.  
  10225.             User's Reference Guide                 149
  10226.  
  10227.  
  10228.  
  10229.  
  10230.  
  10231.  
  10232.  
  10233.  
  10234.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10235.  
  10236.  
  10237.             PROTOTYPE IN          sc_base.h
  10238.  
  10239.             DESCRIPTION           scdnkfind supports two key search
  10240.                       methods (determined by "method"): SC_EXACT - find
  10241.                       an exact match with "key" and "recno", and
  10242.                       SC_FIRST - finds the first logical occurrence of
  10243.                       "key" in the index and returns the associated
  10244.                       record number "recno" if found.
  10245.  
  10246.                       If a match cannot be found, the current key will
  10247.                       be the physical key which would immediately
  10248.                       precede "key". The current key's value and data
  10249.                       record number will be returned in "key" and
  10250.                       "recno".
  10251.  
  10252.                 NOTES The user must ensure that the buffer used to
  10253.                       return the key is large enough to hold the entire
  10254.                       key. The maximum length of the key can be
  10255.                       determined via a call to scdninfo.
  10256.  
  10257.                       When searching using character keys it is not
  10258.                       necessary  to  pad  the key string to size with
  10259.                       spaces (" "), the function will automatically do
  10260.                       this for you.
  10261.  
  10262.                       Searching for partial keys can be accomplished by
  10263.                       using the SC_FIRST method. For example, you are
  10264.                       using a fifteen character key size and you want to
  10265.                       find the first entry where the first five
  10266.                       characters are "ABCDE". All you need do is copy
  10267.                       that five character ASCIIZ string into your key
  10268.                       buffer and then call scdnkfind. The function will
  10269.                       space pad to length and then find the first
  10270.                       matching entry.
  10271.  
  10272.                       Numeric keys are returned as doubles, and
  10273.                       character keys are returned as strings.
  10274.  
  10275.              SEE ALSO scdninfo.
  10276.  
  10277.               EXAMPLE #include <string.h>
  10278.                       #include <softc.h>
  10279.                       #include <sc_base.h>
  10280.  
  10281.                       void main()
  10282.                       {
  10283.                         int ndx;
  10284.                         char key[16],*index="TOCNAME.NDX";
  10285.                         long recno;
  10286.  
  10287.                         scdinit(20,0);
  10288.  
  10289.  
  10290.  
  10291.             150                 SoftC Database Library
  10292.  
  10293.  
  10294.  
  10295.  
  10296.  
  10297.  
  10298.  
  10299.  
  10300.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10301.  
  10302.  
  10303.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  10304.                       {
  10305.                           strcpy(key,"ABCDE");
  10306.                           recno = 7L;
  10307.                           if (scdnkfind(ndx,key,&recno,SC_FIRST) !=
  10308.                       SC_SUCCESS
  10309.                             puts(scemsg());
  10310.                           scddclose(ndx);
  10311.                         }
  10312.                         scdterm();
  10313.                       }
  10314.  
  10315.  
  10316.             scdnkmake_________________________________
  10317.  
  10318.                            USAGE     int scdnkmake(
  10319.                       int datahandle,
  10320.                       int indexhandle,
  10321.                       void **key );
  10322.  
  10323.             PROTOTYPE IN          sc_base.h
  10324.  
  10325.             DESCRIPTION           scdnkmake will build an index key
  10326.                       using the key expression of the index file
  10327.                       specified by "indexhandle" and the data found in
  10328.                       the output buffer of the data file "datahandle".
  10329.                       Memory space for the "key" will be allocated and
  10330.                       the address of this block will be returned.
  10331.  
  10332.                       The key expression can consist of either the data
  10333.                       field name or one of five dBASE functions or a
  10334.                       combination thereof. Data field types of date,
  10335.                       numeric, or character are allowed. dBASE functions
  10336.                       dtoc, left, right, str, and substr are currently
  10337.                       supported by scdnkmake.
  10338.  
  10339.                       Following is a brief description of the five
  10340.                       expression functions:
  10341.  
  10342.                       dtoc will convert data from a date field to an
  10343.                       ASCIIZ string of the format mm/dd/yy. Syntax is:
  10344.  
  10345.                       dtoc(field_name)
  10346.  
  10347.                       left will return the left portion of a character
  10348.                       field as an ASCIIZ string. The number of
  10349.                       characters returned is specified after the field
  10350.                       name. Syntax is:
  10351.  
  10352.                       left(field_name,number)
  10353.  
  10354.  
  10355.  
  10356.  
  10357.             User's Reference Guide                 151
  10358.  
  10359.  
  10360.  
  10361.  
  10362.  
  10363.  
  10364.  
  10365.  
  10366.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10367.  
  10368.  
  10369.                       right will return the right portion of a character
  10370.                       field as an ASCIIZ string. The number of
  10371.                       characters returned is specified after the field
  10372.                       name. This is a count from the right side of the
  10373.                       field. Syntax is:
  10374.  
  10375.                       right(field_name,number)
  10376.  
  10377.                       str will convert a numeric field to an ASCIIZ
  10378.                       string. The total length of the string and the
  10379.                       number of decimal places are optional parameters.
  10380.                       The default string length is 10 and the number of
  10381.                       decimal places is 0. Syntax is:
  10382.  
  10383.                       str(field_name,length,decimal_places)
  10384.  
  10385.                       substr will return the middle portion of a
  10386.                       character field. The starting offset into the
  10387.                       field is a required parameter. The number of
  10388.                       characters to be used is an optional parameter
  10389.                       whose default value is the remainder of the field.
  10390.                       Syntax is:
  10391.  
  10392.                       substr(field_name,start,count)
  10393.  
  10394.                       An example of a more complex key expression:
  10395.  
  10396.                       right(dtoc(date),2)+left(dtoc(date,2)
  10397.  
  10398.                       This expression would cause scdnkmake to create an
  10399.                       index key string consisting of the year and month
  10400.                       ("yymm"). For example if date equals "2/13/89" the
  10401.                       resultant key would be "8902".
  10402.  
  10403.                 NOTES For key expressions consisting of only one data
  10404.                       field scdnkmake is probably an overkill. You can
  10405.                       easily generate these keys yourself. See scdnkdate
  10406.                       for information on date string to key translation.
  10407.                       scdnkmake is a fairly large module and if not
  10408.                       needed probably should not be used. This function
  10409.                       is best used when the key expression is more
  10410.                       complex.
  10411.  
  10412.                       Memory is allocated for the generated key and it
  10413.                       is the responsibility of the caller to free this
  10414.                       memory when finished.
  10415.  
  10416.              SEE ALSO scdncreate, scdnkdate.
  10417.  
  10418.               EXAMPLE #include <sc_base.h>
  10419.  
  10420.  
  10421.  
  10422.  
  10423.             152                 SoftC Database Library
  10424.  
  10425.  
  10426.  
  10427.  
  10428.  
  10429.  
  10430.  
  10431.  
  10432.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10433.  
  10434.  
  10435.                       void main()
  10436.                       {
  10437.                         int ndx, dbf;
  10438.                         char *key,*file="TOCNAME.NDX";
  10439.                         long recno;
  10440.  
  10441.                         scdinit(20,0);
  10442.                         if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
  10443.                           if
  10444.                       (scdnopenx(&ndx,file,SC_BUFFER)==SC_SUCCESS) {
  10445.                             scddfput(dbf,0,"HELLO.C");
  10446.                             scddrput(dbf,&recno,SC_ADD);
  10447.                             scdnkmake(dbf,ndx,(void **) &key);
  10448.                             scdnkadd(ndx,key,recno);
  10449.                             free(key);    /* free memory allocated for
  10450.                       key */
  10451.                             scdnclose(ndx);
  10452.                           }
  10453.                           scddclose(dbf);
  10454.                         }
  10455.                         scdterm();
  10456.                       }
  10457.  
  10458.  
  10459.             scdnknext_________________________________
  10460.  
  10461.                            USAGE     int scdnknext(
  10462.                       int handle,
  10463.                       void *key,
  10464.                       long *recno );
  10465.  
  10466.             PROTOTYPE IN          sc_base.h
  10467.  
  10468.             DESCRIPTION           scdnknext will increment the key
  10469.                       pointer and return the key value "key" and data
  10470.                       record number "recno" associated with the new
  10471.                       current key.
  10472.  
  10473.                       If scdnknext is called immediately after opening
  10474.                       the index file the first logical key will be
  10475.                       returned.
  10476.  
  10477.                 NOTES The user must ensure that the buffer used to
  10478.                       return the key is large enough to hold the entire
  10479.                       key. The maximum length of the key can be
  10480.                       determined via a call to scdninfo.
  10481.  
  10482.                       Numeric keys are returned as doubles, and
  10483.                       character keys are returned as strings.
  10484.  
  10485.  
  10486.  
  10487.  
  10488.  
  10489.             User's Reference Guide                 153
  10490.  
  10491.  
  10492.  
  10493.  
  10494.  
  10495.  
  10496.  
  10497.  
  10498.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10499.  
  10500.  
  10501.              SEE ALSO scdninfo.
  10502.  
  10503.               EXAMPLE /*  Character Key Example     */
  10504.                       #include <stdio.h>
  10505.                       #include <softc.h>
  10506.                       #include <sc_base.h>
  10507.  
  10508.                       void main()
  10509.                       {
  10510.                         int ndx;
  10511.                         char name[65],*index="TOCNAME.NDX";
  10512.                         long recno;
  10513.  
  10514.                         scdinit(20,0);
  10515.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  10516.                       {
  10517.                           scdnknext(ndx,name,&recno);    /* return first
  10518.                       key */
  10519.                           printf("%s %ld\n",name,recno);
  10520.                           scdnclose(ndx);
  10521.                         }
  10522.                         scdterm();
  10523.                       }
  10524.  
  10525.                       /*  Numeric Key Example  */
  10526.                       #include <stdio.h>
  10527.                       #include <softc.h>
  10528.                       #include <sc_base.h>
  10529.  
  10530.                       void main()
  10531.                       {
  10532.                         int ndx;
  10533.                         double length;
  10534.                         long recno;
  10535.                         char *index="TOCLNGTH.NDX";
  10536.  
  10537.                         scdinit(20,0);
  10538.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  10539.                       {
  10540.                           scdnknext(ndx,&length,&recno); /* return first
  10541.                       key */
  10542.                           printf("%lf %ld\n",length,recno);
  10543.                           scdnclose(ndx);
  10544.                         }
  10545.                         scdterm();
  10546.                       }
  10547.  
  10548.  
  10549.  
  10550.  
  10551.  
  10552.  
  10553.  
  10554.  
  10555.             154                 SoftC Database Library
  10556.  
  10557.  
  10558.  
  10559.  
  10560.  
  10561.  
  10562.  
  10563.  
  10564.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10565.  
  10566.  
  10567.             scdnkprev_________________________________
  10568.  
  10569.                            USAGE     int scdnkprev(
  10570.                       int handle,
  10571.                       void *key,
  10572.                       long *recno );
  10573.  
  10574.             PROTOTYPE IN          sc_base.h
  10575.  
  10576.             DESCRIPTION           scdnkprev will decrement the key
  10577.                       pointer and return the key value "key" and data
  10578.                       record number "recno" associated with the new
  10579.                       current key.
  10580.  
  10581.                       If scdnkprev is called immediately after opening
  10582.                       the index file the last logical key will be
  10583.                       returned.
  10584.  
  10585.                 NOTES The user must ensure that the buffer used to
  10586.                       return the key is large enough to hold the entire
  10587.                       key. The maximum length of the key can be
  10588.                       determined via a call to scdninfo.
  10589.  
  10590.                       Numeric keys are returned as doubles, and
  10591.                       character keys are returned as strings.
  10592.  
  10593.  
  10594.  
  10595.  
  10596.  
  10597.  
  10598.  
  10599.  
  10600.  
  10601.  
  10602.  
  10603.  
  10604.  
  10605.  
  10606.  
  10607.  
  10608.  
  10609.  
  10610.  
  10611.  
  10612.  
  10613.  
  10614.  
  10615.  
  10616.  
  10617.  
  10618.  
  10619.  
  10620.  
  10621.             User's Reference Guide                 155
  10622.  
  10623.  
  10624.  
  10625.  
  10626.  
  10627.  
  10628.  
  10629.  
  10630.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10631.  
  10632.  
  10633.              SEE ALSO scdninfo.
  10634.  
  10635.               EXAMPLE /*  Character Key Example  */
  10636.                       #include <stdio.h>
  10637.                       #include <softc.h>
  10638.                       #include <sc_base.h>
  10639.  
  10640.                       void main()
  10641.                       {
  10642.                         int ndx;
  10643.                         char name[65],*file="TOCNAME.NDX";
  10644.                         long recno;
  10645.  
  10646.                         scdinit(20,0);
  10647.                         if (scdnopenx(&ndx,file,SC_BUFFER)==SC_SUCCESS)
  10648.                       {
  10649.                           name[64] = 0;
  10650.                           scdnkprev(ndx,name,&recno);  /* get last key
  10651.                       */
  10652.                           printf("%s %ld\n",name,recno);
  10653.                           scdnclose(ndx);
  10654.                         }
  10655.                         scdterm();
  10656.                       }
  10657.  
  10658.                       /*  Numeric Key Example  */
  10659.                       #include <stdio.h>
  10660.                       #include <softc.h>
  10661.                       #include <sc_base.h>
  10662.  
  10663.                       void main()
  10664.                       {
  10665.                         int ndx;
  10666.                         double length;
  10667.                         long recno;
  10668.                         char *file="TOCLNGTH.NDX";
  10669.  
  10670.                         scdinit(20,0);
  10671.                         if (scdnopenx(&ndx,file,SC_BUFFER)==SC_SUCCESS)
  10672.                       {
  10673.                           scdnkprev(ndx,&length,&recno); /* get last key
  10674.                       */
  10675.                           printf("%lf %ld\n",length,recno);
  10676.                           scdnclose(ndx);
  10677.                         }
  10678.                         scdterm();
  10679.                       }
  10680.  
  10681.  
  10682.  
  10683.  
  10684.  
  10685.  
  10686.  
  10687.             156                 SoftC Database Library
  10688.  
  10689.  
  10690.  
  10691.  
  10692.  
  10693.  
  10694.  
  10695.  
  10696.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10697.  
  10698.  
  10699.             scdnktop__________________________________
  10700.  
  10701.                            USAGE     int scdnktop(
  10702.                       int handle,
  10703.                       void *key,
  10704.                       long *recno );
  10705.  
  10706.             PROTOTYPE IN          sc_base.h
  10707.  
  10708.             DESCRIPTION           scdnktop will set the current key
  10709.                       pointer to the first logical key in the index and
  10710.                       return the key value "key" and data record number
  10711.                       "recno" associated with the new current key.
  10712.  
  10713.                 NOTES The user must ensure that the buffer used to
  10714.                       return the key is large enough to hold the entire
  10715.                       key. The maximum length of the key can be
  10716.                       determined via a call to scdninfo.
  10717.  
  10718.                       Numeric keys are returned as doubles, and
  10719.                       character keys are returned as strings.
  10720.  
  10721.              SEE ALSO scdninfo.
  10722.  
  10723.               EXAMPLE /*  Character Key Example  */
  10724.                       #include <stdio.h>
  10725.                       #include <softc.h>
  10726.                       #include <sc_base.h>
  10727.  
  10728.                       void main()
  10729.                       {
  10730.                         int ndx;
  10731.                         char name[65], *file="TOCNAME.NDX";
  10732.                         long recno;
  10733.  
  10734.                         scdinit(20,0);
  10735.                         if (scdnopenx(&ndx,file,SC_BUFFER)==SC_SUCCESS)
  10736.                       {
  10737.                           name[64] = 0;
  10738.                           scdnktop(ndx,name,&recno);
  10739.                           printf("%s %ld\n",name,recno);
  10740.                           scdnclose(ndx);
  10741.                         }
  10742.                         scdterm();
  10743.                       }
  10744.  
  10745.                       /*  Numeric Key Example  */
  10746.                       #include <stdio.h>
  10747.                       #include <softc.h>
  10748.                       #include <sc_base.h>
  10749.  
  10750.  
  10751.  
  10752.  
  10753.             User's Reference Guide                 157
  10754.  
  10755.  
  10756.  
  10757.  
  10758.  
  10759.  
  10760.  
  10761.  
  10762.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10763.  
  10764.  
  10765.                       void main()
  10766.                       {
  10767.                         int ndx;
  10768.                         double length;
  10769.                         long recno;
  10770.                         char *file="TOCLNGTH.NDX";
  10771.  
  10772.                         scdinit(20,0);
  10773.                         if (scdnopenx(&ndx,file,SC_BUFFER)==SC_SUCCESS)
  10774.                       {
  10775.                           scdnktop(ndx,&length,&recno);
  10776.                           printf("%lf %ld\n",length,recno);
  10777.                           scdnclose(ndx);
  10778.                         }
  10779.                         scdterm();
  10780.                       }
  10781.  
  10782.  
  10783.             scdnopenx_________________________________
  10784.  
  10785.                            USAGE     int scdnopenx(
  10786.                       int *handle,
  10787.                       char *filename,
  10788.                       int command );
  10789.  
  10790.             PROTOTYPE IN          sc_base.h
  10791.  
  10792.             DESCRIPTION           scdnopenx opens a dBASE index file.
  10793.                       Memory will be allocated for a file packet, I/O
  10794.                       buffers, and other miscellaneous structures for
  10795.                       use internally by the SoftC Database Library file
  10796.                       manager. The index file will be tested as much as
  10797.                       possible to insure that it is a legitimate dBASE
  10798.                       index file.
  10799.  
  10800.                       A block of memory large enough to hold at least 3
  10801.                       pages (1536 bytes) will be allocated during the
  10802.                       open. Three pages is the minimum number of buffers
  10803.                       required to add or delete index keys.
  10804.  
  10805.                       The file will be opened under control of the
  10806.                       "command" parameter.  Using SC_RDWR opens the file
  10807.                       for both read and write access.  SC_RDONLY
  10808.                       overrides SC_RDWR and causes the file to be opened
  10809.                       for read access only.  Any attempt to write to a
  10810.                       read only file will result in an error
  10811.                       (SC_READOLY).
  10812.  
  10813.                       Using SC_EXCLUDE opens the file for exclusive use
  10814.                       of this station (single user).  SC_SHARED
  10815.  
  10816.  
  10817.  
  10818.  
  10819.             158                 SoftC Database Library
  10820.  
  10821.  
  10822.  
  10823.  
  10824.  
  10825.  
  10826.  
  10827.  
  10828.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10829.  
  10830.  
  10831.                       overrides SC_EXCLUDE and opens the file in multi-
  10832.                       user mode.  This mode is used when a LAN file is
  10833.                       to be shared with other stations.
  10834.  
  10835.                       Using SC_BUFFER opens the file with I/O caching
  10836.                       enabled.  Memory for up  to 10 pages will be
  10837.                       allocated during the open.  Caching of page I/O
  10838.                       greatly increases the speed of file access.
  10839.                       Typically this mode is used with single user
  10840.                       files.  SC_FLUSH overrides SC_BUFFER and causes
  10841.                       the file to be opened with no caching.  This mode
  10842.                       is generally used with file sharing, although it
  10843.                       is not required.
  10844.  
  10845.                 NOTES The index expression will be translated to upper
  10846.                       case after being read from the index file.
  10847.  
  10848.               EXAMPLE #include <softc.h>
  10849.                       #include <sc_base.h>
  10850.  
  10851.                       void main()
  10852.                       {
  10853.                         int ndx;
  10854.                         char *index="UNKNOWN.NDX";
  10855.  
  10856.                         scdinit(20,0);
  10857.                         if (scdnopenx(&ndx,index,SC_BUFFER)==SC_SUCCESS)
  10858.                           scdnclose(ndx);
  10859.                         scdterm();
  10860.                       }
  10861.  
  10862.  
  10863.             scdtclose_________________________________
  10864.  
  10865.                            USAGE     int scdtclose(
  10866.                       int handle );
  10867.  
  10868.             PROTOTYPE IN          sc_base.h
  10869.  
  10870.             DESCRIPTION           scdtclose closes a memo file and frees
  10871.                       all allocated memory associated with memo file
  10872.                       "handle".
  10873.  
  10874.              SEE ALSO scdtopenx.
  10875.  
  10876.               EXAMPLE #include <sc_base.h>
  10877.  
  10878.                       void main()
  10879.                       {
  10880.                         int dbt;
  10881.  
  10882.  
  10883.  
  10884.  
  10885.             User's Reference Guide                 159
  10886.  
  10887.  
  10888.  
  10889.  
  10890.  
  10891.  
  10892.  
  10893.  
  10894.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  10895.  
  10896.  
  10897.  
  10898.                         scdinit(20,0);
  10899.                         if
  10900.                       (scdtopenx(&dbt,"TOC.DBT",SC_SHARED)==SC_SUCCESS)
  10901.                           scdtclose(dbt);
  10902.                         scdterm();
  10903.                       }
  10904.  
  10905.  
  10906.             scdtcreate________________________________
  10907.  
  10908.                            USAGE     int scdtcreate(
  10909.                       char *filename );
  10910.  
  10911.             PROTOTYPE IN          sc_base.h
  10912.  
  10913.             DESCRIPTION           scdtcreate creates a memo file. This
  10914.                       function will create a new memo file even if one
  10915.                       had already existed.
  10916.  
  10917.               EXAMPLE #include <sc_base.h>
  10918.  
  10919.                       void main()
  10920.                       {
  10921.                         scdinit(20,0);
  10922.                         scdtcreate("TOC.DBT");
  10923.                         scdterm();
  10924.                       }
  10925.  
  10926.  
  10927.             scdterm___________________________________
  10928.  
  10929.                            USAGE     int scdterm( void );
  10930.  
  10931.  
  10932.  
  10933.  
  10934.  
  10935.  
  10936.  
  10937.  
  10938.  
  10939.  
  10940.  
  10941.  
  10942.  
  10943.  
  10944.  
  10945.  
  10946.  
  10947.  
  10948.  
  10949.  
  10950.  
  10951.             160                 SoftC Database Library
  10952.  
  10953.  
  10954.  
  10955.  
  10956.  
  10957.  
  10958.  
  10959.  
  10960.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  10961.  
  10962.  
  10963.             PROTOTYPE IN          sc_base.h
  10964.  
  10965.             DESCRIPTION           scdterm is called once at the end of
  10966.                       the program. Memory allocated by scdinit for
  10967.                       internal control structures will be freed. All
  10968.                       files open will be closed, any locks applied will
  10969.                       be released, and any memory allocated for them
  10970.                       will be freed. Any errors encountered will be
  10971.                       returned in sc_code.
  10972.  
  10973.                 NOTES It is a good idea to call atexit with scdterm at
  10974.                       the very beginning of your application. This will
  10975.                       ensure that all buffered data is written to disk
  10976.                       before the program terminates. Be aware that
  10977.                       scdterm can encounter errors which you may or may
  10978.                       not be able to display if atexit is used.
  10979.  
  10980.              SEE ALSO scdinit.
  10981.  
  10982.               EXAMPLE #include <stdio.h>
  10983.                       #include <sc_base.h>
  10984.  
  10985.                       void main()
  10986.                       {
  10987.                         atexit(scdterm());
  10988.                         scdinit(20,0);
  10989.                         .
  10990.                         . body of application
  10991.                         .
  10992.                         puts("Terminating...");
  10993.                       }
  10994.  
  10995.  
  10996.             scdthget__________________________________
  10997.  
  10998.  
  10999.             USAGEint scdthget(
  11000.                       int handle );
  11001.  
  11002.             PROTOTYPE IN          sc_base.h
  11003.  
  11004.             DESCRIPTION           scdthget will read the memo file
  11005.                       header. This function should be called after the
  11006.                       data file has been locked in order to reload the
  11007.                       current file header information.
  11008.  
  11009.             RETURN VALUES         SC_SUCCESS   header read successfully
  11010.                       SC_RDFAIL   file read failure
  11011.                       SC_SKFAIL   file pointer reposition failed
  11012.                       SC_BADHNDL  invalid handle number
  11013.  
  11014.  
  11015.  
  11016.  
  11017.             User's Reference Guide                 161
  11018.  
  11019.  
  11020.  
  11021.  
  11022.  
  11023.  
  11024.  
  11025.  
  11026.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11027.  
  11028.  
  11029.              SEE ALSO scddlock.
  11030.  
  11031.               EXAMPLE #include <stdio.h>
  11032.                       #include <softc.h>
  11033.                       #include <sc_base.h>
  11034.  
  11035.                       void main()
  11036.                       {
  11037.                         int dbf, dbt;
  11038.  
  11039.                         scdinit(20,0);
  11040.                         if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) ==
  11041.                       SC_SUCCESS) {
  11042.                           scdtopenx(&dbt,"TOC.DBT",SC_SHARED);
  11043.                           scddlock(dbf);
  11044.                           scddhget(dbf);
  11045.                           scdthget(dbt);
  11046.                       /* append records - add keys - etc. */
  11047.                           scddunlock(dbf);
  11048.                           scddclose(dbf);
  11049.                         }
  11050.                         scdterm();
  11051.                       }
  11052.  
  11053.  
  11054.             scdtinfo__________________________________
  11055.  
  11056.                            USAGE     int scdtinfo(
  11057.                       int handle,
  11058.                       SC_DBTINFO *info );
  11059.  
  11060.             PROTOTYPE IN          sc_base.h
  11061.  
  11062.             DESCRIPTION           scdtinfo gets the name of the memo
  11063.                       file associated with "handle" and returns it in a
  11064.                       structure:
  11065.  
  11066.                       typdef struct {
  11067.                         char fname[80];   /* file name */
  11068.                         SC_FLAGS flags;   /* misc. flags */
  11069.                       } SC_DBTINFO;
  11070.  
  11071.              SEE ALSO scdtopenx.
  11072.  
  11073.               EXAMPLE #include <softc.h>
  11074.                       #include <sc_base.h>
  11075.  
  11076.                       void main()
  11077.                       {
  11078.                         int dbt;
  11079.                         SC_DBTINFO info;
  11080.  
  11081.  
  11082.  
  11083.             162                 SoftC Database Library
  11084.  
  11085.  
  11086.  
  11087.  
  11088.  
  11089.  
  11090.  
  11091.  
  11092.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11093.  
  11094.  
  11095.                         char *memo="TOC.DBT";
  11096.  
  11097.                         scdinit(20,0);
  11098.                         if (scdtopenx(&dbt,memo,SC_SHARED)==SC_SUCCESS)
  11099.                       {
  11100.                           scdtinfo(dbt,&info);
  11101.                           puts(info.fname);
  11102.                           scdtclose(dbt);
  11103.                         }
  11104.                         scdterm();
  11105.                       }
  11106.  
  11107.  
  11108.             scdtopenx_________________________________
  11109.  
  11110.                            USAGE     int scdtopenx(
  11111.                       int *handle,
  11112.                       char *filename,
  11113.                       int command );
  11114.  
  11115.             PROTOTYPE IN          sc_base.h
  11116.  
  11117.             DESCRIPTION           scdtopenx opens a memo file. Memory
  11118.                       will be allocated for a file packet and I/O
  11119.                       buffers for use internally by the library file
  11120.                       manager. The memo file will be tested as much as
  11121.                       possible to insure that it is a legitimate
  11122.                       dBASEIII+ memo file.
  11123.  
  11124.                       The file will be opened under control of the
  11125.                       "command" parameter.  Using SC_RDWR opens the file
  11126.                       for both read and write access.  SC_RDONLY
  11127.                       overrides SC_RDWR and causes the file to be opened
  11128.                       for read access only.  Any attempt to write to a
  11129.                       read only file will result in an error
  11130.                       (SC_READOLY).
  11131.  
  11132.                       Using SC_EXCLUDE opens the file for exclusive use
  11133.                       of this station (single user).  SC_SHARED
  11134.                       overrides SC_EXCLUDE and opens the file in multi-
  11135.                       user mode.  This mode is used when a LAN file is
  11136.                       to be shared with other stations.
  11137.  
  11138.                       SC_BUFFER is not used.
  11139.  
  11140.                       "command" = 0 is equivalent to SC_EXCLUDE |
  11141.                       SC_RDWR.
  11142.  
  11143.               EXAMPLE #include <softc.h>
  11144.                       #include <sc_base.h>
  11145.  
  11146.  
  11147.  
  11148.  
  11149.             User's Reference Guide                 163
  11150.  
  11151.  
  11152.  
  11153.  
  11154.  
  11155.  
  11156.  
  11157.  
  11158.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11159.  
  11160.  
  11161.  
  11162.                       void main()
  11163.                       {
  11164.                         int dbt;
  11165.                         char *memo="TOC.DBT";
  11166.  
  11167.                         scdinit(20,0);
  11168.                         if (scdtopenx(&dbt,memo,SC_SHARED)==SC_SUCCESS)
  11169.                           scdtclose(dbt);
  11170.                         scdterm();
  11171.                       }
  11172.  
  11173.  
  11174.             scdtpack__________________________________
  11175.  
  11176.                            USAGE     int scdtpack(
  11177.                       int datafile,
  11178.                       int *memofile );
  11179.  
  11180.  
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186.  
  11187.  
  11188.  
  11189.  
  11190.  
  11191.  
  11192.  
  11193.  
  11194.  
  11195.  
  11196.  
  11197.  
  11198.  
  11199.  
  11200.  
  11201.  
  11202.  
  11203.  
  11204.  
  11205.  
  11206.  
  11207.  
  11208.  
  11209.  
  11210.  
  11211.  
  11212.  
  11213.  
  11214.  
  11215.             164                 SoftC Database Library
  11216.  
  11217.  
  11218.  
  11219.  
  11220.  
  11221.  
  11222.  
  11223.  
  11224.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11225.  
  11226.  
  11227.             PROTOTYPE IN          sc_base.h
  11228.  
  11229.             DESCRIPTION           scdtpack will remove all "memofile"
  11230.                       records which are not referenced by records in the
  11231.                       "datafile".  The "memofile" will be compressed so
  11232.                       that all active records will be contiguous after
  11233.                       the pack.  Files opened with the read only flag
  11234.                       (SC_RDONLY) cannot be packed.
  11235.  
  11236.              SEE ALSO scddpack, scdtopenx
  11237.  
  11238.               EXAMPLE #include <softc.h>
  11239.                       #include <sc_base.h>
  11240.  
  11241.                       void main()
  11242.                       {
  11243.                         int dbf, dbt;
  11244.                         char *data="TOC.DBF",*memo="TOC.DBT";
  11245.  
  11246.                         scdinit(20,0);
  11247.                         if (scddopenx(&dbf,data,SC_SHARED)==SC_SUCCESS)
  11248.                       {
  11249.                           if
  11250.                       (scdtopenx(&dbt,memo,SC_SHARED)==SC_SUCCESS) {
  11251.                             scdtpack(dbf, &dbt);
  11252.                             scdtclose(dbt);
  11253.                           }
  11254.                           scddclose(dbf);
  11255.                         }
  11256.                         scdterm();
  11257.                       }
  11258.  
  11259.  
  11260.             scdtrget__________________________________
  11261.  
  11262.                            USAGE     int scdtrget(
  11263.                       int handle,
  11264.                       long recno,
  11265.                       char **data,
  11266.                       int command );
  11267.  
  11268.             PROTOTYPE IN          sc_base.h
  11269.  
  11270.             DESCRIPTION           scdtrget reads the desired record
  11271.                       "recno" from the memo file specified by "handle".
  11272.                       A buffer large enough to hold the text will be
  11273.                       allocated, the address of which is returned in
  11274.                       "data".
  11275.  
  11276.                       "command" controls whether or not the soft
  11277.                       carriage returns are stripped. Use SC_CRUNCHNG to
  11278.  
  11279.  
  11280.  
  11281.             User's Reference Guide                 165
  11282.  
  11283.  
  11284.  
  11285.  
  11286.  
  11287.  
  11288.  
  11289.  
  11290.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11291.  
  11292.  
  11293.                       leave the soft carriage returns alone, or use
  11294.                       SC_CRDELETE to remove them.
  11295.  
  11296.              SEE ALSO scdtrget.
  11297.  
  11298.               EXAMPLE #include <stdio.h>
  11299.                       #include <softc.h>
  11300.                       #include <sc_base.h>
  11301.  
  11302.                       void main()
  11303.                       {
  11304.                         int dbt;
  11305.                         char *data,*memo="TOC.DBT";
  11306.  
  11307.                         scdinit(20,0);
  11308.                         if (scdtopenx(&dbt,memo,SC_SHARED)==SC_SUCCESS)
  11309.                       {
  11310.                           scdtrget(dbt,1L,&data,SC_CRDELETE);
  11311.                           puts(data);
  11312.                           free(data);
  11313.                           scddclose(dbt);
  11314.                         }
  11315.                         scdterm();
  11316.                       }
  11317.  
  11318.  
  11319.             scdtrput__________________________________
  11320.  
  11321.                            USAGE     int scdtrput(
  11322.                       int handle,
  11323.                       long *recno,
  11324.                       char *data,
  11325.                       int linelength );
  11326.  
  11327.             PROTOTYPE IN          sc_base.h
  11328.  
  11329.             DESCRIPTION           scdtrput writes "data" to the memo
  11330.                       file specified by "handle". The record number
  11331.                       written is returned in "recno". This record number
  11332.                       must be then written to the data output buffer via
  11333.                       a call to scddfput. This function assumes that
  11334.                       "data" is an ASCIIZ string with a maximum length
  11335.                       of 65,536 characters.
  11336.  
  11337.                       The user can directly control whether or not the
  11338.                       soft carriage returns are added and, if so, where.
  11339.                       If "linelength" is zero (0) no soft carriage
  11340.                       returns will be added, else "linelength" specifies
  11341.                       the maximum length of a memo line.  It cannot be
  11342.                       less than 10 nor greater than 132.
  11343.  
  11344.  
  11345.  
  11346.  
  11347.             166                 SoftC Database Library
  11348.  
  11349.  
  11350.  
  11351.  
  11352.  
  11353.  
  11354.  
  11355.  
  11356.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11357.  
  11358.  
  11359.                 NOTES Existing soft carriage returns are not removed
  11360.                       before new ones are added.
  11361.  
  11362.              SEE ALSO scdtrput.
  11363.  
  11364.               EXAMPLE #include <stdio.h>
  11365.                       #include <softc.h>
  11366.                       #include <sc_base.h>
  11367.  
  11368.                       void main()
  11369.                       {
  11370.                         int dbt;
  11371.                         char data[512],*memo="TOC.DBT";
  11372.                         long recno;
  11373.  
  11374.                         scdinit(20,0);
  11375.                         if (scdtopenx(&dbt,memo,SC_BUFFER)==SC_SUCCESS)
  11376.                       {
  11377.                           strcpy(data,"hello world.");
  11378.                           scdtrput(dbt,&recno,data,66);
  11379.                           printf("%ld",recno);
  11380.                           scddclose(dbt);
  11381.                         }
  11382.                         scdterm();
  11383.                       }
  11384.  
  11385.  
  11386.             scdwclose_________________________________
  11387.  
  11388.                            USAGE     int scdwclose(
  11389.                       int handle );
  11390.  
  11391.             PROTOTYPE IN          sc_base.h
  11392.  
  11393.             DESCRIPTION           scdwclose closes a memo file and frees
  11394.                       all allocated memory associated with memo file
  11395.                       "handle".
  11396.  
  11397.             RETURN VALUES         SC_SUCCESS   file closed successfully
  11398.                       SC_CLOSFAIL file close failure
  11399.                       SC_BADHNDL  invalid handle number
  11400.  
  11401.              SEE ALSO scdwopenx.
  11402.  
  11403.               EXAMPLE #include <sc_base.h>
  11404.  
  11405.                       void main()
  11406.                       {
  11407.                         int dbt;
  11408.  
  11409.                         scdinit(20,0);
  11410.  
  11411.  
  11412.  
  11413.             User's Reference Guide                 167
  11414.  
  11415.  
  11416.  
  11417.  
  11418.  
  11419.  
  11420.  
  11421.  
  11422.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11423.  
  11424.  
  11425.                         if
  11426.                       (scdwopenx(&dbt,"TOC.FPT",SC_SHARED)==SC_SUCCESS)
  11427.                           scdwclose(dbt);
  11428.                         scdterm();
  11429.                       }
  11430.  
  11431.  
  11432.             scdwcreate________________________________
  11433.  
  11434.                            USAGE     int scdwcreate(
  11435.                       char *filename,
  11436.                       int blocksize );
  11437.  
  11438.             PROTOTYPE IN          sc_base.h
  11439.  
  11440.             DESCRIPTION           scdwcreate creates a FoxPro memo file.
  11441.                       The memo text record length is determined by
  11442.                       blocksize. The legitimate values for blocksize are
  11443.                       from 1 to 511. Values of 1 through 32 are
  11444.                       multiplied by 512 (1 = 512, 2 = 1024, etc.) while
  11445.                       the others are used as-is. This function will
  11446.                       create a new memo file even if one had already
  11447.                       existed.
  11448.  
  11449.             RETURN VALUES         SC_SUCCESS   file successfully created
  11450.                       SC_WRTFAIL  file write failure
  11451.                       SC_NOHNDL   no handles available
  11452.                       SC_BADFNAME invalid filename
  11453.                       SC_NULLPARM parameter address NULL
  11454.  
  11455.               EXAMPLE #include <sc_base.h>
  11456.  
  11457.                       void main()
  11458.                       {
  11459.                         scdinit(20,0);
  11460.                         scdwcreate("TOC.FPT",64);
  11461.                         scdterm();
  11462.                       }
  11463.  
  11464.  
  11465.             scdwhget__________________________________
  11466.  
  11467.  
  11468.             USAGEint scdwhget(
  11469.                       int handle );
  11470.  
  11471.             PROTOTYPE IN          sc_base.h
  11472.  
  11473.             DESCRIPTION           scdwhget will read the memo file
  11474.                       header. This function should be called after the
  11475.  
  11476.  
  11477.  
  11478.  
  11479.             168                 SoftC Database Library
  11480.  
  11481.  
  11482.  
  11483.  
  11484.  
  11485.  
  11486.  
  11487.  
  11488.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11489.  
  11490.  
  11491.                       data file has been locked in order to reload the
  11492.                       current file header information.
  11493.  
  11494.             RETURN VALUES         SC_SUCCESS   header read successfully
  11495.                       SC_RDFAIL   file read failure
  11496.                       SC_SKFAIL   file pointer reposition failed
  11497.                       SC_BADHNDL  invalid handle number
  11498.  
  11499.              SEE ALSO scddlock.
  11500.  
  11501.               EXAMPLE #include <stdio.h>
  11502.                       #include <softc.h>
  11503.                       #include <sc_base.h>
  11504.  
  11505.                       void main()
  11506.                       {
  11507.                         int dbf, fpt;
  11508.  
  11509.                         scdinit(20,0);
  11510.                         if (scddopenx(&dbf,"TOC.DBF",SC_SHARED) ==
  11511.                       SC_SUCCESS) {
  11512.                           scdwopenx(&fpt,"TOC.FPT",SC_SHARED);
  11513.                           scddlock(dbf);
  11514.                           scddhget(dbf);
  11515.                           scdwhget(fpt);
  11516.                       /* append records - add keys - etc. */
  11517.                           scddunlock(dbf);
  11518.                           scddclose(dbf);
  11519.                         }
  11520.                         scdterm();
  11521.                       }
  11522.  
  11523.  
  11524.             scdwinfo__________________________________
  11525.  
  11526.                            USAGE     int scdwinfo(
  11527.                       int handle,
  11528.                       SC_FPTINFO *info );
  11529.  
  11530.             PROTOTYPE IN          sc_base.h
  11531.  
  11532.             DESCRIPTION           scdwinfo gets the name of the memo
  11533.                       file associated with "handle" and returns it in a
  11534.                       structure:
  11535.  
  11536.                       typdef struct {
  11537.                         char fname[80];   /* file name */
  11538.                         SC_FLAGS flags;   /* misc. flags */
  11539.                       } SC_FPTINFO;
  11540.  
  11541.  
  11542.  
  11543.  
  11544.  
  11545.             User's Reference Guide                 169
  11546.  
  11547.  
  11548.  
  11549.  
  11550.  
  11551.  
  11552.  
  11553.  
  11554.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11555.  
  11556.  
  11557.             RETURN VALUES         SC_SUCCESS   file information
  11558.                       retrieved
  11559.                       SC_BADHNDL  invalid handle number
  11560.                       SC_NULLPARM parameter address NULL
  11561.  
  11562.              SEE ALSO scdwopenx.
  11563.  
  11564.               EXAMPLE #include <softc.h>
  11565.                       #include <sc_base.h>
  11566.  
  11567.                       void main()
  11568.                       {
  11569.                         int fpt;
  11570.                         SC_FPTINFO info;
  11571.                         char *memo="TOC.FPT";
  11572.  
  11573.                         scdinit(20,0);
  11574.                         if (scdwopenx(&fpt,memo,SC_SHARED)==SC_SUCCESS)
  11575.                       {
  11576.                           scdwinfo(fpt,&info);
  11577.                           puts(info.fname);
  11578.                           scdwclose(fpt);
  11579.                         }
  11580.                         scdterm();
  11581.                       }
  11582.  
  11583.  
  11584.             scdwopenx_________________________________
  11585.  
  11586.                            USAGE     int scdwopenx(
  11587.                       int *handle,
  11588.                       char *filename,
  11589.                       int command );
  11590.  
  11591.             PROTOTYPE IN          sc_base.h
  11592.  
  11593.             DESCRIPTION           scdwopenx opens a memo file. Memory
  11594.                       will be allocated for a file packet and I/O
  11595.                       buffers for use internally by the library file
  11596.                       manager. The memo file will be tested as much as
  11597.                       possible to insure that it is a legitimate FoxPro
  11598.                       memo file.
  11599.  
  11600.                       The file will be opened under control of the
  11601.                       "command" parameter.  Using SC_RDWR opens the file
  11602.                       for both read and write access.  SC_RDONLY
  11603.                       overrides SC_RDWR and causes the file to be opened
  11604.                       for read access only.  Any attempt to write to a
  11605.                       read only file will result in an error
  11606.                       (SC_READOLY).
  11607.  
  11608.  
  11609.  
  11610.  
  11611.             170                 SoftC Database Library
  11612.  
  11613.  
  11614.  
  11615.  
  11616.  
  11617.  
  11618.  
  11619.  
  11620.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11621.  
  11622.  
  11623.                       Using SC_EXCLUDE opens the file for exclusive use
  11624.                       of this station (single user).  SC_SHARED
  11625.                       overrides SC_EXCLUDE and opens the file in multi-
  11626.                       user mode.  This mode is used when a LAN file is
  11627.                       to be shared with other stations.
  11628.  
  11629.                       SC_BUFFER is not used.
  11630.  
  11631.                       "command" = 0 is equivalent to SC_EXCLUDE |
  11632.                       SC_RDWR.
  11633.  
  11634.             RETURN VALUES         SC_SUCCESS   file opened successfully
  11635.                       SC_RDFAIL   file read failure
  11636.                       SC_MEMERR   memory allocation error
  11637.                       SC_NOFILE   file not found
  11638.                       SC_NOHNDL   no handles available
  11639.                       SC_BADFNAME invalid file name
  11640.                       SC_NODBT    file not in memo format
  11641.                       SC_NULLPARM parameter address NULL
  11642.  
  11643.               EXAMPLE #include <softc.h>
  11644.                       #include <sc_base.h>
  11645.  
  11646.                       void main()
  11647.                       {
  11648.                         int fpt;
  11649.                         char *memo="TOC.FPT";
  11650.  
  11651.                         scdinit(20,0);
  11652.                         if (scdwopenx(&fpt,memo,SC_SHARED)==SC_SUCCESS)
  11653.                           scdwclose(fpt);
  11654.                         scdterm();
  11655.                       }
  11656.  
  11657.  
  11658.             scdwpack__________________________________
  11659.  
  11660.                            USAGE     int scdwpack(
  11661.                       int datafile,
  11662.                       int *memofile );
  11663.  
  11664.  
  11665.  
  11666.  
  11667.  
  11668.  
  11669.  
  11670.  
  11671.  
  11672.  
  11673.  
  11674.  
  11675.  
  11676.  
  11677.             User's Reference Guide                 171
  11678.  
  11679.  
  11680.  
  11681.  
  11682.  
  11683.  
  11684.  
  11685.  
  11686.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11687.  
  11688.  
  11689.             PROTOTYPE IN          sc_base.h
  11690.  
  11691.             DESCRIPTION           scdwpack will remove all "memofile"
  11692.                       records which are not referenced by records in the
  11693.                       "datafile".  The "memofile" will be compressed so
  11694.                       that all active records will be contiguous after
  11695.                       the pack.  Files opened with the read only flag
  11696.                       (SC_RDONLY) cannot be packed.
  11697.  
  11698.             RETURN VALUES         SC_SUCCESS   memo file packed
  11699.                       successfully
  11700.                       SC_MEMERR   memory allocation error
  11701.                       SC_NOFILE   file not found
  11702.                       SC_NOHNDL   no handles available
  11703.                       SC_NULLPARM parameter address NULL
  11704.  
  11705.              SEE ALSO scddpack, scdwopenx
  11706.  
  11707.               EXAMPLE #include <softc.h>
  11708.                       #include <sc_base.h>
  11709.  
  11710.                       void main()
  11711.                       {
  11712.                         int dbf, fpt;
  11713.                         char *data="TOC.DBF",*memo="TOC.FPT";
  11714.  
  11715.                         scdinit(20,0);
  11716.                         if (scddopenx(&dbf,data,SC_SHARED)==SC_SUCCESS)
  11717.                       {
  11718.                           if
  11719.                       (scdwopenx(&fpt,memo,SC_SHARED)==SC_SUCCESS) {
  11720.                             scdwpack(dbf, &fpt);
  11721.                             scdwclose(fpt);
  11722.                           }
  11723.                           scddclose(dbf);
  11724.                         }
  11725.                         scdterm();
  11726.                       }
  11727.  
  11728.  
  11729.             scdwrget__________________________________
  11730.  
  11731.                            USAGE     int scdwrget(
  11732.                       int handle,
  11733.                       long recno,
  11734.                       char **data );
  11735.  
  11736.             PROTOTYPE IN          sc_base.h
  11737.  
  11738.             DESCRIPTION           scdwrget reads the desired record
  11739.                       "recno" from the memo file specified by "handle".
  11740.  
  11741.  
  11742.  
  11743.             172                 SoftC Database Library
  11744.  
  11745.  
  11746.  
  11747.  
  11748.  
  11749.  
  11750.  
  11751.  
  11752.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11753.  
  11754.  
  11755.                       A buffer large enough to hold the text will be
  11756.                       allocated, the address of which is returned in
  11757.                       "data".
  11758.  
  11759.             RETURN VALUES         SC_SUCCESS   memo record read
  11760.                       successfully
  11761.                       SC_RDFAIL   file read failure
  11762.                       SC_MEMERR   memory allocation error
  11763.                       SC_SKFAIL   file pointer reposition failed
  11764.                       SC_BADHNDL  invalid handle number
  11765.                       SC_NULLPARM parameter address NULL
  11766.  
  11767.              SEE ALSO scdwrget.
  11768.  
  11769.               EXAMPLE #include <stdio.h>
  11770.                       #include <softc.h>
  11771.                       #include <sc_base.h>
  11772.  
  11773.                       void main()
  11774.                       {
  11775.                         int fpt;
  11776.                         char *data,*memo="TOC.FPT";
  11777.  
  11778.                         scdinit(20,0);
  11779.                         if (scdwopenx(&fpt,memo,SC_SHARED)==SC_SUCCESS)
  11780.                       {
  11781.                           scdwrget(fpt,1L,&data,SC_CRDELETE);
  11782.                           puts(data);
  11783.                           free(data);
  11784.                           scddclose(fpt);
  11785.                         }
  11786.                         scdterm();
  11787.                       }
  11788.  
  11789.  
  11790.             scdwrput__________________________________
  11791.  
  11792.                            USAGE     int scdwrput(
  11793.                       int handle,
  11794.                       long *recno,
  11795.                       char *data,
  11796.                       int command );
  11797.  
  11798.             PROTOTYPE IN          sc_base.h
  11799.  
  11800.             DESCRIPTION           scdwrput writes "data" to the memo
  11801.                       file specified by "handle". The record number
  11802.                       written is returned in "recno". This record number
  11803.                       must be then written to the data output buffer via
  11804.                       a call to scddfput. This function assumes that
  11805.  
  11806.  
  11807.  
  11808.  
  11809.             User's Reference Guide                 173
  11810.  
  11811.  
  11812.  
  11813.  
  11814.  
  11815.  
  11816.  
  11817.  
  11818.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11819.  
  11820.  
  11821.                       "data" is an ASCIIZ string with a maximum length
  11822.                       of 65,536 characters.
  11823.  
  11824.                       Unlike dBASE III memo files which appends all
  11825.                       writes at end of the file, FoxPro allows updating
  11826.                       an existing memo in place. command determines how
  11827.                       the memo text is written:
  11828.  
  11829.  
  11830.  
  11831.  
  11832.                       SC_ADD      append to end of file
  11833.  
  11834.  
  11835.                       SC_UPDATE   update current record
  11836.  
  11837.             RETURN VALUES         SC_SUCCESS   record written
  11838.                       successfully
  11839.                       SC_WRTFAIL  file write failure
  11840.                       SC_SKFAIL   file pointer reposition failed
  11841.                       SC_BADHNDL  invalid handle number
  11842.                       SC_NULLPARM parameter address NULL
  11843.  
  11844.              SEE ALSO scdwrput.
  11845.  
  11846.               EXAMPLE #include <stdio.h>
  11847.                       #include <softc.h>
  11848.                       #include <sc_base.h>
  11849.  
  11850.                       void main()
  11851.                       {
  11852.                         int fpt;
  11853.                         char data[512],*memo="TOC.FPT";
  11854.                         long recno;
  11855.  
  11856.                         scdinit(20,0);
  11857.                         if (scdwopenx(&fpt,memo,SC_BUFFER)==SC_SUCCESS)
  11858.                       {
  11859.                           strcpy(data,"hello world.");
  11860.                           scdwrput(fpt,&recno,data,SC_ADD);
  11861.                           printf("%ld",recno);
  11862.                           scddclose(fpt);
  11863.                         }
  11864.                         scdterm();
  11865.                       }
  11866.  
  11867.  
  11868.             sceclr____________________________________
  11869.  
  11870.                            USAGE     void sceclr( void );
  11871.  
  11872.  
  11873.  
  11874.  
  11875.             174                 SoftC Database Library
  11876.  
  11877.  
  11878.  
  11879.  
  11880.  
  11881.  
  11882.  
  11883.  
  11884.                  CHAPTER 8, THE SOFTC DATABASE LIBRARY
  11885.  
  11886.  
  11887.              MACRO IN softc.h
  11888.  
  11889.             DESCRIPTION           sceclr is a macro which expands to
  11890.                       "sc_code = SC_SUCCESS".  The SoftC Database
  11891.                       Library error flag (sc_code) will be cleared.
  11892.  
  11893.              SEE ALSO scemsg.
  11894.  
  11895.               EXAMPLE #include <stdio.h>
  11896.                       #include <softc.h>
  11897.                       #include <sc_base.h>
  11898.  
  11899.                       void main()
  11900.                       {
  11901.                         int dbt;
  11902.                         char data[512],*memo="TOC.DBT";
  11903.                         long recno;
  11904.  
  11905.                         scdinit(20,0);
  11906.                         if (scdtopenx(&dbt,memo,SC_BUFFER)<SC_SUCCESS) {
  11907.                           sceclr();
  11908.                           scdtcreate("TOC.DBT");
  11909.                           scdtopenx(&dbt,memo,SC_BUFFER);
  11910.                         }
  11911.                           .
  11912.                           .
  11913.                           .
  11914.                         scddclose(dbt);
  11915.                         scdterm();
  11916.                       }
  11917.  
  11918.  
  11919.             scemsg____________________________________
  11920.  
  11921.                            USAGE     char *scemsg( void );
  11922.  
  11923.             PROTOTYPE IN          softc.h
  11924.  
  11925.             DESCRIPTION           scemsg returns a pointer to the SoftC
  11926.                       Database Library error or warning message which
  11927.                       corresponds to the code found in sc_code.  Refer
  11928.                       to Appendix A for more information on error and
  11929.                       warning codes.
  11930.  
  11931.              SEE ALSO sceclr.
  11932.  
  11933.               EXAMPLE #include <stdio.h>
  11934.                       #include <softc.h>
  11935.                       #include <sc_base.h>
  11936.  
  11937.                       void main()
  11938.  
  11939.  
  11940.  
  11941.             User's Reference Guide                 175
  11942.  
  11943.  
  11944.  
  11945.  
  11946.  
  11947.  
  11948.  
  11949.  
  11950.             CHAPTER 8, THE SOFTC DATABASE LIBRARY     
  11951.  
  11952.  
  11953.                       {
  11954.                         int dbf;
  11955.  
  11956.                         scdinit(20,0);
  11957.                         if (scddopenx(&dbf,"TOC.DBF",0)!=SC_SUCCESS)
  11958.                           puts(scemsg());
  11959.                         scdterm();
  11960.                       }
  11961.  
  11962.  
  11963.  
  11964.  
  11965.  
  11966.  
  11967.  
  11968.  
  11969.  
  11970.  
  11971.  
  11972.  
  11973.  
  11974.  
  11975.  
  11976.  
  11977.  
  11978.  
  11979.  
  11980.  
  11981.  
  11982.  
  11983.  
  11984.  
  11985.  
  11986.  
  11987.  
  11988.  
  11989.  
  11990.  
  11991.  
  11992.  
  11993.  
  11994.  
  11995.  
  11996.  
  11997.  
  11998.  
  11999.  
  12000.  
  12001.  
  12002.  
  12003.  
  12004.  
  12005.  
  12006.  
  12007.             176                 SoftC Database Library
  12008.  
  12009.  
  12010.  
  12011.  
  12012.  
  12013.  
  12014.  
  12015.  
  12016.  
  12017.  
  12018.  
  12019.             Appendix A
  12020.  
  12021.  
  12022.             Result Codes and Messages
  12023.  
  12024.  
  12025.  
  12026.  
  12027.             Warning Codes and Messages
  12028.  
  12029.             SC_DELREC     1     "WARNING - record read is marked
  12030.                                 deleted"
  12031.  
  12032.             The data  file record just read was flagged as "inactive" or
  12033.             "deleted". dBASE  retains "deleted"  records until  the data
  12034.             file is packed.
  12035.  
  12036.  
  12037.             SC_EMPTY      2     "WARNING - file is empty"
  12038.  
  12039.             You have  attempted to  read from an index file which has no
  12040.             keys (is empty).
  12041.  
  12042.  
  12043.             SC_END        3     "WARNING - no more keys"
  12044.  
  12045.             The current  key pointer  is located  at the physical end of
  12046.             the index  file, either at the first key or at the last key.
  12047.             The actual position depends upon the function called.
  12048.  
  12049.  
  12050.             SC_NOFIND     4     "WARNING - could not find key in index
  12051.                                 file"
  12052.  
  12053.             The index key supplied to the function could not be found in
  12054.             the index  file. Make sure that the index key is being built
  12055.             properly.
  12056.  
  12057.  
  12058.             SC_FLDTRUNC   5     "WARNING - data field truncated"
  12059.  
  12060.             The length  of the  data supplied  is larger  than the space
  12061.             allocated for  the field  in  the  data  file  record.  This
  12062.             usually occurs only with character type fields.
  12063.  
  12064.  
  12065.             SC_FLDROUND   6     "WARNING - numeric field rounded"
  12066.  
  12067.             Numeric data  is not  stored in  the data record in floating
  12068.             point format,  rather it  is converted  to  ASCII  and  then
  12069.             stored complete  with a  decimal point. If the numeric value
  12070.  
  12071.  
  12072.  
  12073.             User's Reference Guide                 177
  12074.  
  12075.  
  12076.  
  12077.  
  12078.  
  12079.  
  12080.  
  12081.  
  12082.             APPENDIX A, RESULT CODES AND MESSAGES     
  12083.  
  12084.  
  12085.             desired to  be written  is more  precise than  space in  the
  12086.             field permits,  the data  will be  rounded and  this warning
  12087.             returned.
  12088.  
  12089.  
  12090.             SC_FILENGTH   7     "WARNING - file length is incorrect"
  12091.  
  12092.             After data,  index, or memo files are opened, the calculated
  12093.             file length is compared to the actual length. If they do not
  12094.             agree this  code is  returned. This  warning will occur most
  12095.             frequently with data files.
  12096.  
  12097.  
  12098.             SC_NOTBFRD    8     "WARNING - I/O not buffered"
  12099.  
  12100.             An attempt  was made  to flush  data to a file which was not
  12101.             opened with  buffering enabled.  Check how the data or index
  12102.             file was  opened. It  should be  opened using  the SC_BUFFER
  12103.             switch, not  SC_FLUSH. See "scd?openx" function descriptions
  12104.             for more information.
  12105.  
  12106.  
  12107.             SC_MEMWRN     9     "WARNING - memory allocation incomplete"
  12108.  
  12109.             The file manager has been unsuccessful in allocating all the
  12110.             memory requested.   This  failure could  be caused  by  many
  12111.             things:  not   enough  memory   available,  memory   threads
  12112.             corrupted, using  a null  pointer, ...  Check your  code  to
  12113.             ensure that  you do not have a problem in this area. You may
  12114.             need to use a larger data model.
  12115.  
  12116.  
  12117.             SC_NOFUNC     10    "WARNING - function not supported"
  12118.  
  12119.             ANSI C  does not  define functions  to  perform  file/record
  12120.             locks, and  changing the  length of a file.  These functions
  12121.             are no-op'd.
  12122.  
  12123.  
  12124.             Error Codes and Messages
  12125.  
  12126.             SC_WRTFAIL    -1    "ERROR - file write failure"
  12127.  
  12128.             This indicates  an incomplete  file write.  The disk  may be
  12129.             full.
  12130.  
  12131.  
  12132.             SC_RDFAIL     -2    "ERROR - file read failure"
  12133.  
  12134.             This indicates an incomplete read.
  12135.  
  12136.  
  12137.  
  12138.  
  12139.             178                 SoftC Database Library
  12140.  
  12141.  
  12142.  
  12143.  
  12144.  
  12145.  
  12146.  
  12147.  
  12148.                  APPENDIX A, RESULT CODES AND MESSAGES
  12149.  
  12150.  
  12151.             SC_MEMERR     -3    "ERROR - memory allocation error"
  12152.  
  12153.             An attempt  to allocate  memory  by  the  file  manager  has
  12154.             failed. This  failure could  be caused  by many  things: not
  12155.             enough memory  available, memory  threads corrupted, using a
  12156.             null pointer,  ... Check your code to ensure that you do not
  12157.             have a  problem in this area. You may have to go to a larger
  12158.             data model.
  12159.  
  12160.  
  12161.             SC_SKFAIL     -4    "ERROR - file pointer reposition failed"
  12162.  
  12163.             This error  is returned under two circumstances: actual seek
  12164.             failed or  an attempt was made to seek beyond the end of the
  12165.             file in  a function intending to read after seek. You should
  12166.             verify the  record number  (for either  data, index, or memo
  12167.             files) being requested is legitimate.
  12168.  
  12169.  
  12170.             SC_NOFILE     -5    "ERROR - file not found"
  12171.  
  12172.             You have attempted to open a data, index, or memo file which
  12173.             cannot be  found. If  you are certain the file exists, check
  12174.             the path specification.
  12175.  
  12176.  
  12177.             SC_FILBAD     -6    "ERROR - file corrupted"
  12178.  
  12179.             The file  manager has noticed something seriously wrong with
  12180.             the index  file. Close  and reopen the file, it may still be
  12181.             good. Otherwise you will have to rebuild the index file.
  12182.  
  12183.  
  12184.             SC_BADEXPR    -7    "ERROR - bad user specified key
  12185.                                 expression"
  12186.  
  12187.             This indicates  an error  either  with  the  length  or  the
  12188.             contents of the expression. The length can be no larger than
  12189.             220 characters.  See scdnkmake for more information on valid
  12190.             expression content.
  12191.  
  12192.  
  12193.             SC_NOHNDL     -8    "ERROR - no handles available"
  12194.  
  12195.             Either DOS  or the  file manager  has no  more  unused  file
  12196.             handles. Each  DOS application  is allowed to have a maximum
  12197.             of twenty files open (up to the total defined by "FILES=" in
  12198.             "CONFIG.SYS"). Five of these files are reserved for console,
  12199.             printer, etc.  which leaves  only fifteen available for you.
  12200.             scdinit can  be used  to specify the maximum number of SoftC
  12201.             Database Library files which can be open simultaneously.
  12202.  
  12203.  
  12204.  
  12205.             User's Reference Guide                 179
  12206.  
  12207.  
  12208.  
  12209.  
  12210.  
  12211.  
  12212.  
  12213.  
  12214.             APPENDIX A, RESULT CODES AND MESSAGES     
  12215.  
  12216.  
  12217.             SC_NOPGS      -9    "ERROR - no index pages loaded"
  12218.  
  12219.             This is  an internal  file manager  error which should never
  12220.             occur. Contact SoftC, Ltd. if you get this error.
  12221.  
  12222.  
  12223.             SC_BADPG      -10   "ERROR - index page was not loaded"
  12224.  
  12225.             This is  an internal  file manager  error which should never
  12226.             occur. Contact SoftC, Ltd. if you get this error.
  12227.  
  12228.  
  12229.             SC_CLOSFAIL   -11   "ERROR - file close failure"
  12230.  
  12231.             This indicates  that DOS  could not properly close the file.
  12232.             Check errno for help in isolating further.
  12233.  
  12234.  
  12235.             SC_BADCMD     -12   "ERROR - invalid command"
  12236.  
  12237.             This error is a general purpose indicator. It means that the
  12238.             I/O buffer  selected, date  string translation  format, data
  12239.             file record  write type, or maximum number of resident index
  12240.             pages was invalid depending upon the function executed.
  12241.  
  12242.  
  12243.             SC_BADHNDL    -13   "ERROR - invalid handle number"
  12244.  
  12245.             The file  handle does  not match  the function required file
  12246.             type or  there is  no file open for that handle. For example
  12247.             this will  occur when using an index file handle with a data
  12248.             file function.
  12249.  
  12250.  
  12251.             SC_BADFNAME   -14   "ERROR - invalid filename"
  12252.  
  12253.             The length  of the  file name  was zero or the file name was
  12254.             invalid in  some other  way. The  file manager  expects file
  12255.             names to  be complete  with an  extension.  File  paths  are
  12256.             optional.
  12257.  
  12258.  
  12259.             SC_BADDATE    -15   "ERROR - invalid date"
  12260.  
  12261.             The year,  month, and/or day was invalid. Verify the date is
  12262.             correct.
  12263.  
  12264.  
  12265.  
  12266.  
  12267.  
  12268.  
  12269.  
  12270.  
  12271.             180                 SoftC Database Library
  12272.  
  12273.  
  12274.  
  12275.  
  12276.  
  12277.  
  12278.  
  12279.  
  12280.                  APPENDIX A, RESULT CODES AND MESSAGES
  12281.  
  12282.  
  12283.             SC_BADTIME    -16   "ERROR - invalid time"
  12284.  
  12285.             The hour, minute, and/or second was invalid. Verify the time
  12286.             is correct.
  12287.  
  12288.  
  12289.             SC_NODBT      -17   "ERROR - file not in .DBT format"
  12290.  
  12291.             The memo  file length  was too  short. This  file cannot  be
  12292.             used.
  12293.  
  12294.  
  12295.             SC_DBFVERS    -18   "ERROR - invalid dBASE version"
  12296.  
  12297.             The dBASE  version  number  in  the  data  file  header  was
  12298.             unsupported. Only  dBASEIII, dBASEIII+, and dBASEIV versions
  12299.             are valid. This file cannot be used.
  12300.  
  12301.  
  12302.             SC_DBFHLEN    -19   "ERROR - file header length error"
  12303.  
  12304.             The length  of the  dBASE header  was invalid. The length of
  12305.             the header  must be  divisible by  32 with  a  remainder  of
  12306.             either 0 or 1. This file cannot be used.
  12307.  
  12308.  
  12309.             SC_DBFDATE    -20   "ERROR - last file change date in error"
  12310.  
  12311.             The data  file header  last modified  date was invalid. This
  12312.             file cannot be used.
  12313.  
  12314.  
  12315.             SC_NULLPARM   -21   "ERROR - parameter address null"
  12316.  
  12317.             The address  of a parameter is NULL. Check the parameters on
  12318.             the call to ensure they are correct.
  12319.  
  12320.  
  12321.             SC_BADKEYT    -22   "ERROR - invalid key type"
  12322.  
  12323.             The selected  key type  is invalid  for the index file type.
  12324.             Refer  to   scd?create  for  further  information  regarding
  12325.             allowable key types.
  12326.  
  12327.  
  12328.             SC_KEYLEN     -23   "ERROR - invalid key length"
  12329.  
  12330.             The character  key maximum  length  definition  exceeds  100
  12331.             characters. This  error does not occur for numeric (or date)
  12332.             keys.
  12333.  
  12334.  
  12335.  
  12336.  
  12337.             User's Reference Guide                 181
  12338.  
  12339.  
  12340.  
  12341.  
  12342.  
  12343.  
  12344.  
  12345.  
  12346.             APPENDIX A, RESULT CODES AND MESSAGES     
  12347.  
  12348.  
  12349.             SC_ITEMLEN    -24   "ERROR - item length incorrect"
  12350.  
  12351.             The file  manager index  key item  length not agree with the
  12352.             value read from the index file. This file cannot be used.
  12353.  
  12354.  
  12355.             SC_BADROOT    -25   "ERROR - invalid root page"
  12356.  
  12357.             The index  page number  for the  top of  the Btree  does not
  12358.             exist in the index file. This file cannot be used.
  12359.  
  12360.  
  12361.             SC_MAXKEYS    -26   "ERROR - bad maximum number of keys per
  12362.                                 page"
  12363.  
  12364.             The file manager maximum number of index keys per index page
  12365.             does not agree with the value read from the index file. This
  12366.             file cannot be used.
  12367.  
  12368.  
  12369.             SC_FLDCNT     -27   "ERROR - invalid number of fields"
  12370.  
  12371.             A  data  file  record  can  consist  of  a  maximum  of  128
  12372.             individual fields for dBASE III or 255 for dBASE IV.
  12373.  
  12374.  
  12375.             SC_BADFLDN    -28   "ERROR - field name invalid"
  12376.  
  12377.             The field  name length  cannot  exceed  ten  characters  not
  12378.             including the null bye.
  12379.  
  12380.  
  12381.             SC_FLDLEN     -29   "ERROR - bad field length"
  12382.  
  12383.             Character fields  cannot be longer than 254 bytes. dBASE III
  12384.             numeric fields  cannot be  longer than  19 bytes.  dBASE  IV
  12385.             numeric and  float fields  cannot be  longer than  20 bytes.
  12386.             This error will not occur for the other field types.
  12387.  
  12388.  
  12389.             SC_DECPL      -30   "ERROR - decimal places parameter
  12390.                                 invalid"
  12391.  
  12392.             The  decimal   places  definition   portion  of   the  field
  12393.             description cannot be less than 0 nor can it be greater than
  12394.             the field length minus two.
  12395.  
  12396.  
  12397.  
  12398.  
  12399.  
  12400.  
  12401.  
  12402.  
  12403.             182                 SoftC Database Library
  12404.  
  12405.  
  12406.  
  12407.  
  12408.  
  12409.  
  12410.  
  12411.  
  12412.                  APPENDIX A, RESULT CODES AND MESSAGES
  12413.  
  12414.  
  12415.             SC_BADFLDT    -31   "ERROR - invalid field type"
  12416.  
  12417.             Only character ('C'), date ('D'), logical ('L'), memo ('M'),
  12418.             and  numeric   ('N')  are   allowed  in   dBASE  III  files.
  12419.             Additionally, dBASE IV supports a floating point ('F') field
  12420.             type.
  12421.  
  12422.  
  12423.             SC_RECLEN     -32   "ERROR - invalid record length"
  12424.  
  12425.             The record length cannot exceed 4000 bytes. Check your field
  12426.             lengths and make sure that they total 4000 or less.
  12427.  
  12428.  
  12429.             SC_BADDATA    -33   "ERROR - bad data"
  12430.  
  12431.             The data  you requested  to be written into a data field was
  12432.             invalid. For  example a pointer to a floating point variable
  12433.             was passed  for a  character field.  Ensure  the  data  type
  12434.             passed matches the field definition.
  12435.  
  12436.  
  12437.             SC_LINELEN    -34   "ERROR - memo soft line length invalid"
  12438.  
  12439.             Valid values for line lengths are 0, and between 10 and 132.
  12440.             The line  length parameter  is used when the file manager is
  12441.             inserting soft  carriage returns  in  memo  text  as  it  is
  12442.             written to the memo file.
  12443.  
  12444.  
  12445.             SC_MDXFLAG    -35   "ERROR - MDX flag in DBF file invalid"
  12446.  
  12447.             The value  found in  byte twenty  eight (28)  of the dBASEIV
  12448.             data file  is not valid. Only values of zero (0) and one (1)
  12449.             are currently supported. This may indicate a corrupted file.
  12450.  
  12451.  
  12452.             SC_READOLY    -36   "ERROR - file open for reading only"
  12453.  
  12454.             An attempt  was made  to execute  a write function to a file
  12455.             opened for reading only. Check the switches used to open the
  12456.             file.
  12457.  
  12458.  
  12459.             SC_LCKVIOL    -37   "ERROR - file locking violation"
  12460.  
  12461.             This  only   occurs  when   sharing  files.  There  are  two
  12462.             situations when  this error  is returned:  1) attempting  to
  12463.             lock a record/file that is already locked, and 2) attempting
  12464.             to unlock a record/file which is not currently locked.
  12465.  
  12466.  
  12467.  
  12468.  
  12469.             User's Reference Guide                 183
  12470.  
  12471.  
  12472.  
  12473.  
  12474.  
  12475.  
  12476.  
  12477.  
  12478.             APPENDIX A, RESULT CODES AND MESSAGES     
  12479.  
  12480.  
  12481.             SC_LCKBOVR    -38   "ERROR - sharing buffer overflow"
  12482.  
  12483.             This is  an internal  file manager  error which should never
  12484.             occur. Contact SoftC, Ltd. if you get this error.
  12485.  
  12486.  
  12487.             SC_NOPATH     -39   "ERROR - path not found"
  12488.  
  12489.             The path  specified in  the file  open command  could not be
  12490.             found. Make sure the path is correct.
  12491.  
  12492.  
  12493.             SC_ACCDEN     -40   "ERROR - access to file denied"
  12494.  
  12495.             This error  occurs only  when sharing  files. The file could
  12496.             not be  accessed. This  can occur if another station has the
  12497.             file opened in SC_EXCLUDE mode.
  12498.  
  12499.  
  12500.             SC_BADACC     -41   "ERROR - invalid access code"
  12501.  
  12502.             This is  an internal  file manager  error which should never
  12503.             occur. Contact SoftC, Ltd. if you get this error.
  12504.  
  12505.  
  12506.             SC_NOTLCKD    -42   "ERROR - file must be locked first"
  12507.  
  12508.             This error  occurs only when sharing files. The file must be
  12509.             locked before executing this function.
  12510.  
  12511.  
  12512.             SC_NEWDEV     -43   "ERROR - diskette changed"
  12513.  
  12514.             DOS believes that the diskette has been changed.
  12515.  
  12516.  
  12517.             SC_MINKEYS    -44   "ERROR - bad minimum number of keys per
  12518.                                 page"
  12519.  
  12520.             The value found in the minimum number of keys per page field
  12521.             was incorrect.  This  error  can  occur  only  when  opening
  12522.             Clipper index files. This may indicate a corrupted file.
  12523.  
  12524.  
  12525.             SC_FILSOPEN   -45   "ERROR - some files remain open"
  12526.  
  12527.             This error  is returned  by scdterm. In order for this error
  12528.             to occur,  scdinit must  have been  called with  SC_USEXHNDL
  12529.             switch and  the "files parameter is greater than twenty. The
  12530.             error indicates  that a  file  handle  above  nineteen  (19)
  12531.             remains open  after all  SoftC files  have been closed. Make
  12532.  
  12533.  
  12534.  
  12535.             184                 SoftC Database Library
  12536.  
  12537.  
  12538.  
  12539.  
  12540.  
  12541.  
  12542.  
  12543.  
  12544.                  APPENDIX A, RESULT CODES AND MESSAGES
  12545.  
  12546.  
  12547.             sure that  all of  your  files  are  closed  before  calling
  12548.             scdterm.
  12549.  
  12550.  
  12551.             SC_OPENFAIL   -46   "ERROR - could not open the file"
  12552.  
  12553.             Error code  added for  ANSI C  support.    The  error  codes
  12554.             available under  ANSI C fopen do not fully define the reason
  12555.             for the failure.  This is a catch-all error code.
  12556.  
  12557.  
  12558.             SC_FLSHFAIL   -47   "ERROR - flush to disk failure"
  12559.  
  12560.             Error code  added for  ANSI C  support.    The  error  codes
  12561.             available under ANSI C fflush do not fully define the reason
  12562.             for the failure.  This is a catch-all error code.
  12563.  
  12564.  
  12565.             SC_BADTAG     -48   "ERROR - invalid tag handle"
  12566.  
  12567.             Error code  added for  dBASE IV multiple index file support.
  12568.             Index tag name supplied was not in file.
  12569.  
  12570.  
  12571.             SC_BLKSZ      -49   "ERROR - invalid block size"
  12572.  
  12573.             Error code  added for  dBASE IV multiple index and memo file
  12574.             support. The  block size supplied to the create function was
  12575.             invalid.
  12576.  
  12577.  
  12578.             SC_BADTNAME   -50   "ERROR - invalid tag name"
  12579.  
  12580.             Error code  added for  dBASE IV multiple index file support.
  12581.             The index  tag name  was improperly  formatted (zero length,
  12582.             too long).
  12583.  
  12584.  
  12585.             SC_BLKADR     -51   "ERROR - invalid block adder size"
  12586.  
  12587.             Error code  added for  dBASE IV multiple index and memo file
  12588.             support. The byte block adder was invalid.
  12589.  
  12590.  
  12591.             SC_MAXTAGS    -52   "ERROR - invalid maximum number of tags"
  12592.  
  12593.             Error code  added for  dBASE IV multiple index file support.
  12594.             The maximum  number of  tag table  elements is invalid (0 or
  12595.             greater than 48).
  12596.  
  12597.  
  12598.  
  12599.  
  12600.  
  12601.             User's Reference Guide                 185
  12602.  
  12603.  
  12604.  
  12605.  
  12606.  
  12607.  
  12608.  
  12609.  
  12610.             APPENDIX A, RESULT CODES AND MESSAGES     
  12611.  
  12612.  
  12613.             SC_TBLELEN    -53   "ERROR - bad tag table element length"
  12614.  
  12615.             Error code  added for  dBASE IV multiple index file support.
  12616.             The tag table element length was not equal to 32.
  12617.  
  12618.  
  12619.             SC_TAGCNT     -54   "ERROR - invalid tag count"
  12620.  
  12621.             Error code  added for  dBASE IV multiple index file support.
  12622.             Tag count was less than 1 or greater than 48.
  12623.  
  12624.  
  12625.             SC_KEYFORM    -55   "ERROR - unknown key format switches"
  12626.  
  12627.             Error code  added for  dBASE IV multiple index file support.
  12628.             File error.
  12629.  
  12630.  
  12631.             SC_UNSWITCH   -56   "ERROR - unknown switch error"
  12632.  
  12633.             Error code  added for  dBASE IV multiple index and memo file
  12634.             support. File error.
  12635.  
  12636.  
  12637.             SC_TAGOPEN    -57   "ERROR - tag in use"
  12638.  
  12639.             Error code  added for  dBASE IV multiple index file support.
  12640.             Tag already open.
  12641.  
  12642.  
  12643.             Other Messages
  12644.  
  12645.             "Unknown error or warning code"
  12646.  
  12647.             This message  is returned  by scemsg  if it  cannot  find  a
  12648.             message which corresponds to the value found in sc_code. The
  12649.             function scemsg  may be  old or  otherwise incompatible with
  12650.             the value found in sc_code.
  12651.  
  12652.  
  12653.  
  12654.  
  12655.  
  12656.  
  12657.  
  12658.  
  12659.  
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665.  
  12666.  
  12667.             186                 SoftC Database Library
  12668.  
  12669.  
  12670.  
  12671.  
  12672.  
  12673.  
  12674.  
  12675.  
  12676.  
  12677.  
  12678.  
  12679.             Appendix B
  12680.  
  12681.  
  12682.             Diskette TOC Demo Program
  12683.  
  12684.  
  12685.  
  12686.  
  12687.             The Diskette  TOC Program  is a  simple program  which  will
  12688.             create a  database (TOC.DBF)  and  three  index  files.  The
  12689.             database record contains the following fields:
  12690.  
  12691.  
  12692.             field name  type  length description
  12693.             __________________________________________
  12694.             NAME        C     64     file name
  12695.             LENGTH      N     10.0   file size in bytes
  12696.             DATE        D     8      file creation date
  12697.             TIME        C     8      file creation time
  12698.             ATTRIBUTE   C     3      file attribute (READ ONLY, HIDDEN)
  12699.  
  12700.  
  12701.             The index  files created  are: TOCNAME (file name), TOCLNGTH
  12702.             (file length), and TOCDATE (file creation date and time).
  12703.  
  12704.  
  12705.             The  program   uses  the   DOS  functions   "findfirst"  and
  12706.             "findnext" to  step through  the files  in the directory. It
  12707.             reformats the  compressed file  date ("mm/dd/yy")  and  time
  12708.             ("hh:mm:ss") and  places the  resultant data into the output
  12709.             buffer. After  all fields have been entered it will append a
  12710.             record to the end of the database and add keys for each file
  12711.             found.   After all  records have been added, the contents of
  12712.             the data  file are  displayed in  the filename  order  using
  12713.             index file TOCNAME.
  12714.  
  12715.  
  12716.             The program only works on the current directory. It does not
  12717.             support any  command line  arguments, although  it would  be
  12718.             easy for  the user  to add  such support.  Very little error
  12719.             checking is performed.
  12720.  
  12721.  
  12722.             The program as it stands has value only in the demonstration
  12723.             of certain library functions:
  12724.  
  12725.  
  12726.             scdinit,      scdterm,      scddclose,
  12727.             scddcreate,   scddopenx,    scddfget,
  12728.             scddfput,     scddrget,     scdrput,
  12729.  
  12730.  
  12731.  
  12732.  
  12733.             User's Reference Guide                 187
  12734.  
  12735.  
  12736.  
  12737.  
  12738.  
  12739.  
  12740.  
  12741.  
  12742.             APPENDIX B, DISKETTE TOC DEMO PROGRAM     
  12743.  
  12744.  
  12745.             scd?create,   scd?openx,    scd?kadd,
  12746.             scd?kmake,    scd?knext,    scd?ktop
  12747.  
  12748.  
  12749.             However, it could form the basis of a diskette cataloger, or
  12750.             ...
  12751.  
  12752.  
  12753.  
  12754.  
  12755.  
  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.             188                 SoftC Database Library
  12800.  
  12801.  
  12802.  
  12803.  
  12804.  
  12805.  
  12806.  
  12807.  
  12808.                                        Index
  12809.  
  12810.  
  12811.                                                  to integers  39
  12812.             Data                                   long  35
  12813.               field                              to long  40
  12814.                 array  80, 86                      integer  31
  12815.                 read                             to month
  12816.                   memo  165, 172                   string  41
  12817.                   strings  85                    to string
  12818.                   values  83                       day of week  43
  12819.                 write                              integers  31
  12820.                   memo  166, 173                   long  36
  12821.                   strings  91                      month  47
  12822.                   values  89                       string  42
  12823.               file
  12824.                 close  79                    Functions
  12825.                 create  80                     sccdi2l  21, 31, 36
  12826.                 flush  88                      sccdi2s  21, 31, 40, 45
  12827.                 I/O buffer clear  98           sccdiget  22, 32, 46
  12828.                 I/O cache  77                  sccdileap  22, 33, 47
  12829.                 information  93                sccdiperm  22, 34, 49
  12830.                 last update  95                sccdl2dow  22, 35
  12831.                 lock file  94                  sccdl2i  21, 31, 35
  12832.                 lock record  102               sccdl2sx  21, 36
  12833.                 number of records  109         sccds2day  22, 37, 39, 42
  12834.                 open  96                       sccds2dow  22, 35, 38
  12835.                 pack  97                       sccds2i  21, 32, 39
  12836.                 position  78, 82, 103          sccds2lx  21, 37, 40
  12837.                 read header  92                sccds2mon  22, 41
  12838.                 record                         sccds2s  21, 42, 45
  12839.                   status  107                  sccdsday  22, 43, 48
  12840.                 unlock  110                    sccdsdiff  22, 44
  12841.               record                           sccdsget  22, 33, 45
  12842.                 delete  99                     sccdsleap  22, 34, 46
  12843.                 read  99, 100                  sccdsmonth  22, 44, 47
  12844.                 recover  108                   sccdsperm  22, 34, 48
  12845.                 write  104, 105                sccdsvalid  22, 32, 45,
  12846.                                                    49
  12847.             Date                               sccdxlat  42
  12848.               calculate                        sccti2s  22, 50, 52, 54
  12849.                 days per month  34, 48         scctiget  23, 51
  12850.                 difference  44                 sccts2i  22, 51, 52
  12851.               get from DOS                     scctsdiff  23, 53
  12852.                 integers  32                   scctsget  23, 46, 54
  12853.                 string  45                     scctsvalid  23, 51, 54,
  12854.               test                                 55
  12855.                 leap year  33, 46              scdcbfrsz  56
  12856.                 valid  49                      scdcclose  57
  12857.               translate                        scdccreate  58, 62, 72
  12858.                 to day of week                 scdcexpr  59
  12859.                   integer  37                  scdcflush  60
  12860.                   long  35                     scdchget  62
  12861.                   string  38                   scdcindex  61
  12862.  
  12863.  
  12864.  
  12865.             User's Reference Manual                189
  12866.  
  12867.  
  12868.  
  12869.  
  12870.  
  12871.  
  12872.  
  12873.  
  12874.             INDEX                                     
  12875.  
  12876.  
  12877.               scdcinfo  59, 63, 67, 68,        scddrput  16, 100, 104,
  12878.                   70, 73, 74, 75                   107
  12879.               scdckadd  65, 69                 scddrputx  101, 105
  12880.               scdckbot  66, 68                 scddrstat  17, 107
  12881.               scdckcur  67, 68                 scddrundel  16, 99, 108
  12882.               scdckdel  68                     scddsize  15, 109
  12883.               scdckfind  68, 69                scddunlock  18, 26, 95,
  12884.               scdckmake  59, 66, 71                103, 110
  12885.               scdcknext  68, 73                scdibfrsz  111
  12886.               scdckprev  68, 74                scdiclose  112
  12887.               scdcktop  68, 75                 scdicreate  112, 128, 130
  12888.               scdcopenx  60, 64, 76            scdiexpr  114
  12889.               scddbfrsz  16, 77                scdiflush  115
  12890.               scddbof  15, 78, 83, 104         scdihget  116
  12891.               scddclose  15, 79                scdiindex  117
  12892.               scddcreate  15, 17, 80,          scdiinfo  114, 118, 121,
  12893.                   82                               122, 125, 126, 129,
  12894.               scddeof  15, 79, 82, 104             131, 132, 133
  12895.               scddfget  17, 24, 83, 85,        scdikadd  119, 124
  12896.                   91, 100, 101                 scdikbot  120, 121, 122
  12897.               scddfgets  17, 84, 85,           scdikcur  121
  12898.                   91, 92                       scdikdate  120, 122, 128,
  12899.               scddfinfo  17, 84, 85, 86            130
  12900.               scddflush  16, 88                scdikdel  123
  12901.               scddfnam2no  17, 88              scdikfind  121, 122, 124
  12902.               scddfput  17, 18, 24, 84,        scdikmake  113, 114, 120,
  12903.                   89, 91, 92, 100, 101,            123, 126, 130
  12904.                   105, 106, 107, 166,          scdiknext  121, 122, 128
  12905.                   173                          scdiknum  20, 120, 123,
  12906.               scddfputs  17, 85, 91,               128, 130
  12907.                   105, 106, 107                scdikprev  121, 122, 131
  12908.               scddhget  92                     scdiktop  121, 122, 132
  12909.               scddinfo  15, 93                 scdinit  3, 8, 24, 134,
  12910.               scddlock  18, 26, 62, 92,            161, 179, 185
  12911.                   94, 103, 110, 117,           scdiopenx  116, 119, 134
  12912.                   141, 162, 169                scdnbfrsz  19, 136
  12913.               scddlud  15, 95                  scdnclose  19, 137
  12914.               scddopenx  15, 78, 80,           scdncreate  19, 137, 152
  12915.                   88, 93, 95, 96, 97,          scdnexpr  19, 138
  12916.                   98, 103, 110                 scdnflush  19, 139
  12917.               scddpack  16, 97, 165,           scdnhget  140
  12918.                   172                          scdnindex  19, 98, 141
  12919.               scddrclear  16, 98               scdninfo  19, 139, 142,
  12920.               scddrdel  16, 99, 109                145, 146, 150, 153,
  12921.               scddrget  16, 84, 85, 99,            154, 155, 156, 157
  12922.                   101, 105, 107                scdnkadd  20, 143, 149
  12923.               scddrgetx  100, 106, 107         scdnkbot  20, 144, 146
  12924.               scddrinfo  16, 87, 101           scdnkcur  20, 146
  12925.               scddrlock  18, 26, 95,           scdnkdate  20, 144, 147,
  12926.                   102, 110                         152
  12927.               scddrnum  17, 79, 83, 103        scdnkdel  20, 148
  12928.  
  12929.  
  12930.  
  12931.             190                 SoftC Database Library
  12932.  
  12933.  
  12934.  
  12935.  
  12936.  
  12937.  
  12938.  
  12939.  
  12940.                                                  INDEX
  12941.  
  12942.  
  12943.               scdnkfind  20, 146, 149              create  58
  12944.               scdnkmake  20, 138, 144,             flush  60
  12945.                   151, 179                         index  61
  12946.               scdnknext  20, 146, 153              open  76
  12947.               scdnkprev  20, 146, 155              read header  62
  12948.               scdnktop  20, 146, 157             key
  12949.               scdnopenx  19, 140, 143,             add  65
  12950.                   158                              build  71
  12951.               scdtclose  18, 159                   delete  68
  12952.               scdtcreate  18, 160                  get first  75
  12953.               scdterm  8, 15, 24, 134,             get last  66
  12954.                   160, 185                         read next  73
  12955.               scdthget  161                        read previous  74
  12956.               scdtinfo  18, 162                    search  69
  12957.               scdtopenx  18, 159, 162,         dBASE
  12958.                   163, 165                       expression
  12959.               scdtpack  18, 98, 164                defined  138, 151
  12960.               scdtrget  18, 84, 165,               functions
  12961.                   166                              dtoc  20, 151
  12962.               scdtrput  18, 166, 167               left  20, 151
  12963.               scdwclose  167                       right  20, 151, 152
  12964.               scdwcreate  168                      str  20, 151, 152
  12965.               scdwhget  168                        substr  20, 151, 152
  12966.               scdwinfo  169                        read  138
  12967.               scdwopenx  167, 170, 172           file
  12968.               scdwpack  171                        cache  136
  12969.               scdwrget  172, 173                   close  137
  12970.               scdwrput  173, 174                   create  137
  12971.               sceclr  25, 174, 175                 flush  139
  12972.               scemsg  25, 175, 186                 index  141
  12973.                                                    open  158
  12974.             Global variables                       read header  140
  12975.               sc_code  25, 161, 175,             key
  12976.                   186                              add  143
  12977.               sc_date_style  24, 84, 90            build  147, 151
  12978.               sc_version  24                       delete  148
  12979.                                                    get first  157
  12980.             Index                                  get last  144
  12981.               Clipper                              read next  153
  12982.                 expression                         read previous  155
  12983.                   defined  58, 71                  search  149
  12984.                   functions                    FoxBase/FoxPro
  12985.                   dtoc  71                       expression
  12986.                   left  71                         defined  113, 126
  12987.                   right  71, 72                    functions
  12988.                   str  71, 72                      dtoc  126, 127
  12989.                   substr  71, 72                   left  126, 127
  12990.                   read  59                         right  126, 127
  12991.                 file                               str  126, 127
  12992.                   cache  56                        substr  126, 127
  12993.                   close  57                        read  114
  12994.  
  12995.  
  12996.  
  12997.             User's Reference Manual                191
  12998.  
  12999.  
  13000.  
  13001.  
  13002.  
  13003.  
  13004.  
  13005.  
  13006.             INDEX                                     
  13007.  
  13008.  
  13009.                 file                             SC_BADHNDL  180
  13010.                   cache  111                     SC_BADKEYT  181
  13011.                   close  112                     SC_BADPG  180
  13012.                   create  112                    SC_BADROOT  182
  13013.                   flush  115                     SC_BADTAG  185
  13014.                   index  117                     SC_BADTIME  181
  13015.                   open  134                      SC_BADTNAME  185
  13016.                   read header  116               SC_BLKADR  185
  13017.                 key                              SC_BLKSZ  185
  13018.                   add  119                       SC_CLOSFAIL  180
  13019.                   build  122, 126, 130           SC_DBFDATE  181
  13020.                   delete  123                    SC_DBFHLEN  181
  13021.                   get first  132                 SC_DBFVERS  181
  13022.                   get last  120                  SC_DECPL  182
  13023.                   read next  128                 SC_FILBAD  179
  13024.                   read previous  131             SC_FILSOPEN  184
  13025.                   search  124                    SC_FLDCNT  182
  13026.                                                  SC_FLDLEN  182
  13027.             Initialization  134                  SC_FLSHFAIL  185
  13028.                                                  SC_ITEMLEN  182
  13029.             Memo                                 SC_KEYFORM  186
  13030.               dBASE                              SC_KEYLEN  181
  13031.                 close  159                       SC_LCKBOVR  184
  13032.                 create  160                      SC_LCKVIOL  183
  13033.                 open  163                        SC_LINELEN  183
  13034.                 pack  164                        SC_MAXKEYS  182
  13035.                 read  165                        SC_MAXTAGS  185
  13036.                 read header  161                 SC_MDXFLAG  183
  13037.                 write  166                       SC_MEMERR  179
  13038.               FoxPro                             SC_MINKEYS  184
  13039.                 close  167                       SC_NEWDEV  184
  13040.                 create  168                      SC_NODBT  181
  13041.                 open  170                        SC_NOFILE  179
  13042.                 pack  171                        SC_NOHNDL  179
  13043.                 read  172                        SC_NOPATH  184
  13044.                 read header  168                 SC_NOPGS  180
  13045.                 write  173                       SC_NOTLCKD  184
  13046.                                                  SC_NULLPARM  181
  13047.             Return codes                         SC_OPENFAIL  185
  13048.               clear  174                         SC_RDFAIL  178
  13049.               defined  24, 177                   SC_READOLY  183
  13050.               errors                             SC_RECLEN  183
  13051.                 SC_ACCDEN  184                   SC_SKFAIL  179
  13052.                 SC_BADACC  184                   SC_TAGCNT  186
  13053.                 SC_BADCMD  180                   SC_TAGOPEN  186
  13054.                 SC_BADDATA  183                  SC_TBLELEN  186
  13055.                 SC_BADDATE  180                  SC_UNSWITCH  186
  13056.                 SC_BADEXPR  179                  SC_WRTFAIL  178
  13057.                 SC_BADFLDN  182                message translate  175
  13058.                 SC_BADFLDT  183                warnings
  13059.                 SC_BADFNAME  180                 SC_DELREC  177
  13060.  
  13061.  
  13062.  
  13063.             192                 SoftC Database Library
  13064.  
  13065.  
  13066.  
  13067.  
  13068.  
  13069.  
  13070.  
  13071.  
  13072.                                                  INDEX
  13073.  
  13074.  
  13075.                 SC_EMPTY  177                SC_FP1  81
  13076.                 SC_END  177
  13077.                 SC_FILENGTH  178             SC_GETSZ  56, 77, 111, 136
  13078.                 SC_FLDROUND  177
  13079.                 SC_FLDTRUNC  177             SC_GREGOR  21, 24, 32, 37,
  13080.                 SC_MEMWRN  178               38, 39, 40, 41, 42, 43, 44,
  13081.                 SC_NOFIND  177               45, 46, 47, 48, 49, 50, 84,
  13082.                 SC_NOFUNC  178               90, 96, 123, 147
  13083.                 SC_NOTBFRD  178
  13084.                                              SC_GREGORL  21, 32, 37, 38,
  13085.             SC_ADD  105, 106, 174            39, 40, 41, 42, 43, 44, 45,
  13086.                                              46, 47, 48, 49, 50, 96,
  13087.             SC_BUFFER  16, 19, 60, 77,       123, 147
  13088.             78, 88, 97, 116, 135, 140,
  13089.             159, 163, 171, 178               SC_JULIAN  21, 32, 37, 38,
  13090.                                              39, 40, 41, 42, 43, 44, 45,
  13091.             SC_CKEY  58, 113, 138            46, 47, 48, 49, 50, 96,
  13092.                                              123, 147
  13093.             SC_CRDELETE  166
  13094.                                              SC_LKEY  113
  13095.             SC_CRUNCHNG  166
  13096.                                              SC_MIL  21, 51, 52, 54, 55,
  13097.             SC_CSHMS  21, 51, 52, 54,        56
  13098.             55, 56
  13099.                                              SC_NKEY  58, 113, 138
  13100.             SC_DB3  81
  13101.                                              SC_NOTUSED  98
  13102.             SC_DB4  81
  13103.                                              SC_RDONLY  76, 97, 98, 135,
  13104.             SC_DELREC  100, 101, 107         158, 163, 170
  13105.  
  13106.             SC_DKEY  58, 113, 138            SC_RDWR  76, 96, 135, 158,
  13107.                                              163, 170
  13108.             SC_DMY  21, 24, 32, 37, 38,
  13109.             39, 40, 41, 42, 43, 44, 45,      SC_SETSZ  56, 77, 111, 136
  13110.             46, 47, 48, 49, 50, 96,
  13111.             123, 147                         SC_SHARED  77, 94, 97, 103,
  13112.                                              110, 135, 159, 163, 171
  13113.             SC_EXACT  70, 125, 150
  13114.                                              SC_SUCCESS  107
  13115.             SC_EXCLUDE  77, 97, 135,
  13116.             159, 163, 171, 184               SC_TRUE  15, 34, 47, 79, 83
  13117.  
  13118.             SC_FALSE  34, 47, 79, 83         SC_UNIQUE  59, 113, 138
  13119.  
  13120.             SC_FIELD  80, 86                 SC_UPDATE  105, 106, 174
  13121.  
  13122.             SC_FIRST  70, 125, 150           SC_USEXHNDL  134, 185
  13123.  
  13124.             SC_FLUSH  77, 97, 135, 159,      SC_YMD  21, 32, 37, 38, 39,
  13125.             178                              40, 41, 42, 43, 44, 45, 46,
  13126.  
  13127.  
  13128.  
  13129.             User's Reference Manual                193
  13130.  
  13131.  
  13132.  
  13133.  
  13134.  
  13135.  
  13136.  
  13137.  
  13138.             INDEX                                     
  13139.  
  13140.  
  13141.             47, 48, 49, 50, 96, 123,
  13142.             147
  13143.  
  13144.             Structures
  13145.               SC_DBFINFO  93
  13146.               SC_DBFRINFO  101, 102
  13147.               SC_DBTINFO  162
  13148.               SC_FIELD  80, 86
  13149.               SC_FLAGS  64, 93, 118,
  13150.                   142, 162, 169
  13151.               SC_FPTINFO  169
  13152.               SC_IDXINFO  118
  13153.               SC_NDXINFO  142
  13154.               SC_NTXINFO  64
  13155.  
  13156.             Termination  160
  13157.  
  13158.             Time
  13159.               calculation  53
  13160.               get from DOS
  13161.                 integers  51
  13162.                 string  54
  13163.               test  55
  13164.               translation  50, 52
  13165.  
  13166.  
  13167.  
  13168.  
  13169.  
  13170.  
  13171.  
  13172.  
  13173.  
  13174.  
  13175.  
  13176.  
  13177.  
  13178.  
  13179.  
  13180.  
  13181.  
  13182.  
  13183.  
  13184.  
  13185.  
  13186.  
  13187.  
  13188.  
  13189.  
  13190.  
  13191.  
  13192.  
  13193.  
  13194.  
  13195.             194                 SoftC Database Library
  13196.  
  13197.  
  13198.  
  13199.  
  13200.  
  13201.  
  13202.  
  13203.  
  13204.  
  13205.  
  13206.  
  13207.                  
  13208.  
  13209.  
  13210.  
  13211.  
  13212.  
  13213.  
  13214.  
  13215.  
  13216.  
  13217.  
  13218.  
  13219.  
  13220.  
  13221.  
  13222.  
  13223.  
  13224.  
  13225.  
  13226.  
  13227.  
  13228.  
  13229.  
  13230.  
  13231.  
  13232.  
  13233.  
  13234.  
  13235.  
  13236.  
  13237.  
  13238.  
  13239.  
  13240.  
  13241.  
  13242.  
  13243.  
  13244.  
  13245.  
  13246.  
  13247.  
  13248.  
  13249.  
  13250.  
  13251.  
  13252.  
  13253.  
  13254.  
  13255.  
  13256.  
  13257.  
  13258.  
  13259.  
  13260.  
  13261.  
  13262.  
  13263.  
  13264.  
  13265.  
  13266.  
  13267.