harishsc
asked on
Some explanation on the code
Can somebody please explain to me what does the below code do?
Class StringClass
'Global Variables
Private m_array
Private m_length
Private m_buffer
Private m_growthSize
'Constructor (sort of)
Private Sub Class_Initialize
m_array = Array()
m_length = 0
m_buffer = 0
m_growthSize = 32'Dynamically grows inside Append()
End Sub
'Public Methods
Public Function Append(ByVal value)
Dim ValueLen: ValueLen = Len(value)
Do While ValueLen > m_buffer
ReDim Preserve m_array(UBound(m_array) + m_growthSize)
m_buffer = m_buffer + m_growthSize
m_growthSize = m_growthSize * 2
Loop
For i = 0 To ValueLen - 1
m_array(m_length) = Mid(value, i + 1, 1)
m_length = m_length + 1
m_buffer = m_buffer - 1
Next
End Function
'Properties
Public Property Get Length
Length = m_length
End Property
Public Property Get Text
Text = Join(m_array, "")
End Property
Public Property Let Text(ByVal value)
'Reset the array without reducing the current capacity.
m_array = Array(m_length + m_buffer - 1)
m_buffer = m_length + m_buffer
m_length = 0
Append(value)
End Property
End Class
Thanks
Harish
Class StringClass
'Global Variables
Private m_array
Private m_length
Private m_buffer
Private m_growthSize
'Constructor (sort of)
Private Sub Class_Initialize
m_array = Array()
m_length = 0
m_buffer = 0
m_growthSize = 32'Dynamically grows inside Append()
End Sub
'Public Methods
Public Function Append(ByVal value)
Dim ValueLen: ValueLen = Len(value)
Do While ValueLen > m_buffer
ReDim Preserve m_array(UBound(m_array) + m_growthSize)
m_buffer = m_buffer + m_growthSize
m_growthSize = m_growthSize * 2
Loop
For i = 0 To ValueLen - 1
m_array(m_length) = Mid(value, i + 1, 1)
m_length = m_length + 1
m_buffer = m_buffer - 1
Next
End Function
'Properties
Public Property Get Length
Length = m_length
End Property
Public Property Get Text
Text = Join(m_array, "")
End Property
Public Property Let Text(ByVal value)
'Reset the array without reducing the current capacity.
m_array = Array(m_length + m_buffer - 1)
m_buffer = m_length + m_buffer
m_length = 0
Append(value)
End Property
End Class
Thanks
Harish
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't see how the StringClass applies to your current code...
@harishsc : I dont think you can really change much about your code as far as the strings go.
ASKER
<%
With o_Rec
Do while not .EOF
strShopper = .Fields("community_name").
if IsNull(strShopper) then ''Try using IsNull Here and see if its appropriate
if not bolDictExists(o_DiscDict,s
Set o_DiscDict(strShopper) = Server.CreateObject("Comme
end if
Set objShopperDiscounts = o_DiscDict(strShopper)
str_SKU = .Fields("sku").Value
if not bolDictExists(objShopperDi
Set objShopperDiscounts(str_SK
end if
Set objSkuDiscount = objShopperDiscounts(str_SK
objSkuDiscount("disc_type"
objSkuDiscount("disc_value
objSkuDiscount("Local_Fixe
objSkuDiscount("USD_FixedP
End if
.MoveNext
Loop
End With
%>