home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Unleashed
/
Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso
/
codebsic
/
cb5_demo.bas
< prev
next >
Wrap
BASIC Source File
|
1995-02-01
|
35KB
|
864 lines
' Data Types Used by CodeBasic
Type FIELD4INFOCB
fname As Long ' C string (which is different than a Basic String)
ftype As Integer
flength As Integer
fdecimals As Integer
End Type
Type FIELD4INFO ' Corresponding Basic structure
fname As String
ftype As String * 1
flength As Integer
fdecimals As Integer
End Type
Type TAG4INFOCB
name As Long ' C string
expression As Long ' C string
filter As Long ' C string
unique As Integer
descending As Integer
End Type
Type TAG4INFO
name As String
expression As String
filter As String
unique As Integer
descending As Integer
End Type
'===================================================================================
'
' CODE4 Access function prototypes
'
'===================================================================================
Declare Function code4autoOpen% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4createError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4dateFormatCB& Lib "v4demo.dll" Alias "code4dateFormat" (ByVal c4&, ByVal pic$)
Declare Function code4defaultUniqueError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4errorCode% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4exclusive% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4exprError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4fieldNameError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4goError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4hWnd% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4lockAttempts% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memExpandBlock% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memExpandData% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memExpandIndex% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memExpandTag% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memSizeBlock& Lib "v4demo.dll" (ByVal c4&, ByVal value&)
Declare Function code4memSizeBuffer& Lib "v4demo.dll" (ByVal c4&, ByVal value&)
Declare Function code4memSizeMemo% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memSizeMemoExpr& Lib "v4demo.dll" (ByVal c4&, ByVal value&)
Declare Function code4memSizeSortBuffer& Lib "v4demo.dll" (ByVal c4&, ByVal value&)
Declare Function code4memSizeSortPool& Lib "v4demo.dll" (ByVal c4&, ByVal value&)
Declare Function code4memStartBlock% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memStartData% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memStartIndex% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4memstartmax& Lib "v4demo.dll" (ByVal c4&, ByVal value&)
Declare Function code4memStartTag% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4offError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4openError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4optimize% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4optimizeWrite% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4readLock% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4readOnly% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4relateError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4safety% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4skipError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
Declare Function code4tagNameError% Lib "v4demo.dll" (ByVal c4&, ByVal value%)
'===============================================================================================
'
' Data File Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Function d4aliasCB& Lib "v4demo.dll" Alias "d4alias" (ByVal d4&)
Declare Sub d4AliasSet Lib "v4demo.dll" Alias "d4alias_set" (ByVal d4&, ByVal AliasValue$)
Declare Function d4append% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4appendBlank% Lib "v4demo.dll" Alias "d4append_blank" (ByVal d4&)
Declare Function d4appendStart% Lib "v4demo.dll" Alias "d4append_start" (ByVal d4&, ByVal UseMemoEntries%)
Declare Sub d4blank Lib "v4demo.dll" (ByVal d4&)
Declare Function d4bof% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4bottom% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4changed% Lib "v4demo.dll" (ByVal d4&, ByVal intFlag%)
Declare Function d4check% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4close% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4closeAll% Lib "v4demo.dll" Alias "d4close_all" (ByVal c4&)
Declare Function d4createCB& Lib "v4demo.dll" Alias "d4create" (ByVal c4&, ByVal DbfName$, fieldinfo As Any, tagInfo As Any)
Declare Function d4data& Lib "v4demo.dll" (ByVal c4&, ByVal AliasName$)
Declare Sub d4delete Lib "v4demo.dll" (ByVal d4&)
Declare Function d4deleted% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4eof% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4field& Lib "v4demo.dll" (ByVal d4&, ByVal FieldName$)
Declare Function d4fieldInfo& Lib "v4demo.dll" Alias "d4field_info" (ByVal d4&)
Declare Function d4fieldJ& Lib "v4demo.dll" Alias "d4field_j" (ByVal d4&, ByVal JField%)
Declare Function d4fieldNumber% Lib "v4demo.dll" Alias "d4field_number" (ByVal d4&, ByVal FieldName$)
Declare Function d4fileNameCB& Lib "v4demo.dll" Alias "d4fileName" (ByVal d4&)
Declare Function d4flush% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4flushData% Lib "v4demo.dll" Alias "d4flush_data" (ByVal d4&)
Declare Function d4flushFiles% Lib "v4demo.dll" Alias "d4flush_files" (ByVal c4&)
Declare Function d4freeBlocks% Lib "v4demo.dll" Alias "d4free_blocks" (ByVal d4&)
Declare Function d4go% Lib "v4demo.dll" (ByVal d4&, ByVal RecNum&)
Declare Function d4goData% Lib "v4demo.dll" Alias "d4go_data" (ByVal d4&, ByVal RecNum&)
Declare Function d4goEof% Lib "v4demo.dll" Alias "d4go_eof" (ByVal d4&)
Declare Function d4index& Lib "v4demo.dll" (ByVal d4&, ByVal IndexName$)
Declare Function d4init& Lib "v4demo.dll" Alias "d4init_v" ()
Declare Function d4initUndo% Lib "v4demo.dll" Alias "d4initUndo" (ByVal c4&)
Declare Function d4lock% Lib "v4demo.dll" (ByVal d4&, ByVal RecordNum&)
Declare Function d4lockAll% Lib "v4demo.dll" Alias "d4lock_all" (ByVal d4&)
Declare Function d4lockAppend% Lib "v4demo.dll" Alias "d4lock_append" (ByVal d4&)
Declare Function d4lockFile% Lib "v4demo.dll" Alias "d4lock_file" (ByVal d4&)
Declare Function d4lockGroup% Lib "v4demo.dll" Alias "d4lock_group" (ByVal d4&, RecordsArray&, ByVal NumRecords%)
Declare Function d4lockIndex% Lib "v4demo.dll" Alias "d4lock_index" (ByVal d4&)
Declare Function d4lockTest% Lib "v4demo.dll" Alias "d4lock_test" (ByVal d4&, ByVal RecNum&)
Declare Function d4lockTestAppend% Lib "v4demo.dll" Alias "d4lock_test_append" (ByVal d4&)
Declare Function d4lockTestFile% Lib "v4demo.dll" Alias "d4lock_test_file" (ByVal d4&)
Declare Function d4lockTestIndex% Lib "v4demo.dll" Alias "d4lock_test_index" (ByVal d4&)
Declare Function d4memoCompress% Lib "v4demo.dll" Alias "d4memo_compress" (ByVal d4&)
Declare Function d4numFields% Lib "v4demo.dll" Alias "d4num_fields" (ByVal d4&)
Declare Function d4open& Lib "v4demo.dll" (ByVal c4&, ByVal DbfName$)
Declare Function d4optStart% Lib "v4demo.dll" Alias "d4opt_start" (ByVal c4&)
Declare Function d4optSuspend& Lib "v4demo.dll" Alias "d4opt_suspend" (ByVal c4&)
Declare Function d4optimize% Lib "v4demo.dll" (ByVal d4&, ByVal OptFlag%)
Declare Function d4optimizeWrite% Lib "v4demo.dll" Alias "d4optimize_write" (ByVal d4&, ByVal OptFlag%)
Declare Function d4pack% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4packData% Lib "v4demo.dll" Alias "d4pack_data" (ByVal d4&)
Declare Function d4position# Lib "v4demo.dll" (ByVal d4&)
Declare Function d4positionSet% Lib "v4demo.dll" Alias "d4position_set" (ByVal d4&, ByVal Percentage#)
Declare Sub d4recall Lib "v4demo.dll" (ByVal d4&)
Declare Function d4reccount& Lib "v4demo.dll" (ByVal d4&)
Declare Function d4recno& Lib "v4demo.dll" (ByVal d4&)
Declare Function d4record& Lib "v4demo.dll" (ByVal d4&)
Declare Function d4recordWidth& Lib "v4demo.dll" Alias "d4record_width" (ByVal d4&)
Declare Function d4refresh% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4refreshRecord% Lib "v4demo.dll" Alias "d4refresh_record" (ByVal d4&)
Declare Function d4reindex% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4seek% Lib "v4demo.dll" (ByVal d4&, ByVal seekValue$)
Declare Function d4seekDouble% Lib "v4demo.dll" Alias "d4seek_double" (ByVal d4&, ByVal value#)
Declare Function d4skip% Lib "v4demo.dll" (ByVal d4&, ByVal NumberRecords&)
Declare Function d4tag& Lib "v4demo.dll" (ByVal d4&, ByVal TagName$)
Declare Function d4tagDefault& Lib "v4demo.dll" Alias "d4tag_default" (ByVal d4&)
Declare Function d4tagNext& Lib "v4demo.dll" Alias "d4tag_next" (ByVal d4&, ByVal TagOn As Any)
Declare Function d4tagPrev& Lib "v4demo.dll" Alias "d4tag_prev" (ByVal d4&, ByVal TagOn As Any)
Declare Sub d4tagSelect Lib "v4demo.dll" Alias "d4tag_select" (ByVal d4&, ByVal tPtr As Any)
Declare Function d4tagSelected& Lib "v4demo.dll" Alias "d4tag_selected" (ByVal d4&)
Declare Function d4top% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4unlock% Lib "v4demo.dll" (ByVal d4&)
Declare Function d4unlockFiles% Lib "v4demo.dll" Alias "d4unlock_files" (ByVal d4&)
Declare Function d4write% Lib "v4demo.dll" (ByVal d4&, ByVal RecNum&)
Declare Function d4zap% Lib "v4demo.dll" (ByVal d4&, ByVal StartRecord&, ByVal EndRecord&)
'===============================================================================================
'
' Date Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Sub date4assign Lib "v4demo.dll" (ByVal DateForm$, ByVal JulianDay&)
Declare Function date4cdowCB& Lib "v4demo.dll" Alias "date4cdow" (ByVal DateForm$)
Declare Function date4cmonthCB& Lib "v4demo.dll" Alias "date4cmonth" (ByVal DateForm$)
Declare Function date4day% Lib "v4demo.dll" (ByVal DateForm$)
Declare Function date4dow% Lib "v4demo.dll" (ByVal DateForm$)
Declare Sub date4formatCB Lib "v4demo.dll" Alias "date4format" (ByVal DateForm$, ByVal Result$, ByVal pic$)
Declare Sub date4initCB Lib "v4demo.dll" Alias "date4init" (ByVal DateForm$, ByVal value$, ByVal pic$)
Declare Function date4long& Lib "v4demo.dll" (ByVal DateForm$)
Declare Function date4month% Lib "v4demo.dll" (ByVal DateForm$)
Declare Sub date4timeNow Lib "v4demo.dll" Alias "date4time_now" (ByVal TimeForm$)
Declare Sub date4todayCB Lib "v4demo.dll" Alias "date4today" (ByVal DateForm$)
Declare Function date4year% Lib "v4demo.dll" (ByVal DateForm$)
'===============================================================================================
'
' Expression Evaluation Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Function expr4double# Lib "v4demo.dll" (ByVal ExprPtr&)
Declare Sub expr4free Lib "v4demo.dll" (ByVal ExprPtr&)
Declare Function expr4Len% Lib "v4demo.dll" (ByVal ExprPtr&)
Declare Function expr4parse& Lib "v4demo.dll" (ByVal d4&, ByVal expression$)
Declare Function expr4true% Lib "v4demo.dll" (ByVal ExprPtr&)
'===============================================================================================
'
' Field Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Sub f4assign Lib "v4demo.dll" (ByVal fPtr&, ByVal value$)
Declare Sub f4assignChar Lib "v4demo.dll" Alias "f4assign_char" (ByVal fPtr&, ByVal Char%)
Declare Sub f4assignDouble Lib "v4demo.dll" Alias "f4assign_double" (ByVal fPtr&, ByVal value#)
Declare Sub f4assignField Lib "v4demo.dll" Alias "f4assign_field" (ByVal fPtrTo&, ByVal fPtrFrom&)
Declare Sub f4assignInt Lib "v4demo.dll" Alias "f4assign_int" (ByVal fPtr&, ByVal value%)
Declare Sub f4assignLong Lib "v4demo.dll" Alias "f4assign_long" (ByVal fPtr&, ByVal value&)
Declare Sub f4assignN Lib "v4demo.dll" Alias "f4assign_n" (ByVal fPtr&, ByVal value$, ByVal Length%)
Declare Sub f4blank Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4char% Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4data& Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4decimals% Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4double# Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4int% Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4len& Lib "v4demo.dll" Alias "f4len_v" (ByVal fPtr&)
Declare Function f4long& Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4memoAssign% Lib "v4demo.dll" Alias "f4memo_assign" (ByVal fPtr&, ByVal value$)
Declare Function f4memoAssignN% Lib "v4demo.dll" Alias "f4memo_assign_n" (ByVal fPtr&, ByVal value$, ByVal Length%)
Declare Sub f4memoFree Lib "v4demo.dll" Alias "f4memo_free" (ByVal fPtr&)
Declare Function f4memoLen& Lib "v4demo.dll" Alias "f4memoLen" (ByVal fPtr&)
Declare Function f4memoPtr& Lib "v4demo.dll" Alias "f4memo_ptr" (ByVal fPtr&)
Declare Function f4memoStrCB& Lib "v4demo.dll" Alias "f4memo_str" (ByVal fPtr&)
Declare Function f4nameCB& Lib "v4demo.dll" Alias "f4name" (ByVal fPtr&)
Declare Function f4ncpy% Lib "v4demo.dll" (ByVal fPtr&, ByVal memPtr$, ByVal memLength%)
Declare Function f4ptr& Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4strCB& Lib "v4demo.dll" Alias "f4str" (ByVal fPtr&)
Declare Function f4true% Lib "v4demo.dll" (ByVal fPtr&)
Declare Function f4type% Lib "v4demo.dll" (ByVal fPtr&)
'===============================================================================================
'
' Index Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Function i4close% Lib "v4demo.dll" (ByVal i4&)
Declare Function i4createCB& Lib "v4demo.dll" Alias "i4create" (ByVal d4&, ByVal FileName As Any, tagInfo As TAG4INFOCB)
Declare Function i4lock% Lib "v4demo.dll" (ByVal i4&)
Declare Function i4openCB& Lib "v4demo.dll" Alias "i4open" (ByVal d4&, ByVal FileName As Any)
Declare Function i4reindex% Lib "v4demo.dll" (ByVal i4&)
Declare Function i4tag& Lib "v4demo.dll" (ByVal i4&, ByVal FileName$)
Declare Function i4tagInfo& Lib "v4demo.dll" Alias "i4tag_info" (ByVal i4&)
Declare Function i4unlock% Lib "v4demo.dll" (ByVal i4&)
'===============================================================================================
'
' Relate Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Function relate4bottom% Lib "v4demo.dll" (ByVal r4&)
Declare Sub relate4changed Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4createSlave& Lib "v4demo.dll" Alias "relate4create_slave" (ByVal r4&, ByVal d4&, ByVal mExpr$, ByVal t4 As Any)
Declare Function relate4data& Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4dataTag& Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4do% Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4doOne% Lib "v4demo.dll" Alias "relate4do_one" (ByVal r4&)
Declare Function relate4errorAction% Lib "v4demo.dll" Alias "relate4error_action" (ByVal r4&, ByVal ErrAction%)
Declare Function relate4free% Lib "v4demo.dll" (ByVal r4&, ByVal CloseFlag%)
Declare Function relate4init& Lib "v4demo.dll" (ByVal d4&)
Declare Function relate4lock% Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4matchLen% Lib "v4demo.dll" Alias "relate4match_len" (ByVal r4&, ByVal Length%)
Declare Function relate4master& Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4next% Lib "v4demo.dll" (r4&)
Declare Function relate4querySet% Lib "v4demo.dll" Alias "relate4query_set" (ByVal r4&, ByVal expr As String)
Declare Function relate4skip% Lib "v4demo.dll" (ByVal r4&, ByVal NumRecs&)
Declare Function relate4skipEnable% Lib "v4demo.dll" Alias "relate4skip_enable" (ByVal r4&, ByVal DoEnable%)
Declare Function relate4sortSet% Lib "v4demo.dll" Alias "relate4sort_set" (ByVal r4&, ByVal expr As String)
Declare Function relate4top% Lib "v4demo.dll" (ByVal r4&)
Declare Function relate4type% Lib "v4demo.dll" (ByVal r4&, ByVal rType%)
Declare Function relate4unlock% Lib "v4demo.dll" (ByVal r4&)
'===============================================================================================
'
' Report function prototypes
'
'================================================================================================
Declare Function report4currency% Lib "v4demo.dll" (ByVal r4&, ByVal symbol%)
Declare Function report4do% Lib "v4demo.dll" (ByVal r4&)
Declare Sub report4free Lib "v4demo.dll" (ByVal r4&, ByVal free_r%, ByVal close_f%)
Declare Sub report4output Lib "v4demo.dll" (ByVal r4&, ByVal o_code%, ByVal o_dev As Any, ByVal styles%)
Declare Sub report4pageSize Lib "v4demo.dll" Alias "report4page_size" (ByVal r4&, ByVal pWidth%, ByVal pHeight%)
Declare Function report4relate& Lib "v4demo.dll" (ByVal r4&)
Declare Function report4retrieve& Lib "v4demo.dll" (ByVal c4&, ByVal f_name$, ByVal open_f%)
Declare Function report4save% Lib "v4demo.dll" (ByVal r4&, ByVal fname$)
Declare Function report4symbolsNumeric% Lib "v4demo.dll" Alias "report4symbols_numeric" (ByVal r4&, ByVal thous%, ByVal decimal%)
'===============================================================================================
'
' TAG4 Access function prototypes
'
'================================================================================================
Declare Function tag4aliasCB& Lib "v4demo.dll" Alias "tag4alias" (ByVal t4&)
Declare Function tag4Descending% Lib "v4demo.dll" (ByVal t4&)
Declare Function tag4exprCB& Lib "v4demo.dll" Alias "tag4expr" (ByVal t4&)
Declare Function tag4filterCB& Lib "v4demo.dll" Alias "tag4filter" (ByVal t4&)
Declare Function tag4KeyLen% Lib "v4demo.dll" (ByVal t4&)
Declare Function tag4Unique% Lib "v4demo.dll" (ByVal t4&)
Declare Function tag4UniqueError% Lib "v4demo.dll" (ByVal t4&, ByVal value%)
'===============================================================================================
'
' Tag Functions' Prototypes
'
'-----------------------------------------------------------------------------------------------
Declare Function t4bottom% Lib "v4demo.dll" (ByVal t4&)
Declare Function t4eof% Lib "v4demo.dll" (ByVal t4&)
Declare Function t4go% Lib "v4demo.dll" (ByVal t4&, ByVal key$, ByVal RecNum&)
Declare Function t4keyCB& Lib "v4demo.dll" Alias "t4key" (ByVal t4&)
Declare Function t4open& Lib "v4demo.dll" Alias "t4open_v" (ByVal dbPtr&, ByVal IndexName$)
Declare Function t4position# Lib "v4demo.dll" (ByVal t4&)
Declare Function t4positionSet% Lib "v4demo.dll" Alias "t4position_set" (ByVal t4&, ByVal Position#)
Declare Function t4recno& Lib "v4demo.dll" (ByVal t4&)
Declare Function t4seek% Lib "v4demo.dll" (ByVal t4&, ByVal key As Any, ByVal keyLength%)
Declare Function t4skip& Lib "v4demo.dll" (ByVal t4&, ByVal NumRecs&)
Declare Function t4top% Lib "v4demo.dll" (ByVal t4&)
'=======================================================================================
'
' Utility function prototypes
'
'========================================================================================
Declare Function u4alloc& Lib "v4demo.dll" (ByVal amt&)
Declare Function u4allocFree& Lib "v4demo.dll" Alias "u4alloc_free" (ByVal c4&, ByVal amt&)
Declare Sub u4free Lib "v4demo.dll" (ByVal memPtr&)
Declare Function u4ncpy% Lib "v4demo.dll" (ByVal MemPtr1$, ByVal memptr2&, ByVal memLength%)
Declare Function u4ncpy2% Lib "v4demo.dll" Alias "u4ncpy" (ByVal MemPtr1&, ByVal memptr2$, ByVal memLength%)
'=======================================================================================
'
' Misc. function prototypes
'
'========================================================================================
Declare Function v4Cstring& Lib "v4demo.dll" (ByVal s$)
Declare Sub v4Cstringfree Lib "v4demo.dll" (ByVal s&)
'CodeBase Return Code Constants
Global Const r4success% = 0
Global Const r4found% = 1
Global Const r4after = 2
Global Const r4eof = 3
Global Const r4bof = 4
Global Const r4entry = 5
Global Const r4descending = 10
Global Const r4unique = 20
Global Const r4uniqueContinue = 25
Global Const r4ignore = 40
Global Const r4keep = 45
Global Const r4locked = 50
Global Const r4noCreate = 60
Global Const r4noOpen = 70
Global Const r4notag = 80
Global Const relate4filterRecord = 101
Global Const relate4doRemove = 102
Global Const relate4skipped = 104
Global Const relate4blank = 105
Global Const relate4skipRec = 106
Global Const relate4terminate = 107
Global Const relate4exact = 108
Global Const relate4scan = 109
Global Const relate4approx = 110
Global Const relate4sortSkip = 120
Global Const relate4sortDone = 121
'CodeBasic Field Definition Constants
Global Const r4logLen = 1
Global Const r4dateLen = 8
Global Const r4memoLen = 10
Global Const r4str$ = "C"
Global Const r4float$ = "F"
Global Const r4num$ = "N"
Global Const r4date$ = "D"
Global Const r4log$ = "L"
Global Const r4memo$ = "M"
'Other CodeBasic Constants
Global Const r4check = -5
'CodeBasic Error Code Constants
Global Const e4close = -10
Global Const e4create = -20
Global Const e4len = -30
Global Const e4lenSet = -40
Global Const e4lock = -50
Global Const e4open = -60
Global Const e4read = -70
Global Const e4remove = -80
Global Const e4rename = -90
Global Const e4seek = -100
Global Const e4unlock = -110
Global Const e4write = -120
Global Const e4data = -200
Global Const e4fieldName = -210
Global Const e4fieldType = -220
Global Const e4recordLen = -230
Global Const e4entry = -300
Global Const e4index = -310
Global Const e4tagName = -330
Global Const e4unique = -340
Global Const e4commaExpected = -400
Global Const e4complete = -410
Global Const e4dataName = -420
Global Const e4numParms = -430
Global Const e4overflow = -440
Global Const e4rightMissing = -450
Global Const e4typeSub = -460
Global Const e4unrecFunction = -470
Global Const e4unrecOperator = -480
Global Const e4unrecValue = -490
Global Const e4undetermined = -500
Global Const e4info = -910
Global Const e4memory = -920
Global Const e4parm = -930
Global Const e4result = -950
Function b4$ (p&)
'This is a utility function for copying a DLL string pointer to a VB string.
Dim rc%
Dim s As String * 256
s$ = ""
rc% = u4ncpy(s$, (p&), 255)
b4$ = Left$(s$, rc)
End Function
Function code4dateFormat$ (c4codePtr&, Fmt$)
'This function returns and optionally modifies the
'CODE4.dateFormat member
Dim in As String * 19
Dim DatePtr&, rc%
'If Fmt$ = "" then return present date format,
'otherwise change date format to Fmt$
DatePtr = code4dateFormatCB(c4codePtr&, Fmt$)
'Copy to VB string and trim any null characters
rc% = u4ncpy(in$, DatePtr, 19)
code4dateFormat$ = Left$(in$, rc%)
End Function
Function d4alias$ (dbPtr&)
'This function returns the data file alias
Dim AliasPtr&
Dim AliasName As String * 11
'Get pointer to alias string
AliasPtr& = d4aliasCB(dbPtr)
'Copy to VB string and trim null character(s)
rc% = u4ncpy(AliasName$, AliasPtr&, 11)
d4alias$ = Left$(AliasName$, rc%)
End Function
Function d4create& (ByVal cb&, dbname$, d() As FIELD4INFO, n() As TAG4INFO)
' d4create calls d4createCB() to create a new database.
' This function is the same as d4createData() except that
' it requires an additional parameter which it uses to
' create tag information for a database.
'
' Variable n is an array of type TAG4INFO which corresponds
' to TAG4INFOCB, a structure that can be used by d4create.
' The difference once again is merely the difference in the
' representation of strings between C and Basic.
' d4create takes the contents from the TAG4INFO structure
' and builds a TAG4INFOCB structure which it passes to d4createCB().
' Note: the TAG4INFOCB array is one size larger than the TAG4INFO
' array. The extra empty (zero filled) array element is the
' way that d4createCB() detects the end of the array.
Dim i%
Dim flb%
Dim fub%
Dim fs%
Dim tlb%
Dim tub%
Dim ts%
flb = LBound(d)
fub = UBound(d)
fs = fub - flb + 1
ReDim f(1 To (fs + 1)) As FIELD4INFOCB
For i = 1 To fs
f(i).fname = v4Cstring(d((flb - 1) + i).fname) ' note: this function allocates memory
f(i).ftype = Asc(d((flb - 1) + i).ftype)
f(i).flength = d((flb - 1) + i).flength
f(i).fdecimals = d((flb - 1) + i).fdecimals
Next i
tlb = LBound(n)
tub = UBound(n)
ts = tub - tlb + 1
ReDim t(1 To (ts + 1)) As TAG4INFOCB
For i = 1 To ts
t(i).name = v4Cstring(n((tlb - 1) + i).name)
t(i).expression = v4Cstring(n((tlb - 1) + i).expression)
t(i).filter = v4Cstring(n((tlb - 1) + i).filter)
t(i).unique = n((tlb - 1) + i).unique
t(i).descending = n((tlb - 1) + i).descending
Next i
d4create = d4createCB(cb&, ByVal (dbname$), f(1), t(1))
' Since v4Cstring allocates memory for the storage of
' C strings, we must free the memory after it has been
' used.
For i = 1 To fs
Call v4Cstringfree(f(i).fname)
Next i
For i = 1 To ts
Call v4Cstringfree(t(i).name)
Call v4Cstringfree(t(i).expression)
Call v4Cstringfree(t(i).filter)
Next i
End Function
Function d4createData& (ByVal cb&, dbname$, d() As FIELD4INFO)
' d4createData() calls d4createCB() to create a new database.
' d4create() builds the FIELD4INFOCB array which is
' the one recognized by d4create (note that the only difference
' is that the fname field is a string in type FIELD4INFO
' and type long in FIELD4INFOCB which is how strings are represented
' in C). Furthermore, the size of f (our FIELD4INFOCB array) is one
' larger than the size s of FIELD4INFO d. This is because
' d4create doesn't know the size of the array f and therefore it stops
' when it reaches an array element that is filled with zeros which
' the extra (s+1)'th element of f provides.
Dim i%
Dim lb%
Dim ub%
Dim s%
lb = LBound(d)
ub = UBound(d)
s = ub - lb + 1
ReDim f(1 To (s + 1)) As FIELD4INFOCB
For i = 1 To s
f(i).fname = v4Cstring(d((lb - 1) + i).fname)' note: this function allocates memory
f(i).ftype = Asc(d((lb - 1) + i).ftype)
f(i).flength = d((lb - 1) + i).flength
f(i).fdecimals = d((lb - 1) + i).fdecimals
Next i
d4createData = d4createCB(cb&, ByVal (dbname$), f(1), ByVal (0&))
' Since v4Cstring allocates memory for the storage of
' C strings, we must free the memory after it has been
' used.
For i = 1 To s
Call v4Cstringfree(f(i).fname)
Next i
End Function
Function d4fileName$ (dbfPtr&)
d4fileName$ = b4(d4fileNameCB(dbfPtr))
End Function
Function date4cdow$ (dateString$)
'This function returns the day of the week in a character
'string based on the value in 'DateString'
'Validate "dateString"
If dateString = "" Or Len(dateString) < 8 Then Exit Function
Dim DatePtr&
DatePtr& = date4cdowCB(dateString) 'Get pointer to day
If DatePtr = 0 Then Exit Function 'Illegal date
Dim rc%
Dim inDay As String * 10
rc% = u4ncpy(inDay$, DatePtr&, 10) 'Copy it to inDay
date4cdow$ = Left$(inDay$, rc%) 'Trim null characters
End Function
Function date4cmonth$ (dateString$)
'This function returns the month in 'DateString' as a
'character string
'Validate "DateString"
If dateString = "" Or Len(dateString) < 8 Then Exit Function
Dim DatePtr&
DatePtr& = date4cmonthCB(dateString) 'Get pointer to month
If DatePtr = 0 Then Exit Function 'Illegal date
Dim rc%
Dim inMonth As String * 10
rc% = u4ncpy(inMonth$, DatePtr&, 10) 'Copy it to inMonth
date4cmonth$ = Left$(inMonth$, rc%) 'Return month
End Function
Sub date4format (dateString$, Result$, pic$)
'This functions formats Result$ using the date value
' in 'dateString$' and the format info. in 'Pic$'
'Size Result$
Result$ = Space$(Len(pic$) + 1)
Call date4formatCB(dateString$, Result$, pic$)
Result$ = Left$(Result$, Len(pic$))
End Sub
Sub date4init (Result$, dateString$, pic$)
'This functions formats Result$ using the date value
' in 'dateString$' and the format info. in 'Pic$'
'Size Result$
Result$ = Space$(Len(pic$) + 1)
Call date4initCB(Result$, dateString$, pic$)
Result$ = Left$(Result$, Len(pic$))
End Sub
Sub date4today (dateS As String)
If Len(dateS) < 8 Then dateS = Space$(8)
Call date4todayCB(dateS)
End Sub
Function f4memoStr$ (fPtr&)
'This function returns a string corresponding to the memo
'field pointer argument.
Dim MemoLen&, MemoPtr&, rc%
MemoLen& = f4memoLen(fPtr) + 1 'Get memo length
MemoPtr& = f4memoPtr(fPtr)
If MemoPtr& = 0 Then Exit Function
Dim MemoString$
MemoString = String$(MemoLen&, " ")
'Copy 'MemoPtr' to VB string 'MemoString'
rc% = u4ncpy(MemoString$, MemoPtr&, MemoLen&)
'Remove null character and return memo contents
f4memoStr$ = Left$(MemoString$, rc%)
End Function
Function f4name$ (fPtr&)
'This function returns the name of a field
Dim FldNamePtr& 'Pointer to field name
Dim FldName As String * 11 'String to hold info
Dim rc%
FldNamePtr& = f4nameCB(fPtr) 'Get pointer
'Copy to string 'FldName' and remove null character(s)
rc% = u4ncpy(FldName$, FldNamePtr&, 11)
f4name$ = Left$(FldName$, rc%)
End Function
Function f4str$ (Field&)
'This function returns the contents of a field
Dim s$, fPtr&
Dim rc%, flen%
flen = f4len(Field) 'Get field length
s$ = Space$(flen + 1) 'Make s$ one byte longer for null character that u4ncpy adds
fPtr& = f4ptr(Field)
If fPtr& = 0 Then Exit Function
rc% = u4ncpy(s$, fPtr&, flen + 1) 'Copy field contents
f4str$ = Left$(s$, flen%) 'Remove null character
End Function
Function i4create& (ByVal dbPtr&, IndexName$, n() As TAG4INFO)
' i4create() calls i4createCB() to create a new
' index file. Variable n is an array of type TAG4INFO
' which corresponds to TAG4INFOCB, a structure that
' can be used by i4createCB(). The difference once
' again is merely the difference in the representation
' of strings between C and Basic.
'
' i4create() takes the contents from the TAG4INFO
' structure and builds a TAG4INFOCB structure which
' it passes to i4createCB(). Note: the TAG4INFOCB
' arrary is one size larger than the TAG4INFO array.
' The extra empty (zero filled) array element is the
' way that d4create detects the end of the array.
'
' Note also, that if 'IndexName' is an empty string,
' the index file that is created will become a
' "production" index file. i.e. it will be opened every
' time the corresponding data file is opened.
Dim i%
Dim tlb%
Dim tub%
Dim ts%
tlb = LBound(n)
tub = UBound(n)
ts = tub - tlb + 1
ReDim t(1 To (ts + 1)) As TAG4INFOCB
For i = 1 To ts
t(i).name = v4Cstring(n((tlb - 1) + i).name)
t(i).expression = v4Cstring(n((tlb - 1) + i).expression)
t(i).filter = v4Cstring(n((tlb - 1) + i).filter)
t(i).unique = n((tlb - 1) + i).unique
t(i).descending = n((tlb - 1) + i).descending
Next i
If IndexName$ = "" Then 'User wants production index file
i4create = i4createCB(dbPtr&, ByVal 0&, t(1))
Else
i4create = i4createCB(dbPtr&, IndexName$, t(1))
End If
' Since v4Cstring allocates memory for the storage of
' C strings, we must free the memory after it has been
' used.
For i = 1 To ts
Call v4Cstringfree(t(i).name)
Call v4Cstringfree(t(i).expression)
Call v4Cstringfree(t(i).filter)
Next i
End Function
Function i4open& (d4&, fname$)
If fname = "" Then
i4open = i4openCB(d4&, ByVal 0&) 'Use data file name
Else
i4open = i4openCB(d4&, fname$) 'Use supplied name
End If
End Function
Function t4key$ (tPtr&)
'This function returns the value of the current key
Dim KeyPtr&, KeyLen%, KeyBuf$
KeyLen% = tag4KeyLen(tPtr&) + 1
KeyBuf$ = Space(KeyLen%)
'Get pointer to key info
KeyPtr& = t4keyCB(tPtr&)
If KeyPtr& = 0 Then Exit Function
'Copy to VB string
rc% = u4ncpy(KeyBuf$, KeyPtr&, KeyLen%)
'Trim null character(s)
t4key$ = Left$(KeyBuf$, rc%)
End Function
Function tag4alias$ (tPtr&)
'This function returns the alias of an index tag
Dim AliasPtr&
Dim AliasName As String * 11
'Get pointer to alias string
AliasPtr& = tag4aliasCB(tPtr&)
'Copy to VB string
rc% = u4ncpy(AliasName$, AliasPtr&, 11)
'Trim null character(s)
tag4alias$ = Left$(AliasName$, rc%)
End Function
Function tag4expr$ (tPtr&)
'This function returns the original tag expression
Dim ExprPtr&
Dim expr As String * 255
'Get pointer to parsed dBASE expression
ExprPtr& = tag4exprCB(tPtr&)
'Copy to VB string and trim null character(s)
rc% = u4ncpy(expr$, ExprPtr&, 255)
tag4expr$ = Left$(expr$, rc%)
End Function
Function tag4Filter$ (tPtr&)
'This function returns the tag filter expression
Dim FilterPtr&
Dim filter As String * 255
'Get pointer to parsed filter expression
FilterPtr& = tag4filterCB(tPtr&)
If FilterPtr& = 0 Then 'No filter
tag4Filter$ = ""
Exit Function
End If
'Copy to VB string and trim null character(s)
rc% = u4ncpy(filter$, FilterPtr&, 255)
tag4Filter$ = Left$(filter$, rc%)
End Function
Function u4descend$ (charString$)
Dim Result$, i%
For i = 1 To Len(charString)
Result = Result + Chr$(128 And Asc(Mid$(charString, i, 1)))
Next
u4descend = Result
End Function