Updating the size of an array

Post Reply
Massage_Dude
Posts: 2
Joined: Mon Sep 22, 2014 9:30 pm
My devices: Iphone 5
someday IPhone 6 Plus

Updating the size of an array

Post by Massage_Dude »

I am wanting to save a list of peoples names into a file!
Initially, the list is small but I want my program to add names to my list.
My difficulty is that I want my People$() array to increase in size as names are added!

This so my program can allocate People$(# according to list in file at start up!)
Understand what I don't understand? I could use some help.

Some example code might be helpful.
Thanks

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Updating the size of an array

Post by Mr. Kibernetik »

You cannot increase size of your array and keep its old values intact.
If you create array of bigger size, it is re-initialized.

So you have to create your own algorithm of adding new values to your array.
There can be many different approaches, for example use intermediate array to keep old values before you increase size of your array.

Massage_Dude
Posts: 2
Joined: Mon Sep 22, 2014 9:30 pm
My devices: Iphone 5
someday IPhone 6 Plus

Re: Updating the size of an array

Post by Massage_Dude »

Thank you for your quick response.
I have some ideas I think may work.

I'll update this post after my idea is tried and hopefully succeeds!

- I value your time! Thanks

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Updating the size of an array

Post by Henko »

You might have a look into the program "password manager" in this program section.
There an extensible array of strings is used to fully fit in a UI list. With "add" and "delete" functions

Post Reply