$INCLUDE "TRM_RQDeclares.INC"
DIM CmdTsu AS TRMType
FUNCTION AddDefOfKey(Sender AS TRMdKey) AS STRING
Sender.FDef = RTRIM$(Sender.FDef) + _
Sender.SegName + _
CHR$(Sender.KeyNo) + _
CHR$(Sender.KeyPos MOD 256) + CHR$(Sender.KeyPos / 256) + _
CHR$(Sender.KeyLen) + _
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
FDefKey.Compress = 1
FDefKey.Segments = 3
FDefKey.FDef = CHR$(FDefKey.PageSize) + _
CHR$(FDefKey.Compress) + _
CHR$(FDefKey.Segments)
FDefKey.SegName = "Employee ID Number"
FDefKey.KeyNo = 1
FDefKey.KeyPos = 1
FDefKey.KeyLen = 6
FDefKey.KeyFlags = 0
FDef = AddDefOfKey (FDefKey)
FDefKey.SegName = "Last Name, First Name, MI"
FDefKey.KeyNo = 2
FDefKey.KeyPos = 7
FDefKey.KeyLen = 25
FDefKey.KeyFlags = 0
FDef = AddDefOfKey (FDefKey)
FDefKey.SegName = "Department Number"
FDefKey.KeyNo = 3
FDefKey.KeyPos = 32
FDefKey.KeyLen = 5
FDefKey.KeyFlags = NO_COMPRESSION
FDef = AddDefOfKey (FDefKey)
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
|