Author Topic: Understanding arrays?  (Read 5483 times)

Tomas

  • Newbie
  • *
  • Posts: 7
Understanding arrays?
« on: December 09, 2011, 08:22:35 PM »
I think I understand lists but I'm having some difficulties understanding arrays. I need arrays because my program has to cope with text data that can have multiple lines. In another post it said arrays should be used in this case as lists were based on single lines. Perhaps someone can give me an example of how to place blocks of text into an array, and how to get them out again?

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 289
Re: Understanding arrays?
« Reply #1 on: December 12, 2011, 08:19:50 AM »
I think I understand lists but I'm having some difficulties understanding arrays. I need arrays because my program has to cope with text data that can have multiple lines. In another post it said arrays should be used in this case as lists were based on single lines. Perhaps someone can give me an example of how to place blocks of text into an array, and how to get them out again?

Hi Tomas

Arrays are fairly easy to use, just create one then enter data into it, retrieve data from it.

The code below creates an array called mydata having 10 rows and 3 columns
It then puts the value hello into the cell of row 6 column 2
It then retrieves the value from the cell of row 6 column 2

Code: [Select]
Local okay,value

Put ArrayCreateFN('mydata',10,3) into okay

ArrayPutValue('mydata',6,2,'hello')

Put ArrayValueFN('mydata',6,2) into value


Note, usually the array name, number of rows and columns would be stored in variables but in the above example are used directly to make it easier to understand.
Also the okay value was not checked to see if the array was successfully created or not.

There is some info on arrays in the in-built help and help PDF.

http://www.hypernextandroid.com/binaries/HAC_help.pdf


The HyperNext Studio Language Reference PDF also has a chapter on arrays.

http://www.tigabyte.com/docs/LanguageReference.pdf


Malkom


I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

Tomas

  • Newbie
  • *
  • Posts: 7
Re: Understanding arrays?
« Reply #2 on: December 13, 2011, 07:04:33 AM »
Thank you, thats easy enough.