Page 1 of 1

Using Records

Posted: Mon Jan 12, 2015 7:59 pm
by stevenwhyte
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

Re: Using Records

Posted: Mon Jan 12, 2015 8:50 pm
by Klaus
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

Re: Using Records

Posted: Sat Jan 17, 2015 8:50 pm
by stevenwhyte
Many thanks for your help with this Klaus. It worked perfectly! :D