Page 1 of 1

Rev equiv of VB Type data handler

Posted: Thu Oct 15, 2009 3:02 pm
by el_stupido
I am really keen to jump in to Run Rev having been a hypercard nut back in the day.

But when Hypercard pulled up stumps I somewhat reluctantly went back to VB.

One thing I can't work out from the manuals is how to make your own custom data types

ie in VB I'd do something like this:

Private Type Node
Row As Integer 'row of the actual node
Col As Integer 'column of the actual node
ParId As Integer 'parent node
ScoreF As Integer 'Score F (total cost)
ScoreG As Integer 'Score G (Cost of the path done)
ScoreH As Integer 'Score H (Estimated cost of the path to do)
Closed As Boolean 'indicates if the node is in the close list
End Type

then I could make an array in which each address in the array was the above custom data type, therefore giving me a very efficient way of storing a lot of info for each data element of the array

eg

Dim OpenList() as Node

I could also have different variables that are defined by this custom data type

Dim CurrNode as Node
Dim TargetNode as Node

And then pass data to the individual elements of the datatype:

TargetNode.Row = 34
TargetNode.Col = 25

....

So my question is...... How do I do something like this in Run Rev... It's basically arrays isn't it with sub arrays??

Posted: Thu Oct 15, 2009 7:56 pm
by Janschenkel
Yep, nested arrays hold the answer.

Code: Select all

put "John" into tContact["firstname"]
put "Doe" into tContact["lastname"]
put tContact into tContacts[1]
put "Jane" into tContacts[2]["firstname"]
put "Smith" into tContacts[2]["lastname"]
It's a flexible system, but of course you have to make sure to use the right keys for each field. I tend to use the same name for the key as the column name in the underlying database.

HTH,

Jan Schenkel.

Posted: Thu Oct 15, 2009 9:58 pm
by mwieder
...but you can't do anything like

Code: Select all

Dim CurrNode as Node
...sorry.

User-defined types would be very nice, and someday <sigh> we'll get them, but for now I just use nested arrays.

thanks

Posted: Fri Oct 16, 2009 1:13 am
by el_stupido
thanks for the quick feedback.

Arrays it is!

And yes, User-defined types would be very nice indeed. I love love love Hypertalk/Revscript... but there is beauty still in BASIC.

Heck user defined types have been in it since at QuickBASIC 4.0!!!

thanks again guys, I will start playing with arrays now

Posted: Fri Oct 16, 2009 7:51 am
by Mark
el_stupido,

The beauty of xTalk languages is that these languages are able to recognise data types by themselves. There is no need to define data types. I'd say that's very, very clever!

Mark

Posted: Sat Oct 17, 2009 3:56 am
by el_stupido
Mark wrote:el_stupido,

The beauty of xTalk languages is that these languages are able to recognise data types by themselves. There is no need to define data types. I'd say that's very, very clever!

Mark
Agreed, that is very clever.

I counter that sometimes making a data type is not so much for the benefit of the language itself but for the problem solving mind of the programmer.

It is for me anyway, but as has been noted, arrays are the key to this for me now.

I shall embrace arrays in due time I am sure.