Restored from previous forum. Originally posted by cor.
What is the best way to check array overflow at your source.
I have a lot of arrays.
All suggestions are welcome
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Check Array overflow ?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tranquil.
He means how to check if he tries to write datas to an array which is out of range. for eg:
dim Test.s(1000)
test.s(1001)="bla"
One way is to check your field-value before you write to your array.
eg:
#namearray=50
dim name.s(#namearray)
position=30
if position<=#namearray
name.s(position)="blabla"
endif
The Debugger of PureBasic does not report if you try to write datas in a "Dimension out of range", which is standard in every other basic language. Fred!?
But indeed, the best way is to use linked lists.
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
He means how to check if he tries to write datas to an array which is out of range. for eg:
dim Test.s(1000)
test.s(1001)="bla"
One way is to check your field-value before you write to your array.
eg:
#namearray=50
dim name.s(#namearray)
position=30
if position<=#namearray
name.s(position)="blabla"
endif
The Debugger of PureBasic does not report if you try to write datas in a "Dimension out of range", which is standard in every other basic language. Fred!?
But indeed, the best way is to use linked lists.
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.

It's a feature, it allows us to do some nice and powerfull tricks with dimed vars..Originally posted by tranquil
The Debugger of PureBasic does not report if you try to write datas in a "Dimension out of range", which is standard in every other basic language. Fred!?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm