Arrays in Rev

Jan Schenkel janschenkel at yahoo.com
Fri Dec 10 01:15:12 EST 2004


--- Gordon <gwalias-rev at yahoo.com> wrote:
> Dear Revolutionaries
> 
> Can an element of a rev array be another array?
> 
> If not, is there any way to achieve the effect of
> nesting arrays - OR if not, is there some way to
> create new container types (like the structures and
> unions typical in C and Pascal). Basically - how do
> I
> create complex organized containers (objects) to
> hold
> my data?
> 
> Best
> 
> Gordon
> 

Hi Gordon,

As Xavier pointed out, there are no nested arrays in
Revolution. In addition to his suggestion to use the
"split" and "combine" commands when needed, I'd like
to point at the other two options : crafting array
keys to simulate the behaviour, and using XML trees as
a way to hierarchically store information into nodes.

1. Array keys
Revolution arrays are actually associative arrays,
which means that the keys can be any string, and you
can use separators as much as you like. Example :
--
  put "01/01/2003" into \
      tCustomerData["1,history,23,date"]
  put tCustomerData["78,contacts,3,phone"] into \
      tPhoneNumber
--

2. XML trees
If you build your tree correctly, you can get the
content of your data using calls like :
--
  put "data/customers[1]/history[23]/date" into \
      tNode
  revPutIntoXMLNode tXMLTree,tNode,"01/01/2003"
  put "data/customers[78]/contacts[3]/phone" into \
      tNode
  put revXMLNodeContents(tXMLTree,tNode) into \
      tPhoneNumber
--
For more information about XML and how Rev supports
it, make sure to download the tutorial by Sarah
Reichelt, available from the Runtime Revolution
website at :
<http://support.runrev.com/resources/xml.php>

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 



More information about the use-livecode mailing list