Arrays in Rev
Frank D. Engel, Jr.
fde101 at fjrhome.net
Fri Dec 10 11:17:51 EST 2004
As far as records (C's struct types), there are at least two ways to do
this:
Mathod 1. Arrays
Since array keys can be strings, you can convert something like this:
VAR myRec : RECORD x, y : INTEGER END;
BEGIN
x := 5;
y := 7
END;
into something like this:
put 5 into myRec["x"]
put 7 into myRec["y"]
(Transcript's arrays are *really* cool...)
Method 2. Objects
You can also use custom properties on objects in place of fields on
records. So create a button called "myRec", then:
set the x of button "myRec" to 5
set the y of button "myRec" to 7
On Dec 10, 2004, at 1:15 AM, Jan Schenkel wrote:
> --- 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
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
-----------------------------------------------------------
Frank D. Engel, Jr. <fde101 at fjrhome.net>
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten
Son, that whosoever believeth in him should not perish, but have
everlasting life.
$
___________________________________________________________
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
More information about the use-livecode
mailing list