Hello all,
For some reason, this code has started to fail yielding an out of bounds exception.
Here’s the code:
The class clsSendTwilioBuffer contains no methods, only 7 properties; most are string, but some are integer.
Private Property SendTwilioBuffer(-1) As clsSendTwilioBuffer
In the Constructor of the same class:
SendTwilioBuffer(-1) = New clsSendTwilioBuffer
This used to work (sorry I don’t recall the Xojo version). In 2023r3.1 and 2023R4 it gives the out of bounds exception.
What am I doing wrong??
Thanks,
TIm
SendTwilioBuffer(-1)
is an array?
Hello Andrew
Yes, it is. I just tried changing the Property from (-1) to (0) and the same with the instantiation. That worked. But not sure why!
Tim
Tim_Hare
(Tim Hare)
January 17, 2024, 11:44pm
4
That should never have worked. Do you mean to add a new element to the array? That would be
SendTwilioBuffer.Add New clsSendTwilioBuffer
Hi Tim,
I wanted the array to be empty to start, then add to the array. Once the work has been done with the values in the array, I remove them one at a time. That was the reason behind using (-1).
Obviously that did not work as planned!
Tim
Tangential to the main topic, this is not necessarily invalid Xojo syntax. If the class had an Operator_Convert() As ClassName()
method, for example.
Class FooBar
Public Function Operator_Convert() As FooBar()
End Class
Dim foos() As FooBar = New FooBar
But this is more of a syntactical parlor trick than a useful design pattern.
Hi Andrew,
No such parlor tricks here…
Thanks for your response!
Tim
MarkusR
(MarkusR)
January 18, 2024, 11:36am
8
I wanted the array to be empty to start
maybe try
Private Property SendTwilioBuffer() As clsSendTwilioBuffer
see
Add
RemoveAll
ResizeTo
https://documentation.xojo.com/api/language/arrays.html