Rev equiv of VB Type data handler
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller
-
- Posts: 24
- Joined: Tue Jun 23, 2009 9:38 am
Rev equiv of VB Type data handler
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??
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??
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Yep, nested arrays hold the answer.
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.
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"]
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
...but you can't do anything like
...sorry.
User-defined types would be very nice, and someday <sigh> we'll get them, but for now I just use nested arrays.
Code: Select all
Dim CurrNode as Node
User-defined types would be very nice, and someday <sigh> we'll get them, but for now I just use nested arrays.
-
- Posts: 24
- Joined: Tue Jun 23, 2009 9:38 am
thanks
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
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
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
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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 24
- Joined: Tue Jun 23, 2009 9:38 am
Agreed, that is very clever.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
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.