Populating groups with data

Sarah Reichelt sarah.reichelt at gmail.com
Sat Feb 4 17:51:44 EST 2006


> I have data returned from a PHP script, like this:
>
> total number of tasks: 4
> project_id: 3|take trip|task_id: 47|get cookies|vanilla wafers,
> oreos, choc chip|duncan|3|
> project_id: 3|take trip|task_id: 46|buy funny hats|all kinds of hats|
> duncan|3|
> project_id: 3|take trip|task_id: 40|buy bikes|cool bikes!|duncan|3|
> project_id: 3|take trip|task_id: 48|get shiny stuff|shiny|duncan|3|
>
>
> I want the data to populate a scrolling group of groups that will
> look something like this:
>
> http://revcoders.org/populating-groups-with-data/

How about something like this:

put last word of tPHPdata into tNumGroups
delete line 1 of tPHPdata

set the itemDelimiter to "|"
repeat with g = 1 to tNumGroups
  put line g of tPHPdata into tLineData
  put item 2 of tLineData into field "ProjectName" of group ("Task" & g)
  put item 4 of tLineData into field "TaskName" of group ("Task" & g)
  put item 5 of tLineData into field "TaskDetails" of group ("Task" & g)
  put item 6 of tLineData into tTaskOwner
  if btn "TaskOwner" of group ("Task" & g) contains tTaskOwner is false then
    put cr & tTaskOwner after btn "TaskOwner" of group ("Task" & g)
  end if
  get lineOffset(tTaskOwner, btn "TaskOwner" of group ("Task" & g))
  set the menuHistory of btn "TaskOwner" of group ("Task" & g) to it
end repeat


This assumes that all the groups have been created and are called
"Task1", "Task2" etc. If they don't already exist, you need to clone
them and position them. If you make lots in advance, you may want to
show & hide them depending on how many are full.

BTW, I wasn't sure what all the data segments in your PHP data were,
but this should give you enough to display the rest wherever you need
them.

Cheers,
Sarah



More information about the use-livecode mailing list