Using Records

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
stevenwhyte
Posts: 14
Joined: Mon Jan 12, 2015 7:55 pm

Using Records

Post by stevenwhyte » Mon Jan 12, 2015 7:59 pm

Hello,

I need some help. I've not had much experience of implementing a record data structure in LiveCode and wondered how the following pseudocode would translate into LiveCode:

TYPE runner IS RECORD {STRING Participant, REAL Time, BOOLEAN Qualified}
SET race[0] TO {Participant = “Mark”, Time = 4.56, Qualified = False}
SET race[1] TO {Participant = “Greg”, Time = 4.32, Qualified = True}
SET race[2] TO {Participant = “Iain”, Time = 5.01, Qualified = False}
SET race[3] TO {Participant = “Peter”, Time = 4.61, Qualified = False}
SET race[4] TO {Participant = “Steve”, Time = 4.55, Qualified = True}
SET race[5] TO {Participant = “Ahmed”, Time = 5.12, Qualified = False}


Many thanks,

Steven

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Using Records

Post by Klaus » Mon Jan 12, 2015 8:50 pm

Hi Steven,

1. welcome to the forum! :D

2. No idea what a RECORD is, but this looks like a task for an Livecode ARRAY:
...
## No need to define a data type in LC!
put "Mark" into race[1]["Participant"]
put 4.56 into race[1]["time"]
put FALSE into race[1]["qualified"]
put "Greg" into race[2]["Participant"]
etc...
...
Address it like this:
put race[2]["time"] into fld "race 2 time"

You get the picture :D


Best

Klaus

stevenwhyte
Posts: 14
Joined: Mon Jan 12, 2015 7:55 pm

Re: Using Records

Post by stevenwhyte » Sat Jan 17, 2015 8:50 pm

Many thanks for your help with this Klaus. It worked perfectly! :D

Post Reply