dynamic string lite object
ReDim automatic
ONE based index
array referenced with LONG handle
StrBuff and BArr handles interchangeable
array may be stored/restored to string
DLL in zip file
Code:
'pbcc 5, pbwin 9 (pb 4/8 ok) 'dynamic BYTE array lite object (not OOP object) ' ReDim automatic ' ONE based index ' 'array referenced with LONG handle ' StrBuff and BArr handles interchangeable ' 'array may be stored/restored to string ' Declare Function BArr_Alloc Lib "BArr_DLL-1.dll" () As Long 'create new array object 'return handle ' null if fail Declare Sub BArr_Free Lib "BArr_DLL-1.dll" (ByVal arr As Long) 'close array object 'free resources Declare Sub BArr_Clear Lib "BArr_DLL-1.dll" (ByVal arr As Long) 'delete all data Declare Function BArr_Count Lib "BArr_DLL-1.dll" (ByVal arr As Long) As Long 'get stored element count Declare Sub BArr_ReDim Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal Count As Long) 'ReDim array - data preserved Declare Sub BArr_Add Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Byte) 'append item 'redim automatic Declare Sub BArr_Insert Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long, ByVal item As Byte) 'insert item at index 'redim automatic ' if index > array then item appended Declare Sub BArr_Delete Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long) 'delete array element at index 'redim automatic Declare Sub BArr_Set Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long, ByVal item As Byte) 'store item at index Declare Function BArr_Get Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long) As Byte 'get item at index Declare Function BArr_BinFind Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Byte) As Long 'binary search for "item" ' return index if found ' -1 if not found Declare Function BArr_BinFindPosition Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Byte) As Long 'binary search for the position where "item" is, or should be Declare Function BArr_BinInsert Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Byte) As Long 'binary insert item ' array must sorted 'return index ' -1 if fail Declare Sub BArr_BinSort Lib "BArr_DLL-1.dll" (ByVal arr As Long) 'sort array ' (slow sort) Declare Function BArr_Store Lib "BArr_DLL-1.dll" (ByVal arr As Long) As String 'store array in string Declare Function BArr_StoreValidate Lib "BArr_DLL-1.dll" (ByRef storedArr As String) As Long 'validate storage string ' string has front and back DWord validation hash cookies Declare Sub BArr_Restore Lib "BArr_DLL-1.dll" (ByVal arr As Long, ByRef storedArr As String) 'restore array from string made with: BArr_Store() ' current contents of array will be lost 'dynamic string lite object ' StrBuff and BArr handles interchangeable ' indexes ONE based Declare Function StrBuff_Alloc Lib "BArr_DLL-1.dll" () As Long 'allocate new lite object Declare Function StrBuff_AllocSet Lib "BArr_DLL-1.dll" (ByRef s As String) As Long 'allocate new instance 'set string ' return handle Declare Sub StrBuff_Free Lib "BArr_DLL-1.dll" (ByVal str As Long) 'free lite obj Declare Sub StrBuff_Clear Lib "BArr_DLL-1.dll" (ByVal str As Long) 'null string Declare Sub StrBuff_Set Lib "BArr_DLL-1.dll" (ByVal str As Long, ByVal s As String) 'set string Declare Function StrBuff_Get Lib "BArr_DLL-1.dll" (ByVal str As Long) As String 'get string Declare Function StrBuff_Len Lib "BArr_DLL-1.dll" (ByVal str As Long) As Long 'get array as string Declare Function StrBuff_Compare Lib "BArr_DLL-1.dll" (ByVal strA As Long, ByVal strB As Long) As Long 'compare two Byte arrays as strings - case sensitive ' <0 : strA < strB ' =0 : strA = strB ' >0 : strA > strB Declare Function StrBuff_CompareNoCase Lib "BArr_DLL-1.dll" (ByVal strA As Long, ByVal strB As Long) As Long 'compare two Byte arrays as strings - case insensitive ' <0 : strA < strB ' =0 : strA = strB ' >0 : strA > strB Declare Function StrBuff_CompareStr Lib "BArr_DLL-1.dll" (ByRef s As String, ByVal str As Long) As Long 'compare string to byte array - case sensitive ' <0 : s < str ' =0 : s = str ' >0 : s > str Declare Function StrBuff_CompareStrNoCase Lib "BArr_DLL-1.dll" (ByRef s As String, ByVal str As Long) As Long 'compare string to byte array - case insensitive ' <0 : s < str ' =0 : s = str ' >0 : s > str Declare Function StrBuff_Hash Lib "BArr_DLL-1.dll" (ByVal str As Long, ByVal totalSlots As Long) As Long 'get stored string's hash ' for use with ONE based index 'use case 'thanks to Paul Squires Declare Function StrBuff_HashNoCase Lib "BArr_DLL-1.dll" (ByVal str As Long, ByVal totalSlots As Long) As Long 'get stored string's hash ' for use with ONE based index 'ignore case 'thanks to Paul Squires Declare Function StrBuff_Store Lib "BArr_DLL-1.dll" (ByVal str As Long) As String 'store string in wrapper container compatible with BArr stored arrays Declare Function StrBuff_StoreValidate Lib "BArr_DLL-1.dll" (ByRef storedStr As String) As Long 'validate storage string ' string has front and back DWord validation hash cookies Declare Sub StrBuff_Restore Lib "BArr_DLL-1.dll" (ByVal str As Long, ByRef storedStr As String) 'restore array from string made with: StrBuff_Store() ' current contents of array will be lost