Re: Coding problem

Jean-Pierre DOUCET <[email protected]> Sun, 05 Aug 2018 22:05:36 +0200
Newsgroups gmane.comp.lang.realbasic.user
Message-ID <[email protected]>
Hi Daniel,
From the doco :
If you try to access an element of an array that does not exist, you will get an OutOfBoundsException <http://developer.xojo.com/outofboundsexception>. Here are some examples that would raise the exception:
aNames(5) = "Tom" ' this exceeds the upper bound of aNames
aFirstName(1) = "Bill" ' aFirstName is still empty
Use the methods Append <http://developer.xojo.com/arrays$Append> and Insert <http://developer.xojo.com/arrays$Insert> to add additional elements to arrays. These methods are the only ways to add elements to empty arrays, but they can also be used to extend the size of any single-dimension array.
Hence : Adr.Append (MyBin.readint32)

> Le 5 août 2018 à 19:42, Daniel Drijard <[email protected]> a écrit :
> 
> Hello, 
> 
>   I have a problem. I use macOS SIERRA (10.12.6) on an iMac Retina bought 9/2015. 
>   The following shows my code. The program blows up in this routine, pointing to Adr(i).
> 
> Cordially, 
> Daniel
> 
> •••••••••••••••
> Read4 Byref NbWords as integer, Byref Adr() as integer
> dim i as integer
> for i=1 to NbWords
>  Adr(i)=MyBin.readint32
> next
> 
> MyBin was declared as BinaryStream
> •••••••••••••••
> 
> Daniel Drijard
> Thoiry téléphone : 
>  04 50 41 22 75
>    international
>  +33/4 50 41 22 75
> Courriel :
>   [email protected]
> Thoiry F-01710
>   48, rue des Savoies
> 

Cordially,
JPD