BSTR - I like that you have added this as a virtual type but is there any reason why it's not as a native type?
CLASSES - I know PureBasic is not intended to be an OOP language but incorporating classes does not necessarily mean it is an OOP language. For example, VBScript (so others are not confused, I am referring to the scripting language, not VB) is not OO but includes the ability to create classes. Here's a VBScript example of a class so you can see what I am talking about:
Code: Select all
'**********************************************************************************************************************
' Allows for the efficient (very fast) building/concatenating of String variables.
'----------------------------------------------------------------------------------------------------------------------
' Usage:
' dim example
' set example = new StringBuilder
' example.Append("string 1")
' example.Append(":")
' example.Append("string 2")
'
' dim finalString
' finalString = example.Value ' finalString = "string 1:string 2"
'
' set example = nothing
'**********************************************************************************************************************
Class StringBuilder
Private StringCounter
Private StringArray()
Private StringLength
' Called at creation of instance.
Private Sub Class_Initialize()
const INIT_STRING_LENGTH = 128
StringCounter = 0
ReDim StringArray(INIT_STRING_LENGTH - 1)
StringLength = INIT_STRING_LENGTH
End Sub
Private Sub Class_Terminate()
Erase StringArray
End Sub
' Add new string to array
Public Sub Append(byref NewString)
if IsNull(NewString) then
StringArray(StringCounter) = ""
else
StringArray(StringCounter) = NewString
end if
StringCounter = StringCounter + 1
' ReDim array if necessary
If StringCounter MOD StringLength = 0 Then
' Redimension
ReDim Preserve StringArray(StringCounter + StringLength - 1)
' Double the size of the array next time
StringLength = StringLength * 2
End If
End Sub
' Return the concatenated string
Public Property Get Value
Value = Join(StringArray, "")
End Property
' Resets array
Public Function Clear()
const INIT_STRING_LENGTH = 128
StringCounter = 0
Redim StringArray(INIT_STRING_LENGTH - 1)
StringLength = INIT_STRING_LENGTH
End Function
End Class