Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Reading a file that was created with Array.Length? AGK V2

Author
Message
kozma_11
21
Years of Service
User Offline
Joined: 17th Sep 2003
Location: Scotland
Posted: 6th Jul 2016 21:27
Hi,

I've been struggling to find a solution to this one, any help appreciated!

Say I created a file using the following code, and my array has 5 entries (i.e. EClub.Length = 5)



How can I then read in the data when it won't know that there is 5 entries in the array? I've tried using a repeat until but I just get an error saying the Array is out of bounds.


El Presidente
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Jul 2016 22:02 Edited at: 6th Jul 2016 22:04
its more easy if you write the count also into the file EClub.Length
at load you read it have a loop count and can define the array.
AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Jul 2016 22:29 Edited at: 6th Jul 2016 22:33
The .insert() Method works quite well for these situations.



this is a good read for all new array methods;
https://www.appgamekit.com/documentation/guides/12_array_changes.htm
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jul 2016 07:45
You have used an UNTIL loop.If you use a WHILE loop it will exit before you get an out of bounds error.
UNTIL always processes the loop one more time after the condition is met.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
kozma_11
21
Years of Service
User Offline
Joined: 17th Sep 2003
Location: Scotland
Posted: 10th Jul 2016 18:48
Thanks for the replies guys, some good advice. Hopefully I can fix it now!
El Presidente

Login to post a reply

Server time is: 2024-09-29 15:23:25
Your offset time is: 2024-09-29 15:23:25