Skip to content

Commit

Permalink
Fix overflow errors
Browse files Browse the repository at this point in the history
Closes #56
  • Loading branch information
sancarn committed Jul 21, 2022
1 parent 835bf4b commit f7d4594
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ Before `08/07/2021` a change log was not kept. We have retrospectively gone bac
* 2022-06-13 stdAcc FIX - Fix `stdAcc::CreateFromMouse()` on 64-bit
* 2022-06-13 stdAcc FIX - Fix incorrect parameter order for `stdAcc` helper method `PointToLongLong()`. Without the fix, incorrect elements were being selected by their location.
* 2022-06-13 stdAcc FIX - Fix Added check that acc is desktop to `getPath()`.
* 2022-06-13 stdWindow FEATURE - Added `Get/Let isTopMost`, useful for userforms.
* 2022-06-13 stdWindow FEATURE - Added `Get/Let isTopMost`, useful for userforms.
* 2022-07-21 stdArray FIX - Fix `pLength` is defined as `Long` but numerous accessors defined as `integer`
28 changes: 14 additions & 14 deletions src/stdArray.cls
Original file line number Diff line number Diff line change
Expand Up @@ -495,34 +495,34 @@ Public Function Join(Optional ByVal delimeter As String = ",") As String
End Function

'Get/Let/Set item
'@param {integer} The location to get/set the item
Public Property Get item(ByVal i As Integer) As Variant
'@param {long} The location to get/set the item
Public Property Get item(ByVal i As long) As Variant
Attribute item.VB_UserMemId = 0
'item(1) = 1st element
'item(2) = 2nd element
'etc.
CopyVariant item, pArr(i)

End Property
Public Property Set item(ByVal i As Integer, ByVal item As Object)
Public Property Set item(ByVal i As long, ByVal item As Object)
set pArr(i) = item
End Property
Public Property Let item(ByVal i As Integer, ByVal item As Variant)
Public Property Let item(ByVal i As long, ByVal item As Variant)
pArr(i) = item
End Property

'Copy a variant into the array's ith element. This saves from having to test the item and call the correct `set` keyword
'@param {Long} The index at which the item's data should be set
'@param {ByRef Variant} Item to set at the index
Public Sub PutItem(ByVal i As Integer, ByRef item As Variant)
Public Sub PutItem(ByVal i As long, ByRef item As Variant)
CopyVariant pArr(i), item
End Sub

'Obtain the index of an element
'@param {Variant} Element to find
'@param {Ingeger?=1} Location to start search for element.
'@returns {integer} Index of element
Public Function indexOf(ByVal el As Variant, Optional ByVal start As Integer = 1) as integer
'@returns {long} Index of element
Public Function indexOf(ByVal el As Variant, Optional ByVal start As long = 1) as long
Dim elIsObj As Boolean, i As Long, item As Variant, itemIsObj As Boolean

'Is element an object?
Expand Down Expand Up @@ -557,7 +557,7 @@ End Function

'Obtain the last index of an element
'@param {Variant} Element to find
'@returns {integer} Last index of element
'@returns {long} Last index of element
Public Function lastIndexOf(ByVal el As Variant)
Dim elIsObj As Boolean, i As Long, item As Variant, itemIsObj As Boolean

Expand Down Expand Up @@ -593,8 +593,8 @@ End Function

'Returns true if the array contains an item
'@param {Variant} Item to find
'@param {Integer?=1} Index to start search for item at. (Internally uses indexOf())
Public Function includes(ByVal el As Variant, Optional ByVal startFrom As Integer = 1) As Boolean
'@param {long?=1} Index to start search for item at. (Internally uses indexOf())
Public Function includes(ByVal el As Variant, Optional ByVal startFrom As long = 1) As Boolean
includes = indexOf(el, startFrom) >= startFrom
End Function

Expand Down Expand Up @@ -626,7 +626,7 @@ End Function

Public Function IsSome(ByVal cb As stdICallable) As Boolean
If pInitialised Then
Dim i As Integer
Dim i As long
For i = 1 To pLength
Dim bFlag as Boolean
bFlag = cb.Run(pArr(i))
Expand All @@ -644,7 +644,7 @@ End Function

Public Sub ForEach(ByVal cb As stdICallable)
If pInitialised Then
Dim i As Integer
Dim i As long
For i = 1 To pLength
Call cb.Run(pArr(i))
Next
Expand All @@ -658,7 +658,7 @@ Public Function Map(ByVal cb As stdICallable) As stdArray
Dim pMap As stdArray
Set pMap = Me.Clone()

Dim i As Integer
Dim i As long
For i = 1 To pLength
'BUGFIX: Sometimes required, not sure when
Dim v As Variant
Expand Down Expand Up @@ -705,7 +705,7 @@ Public Function Reduce(ByVal cb As stdICallable, Optional ByVal initialValue As
If pInitialised Then
Reduce = initialValue

Dim i As Integer
Dim i As long
For i = 1 To pLength
'BUGFIX: Sometimes required, not sure when
Dim el As Variant
Expand Down

0 comments on commit f7d4594

Please sign in to comment.