Guidance
指路人
g.yi.org
software / rapidq / Examples / Database / Tsunami Record Manager 2.5 / TRM_RQCreate.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
     $INCLUDE "TRM_RQDeclares.INC"

     DIM CmdTsu  AS TRMType

'\--- Construct the File Definition string ---------------------------\


     FUNCTION AddDefOfKey(Sender AS TRMdKey) AS STRING
      Sender.FDef = RTRIM$(Sender.FDef) + _
       Sender.SegName + _                                          ' Segment description
       CHR$(Sender.KeyNo) + _                                      ' Key number = 1
       CHR$(Sender.KeyPos MOD 256) + CHR$(Sender.KeyPos / 256) + _ ' Segment's position
       CHR$(Sender.KeyLen) + _                                     ' Segment's length
       CHR$(Sender.KeyFlags)

      result = Sender.FDef
     END FUNCTION

     DIM FDefKey  AS TRMdKey
     DIM FDef     AS STRING
     DIM FileName  AS STRING
     DIM Result    AS LONG
     DIM OverWrite AS LONG


     FDefKey.PageSize = 1     ' Page size = 1K
     FDefKey.Compress = 1     ' Compress records in file
     FDefKey.Segments = 3     ' 4 key segments will be defined (3 keys)

     FDefKey.FDef = CHR$(FDefKey.PageSize) + _
      CHR$(FDefKey.Compress) + _
      CHR$(FDefKey.Segments)

 '\---Introducing 1st key --------------------------------------------\

     FDefKey.SegName  = "Employee ID Number"
     FDefKey.KeyNo    = 1
     FDefKey.KeyPos   = 1
     FDefKey.KeyLen   = 6
     FDefKey.KeyFlags = 0

     FDef = AddDefOfKey (FDefKey)    '---Add the key definition

 '\---Introducing 2nd key --------------------------------------------\

     FDefKey.SegName  = "Last Name, First Name, MI"
     FDefKey.KeyNo    = 2
     FDefKey.KeyPos   = 7
     FDefKey.KeyLen   = 25
     FDefKey.KeyFlags = 0

     FDef = AddDefOfKey (FDefKey)    '\---Add the key definition

 '\---Introducing 3rd Key --------------------------------------------\

     FDefKey.SegName  = "Department Number"
     FDefKey.KeyNo    = 3
     FDefKey.KeyPos   = 32
     FDefKey.KeyLen   = 5
     FDefKey.KeyFlags = NO_COMPRESSION

     FDef = AddDefOfKey (FDefKey)    '\---Add the key definition


'\--- Create the Tsunami file ----------------------------------------\

     OverWrite = 0
     FileName  = "dBase.pdb"

     CmdTsu.op = Tsu_Create
     CmdTsu.dataptr = VARPTR(FDef)
     CmdTsu.datalen = LEN(FDef)
     CmdTsu.keyptr = VARPTR(FileName)
     CmdTsu.keylen = LEN(FileName)
     CmdTsu.keyno = OverWrite

     Result = trm_udt(CmdTsu)

     SELECT CASE Result
     CASE 0    : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create was sucessfull"
     CASE 2    : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered I/O errors"
     CASE 10   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered invalid page size"
     CASE 11   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered invalid number of key segments"
     CASE 12   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered invalid file definition string"
     CASE 13   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered invalid key segment position"
     CASE 14   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered invalid key segment length"
     CASE 15   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered inconsistent key segment definitions"
     CASE 31   : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered file already exists"
     CASE ELSE : SHOWMESSAGE "CODE: "& STR$(Result) &": Trm_Operation trm_Create encountered Unknown Error"
     END SELECT
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-19  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-10-21 15:03:00