You don't even need to test for empty; you can use 'put ... after tArray[key]' whether it is currently empty or not.

so you could simply do

set the itemDel to tab
repeat for each line tRecord in tManyRecords
  put item 1 of tRecord into tParent
  put item 2 of tRecord into tChild
  put tChild & comma after aArray[tParent]
end repeat
put aArray[138] into msg -- 43,131,6, should appear in the msg box


NB - you do get the trailing comma, so you need to handle that properly in any subsequent processing
e.g. repeat for each item T in aArray[138] ... is fine.

-- Alex.


On 22/04/2016 08:39, Kay C Lan wrote:
This might get you started with your first problem of how to avoid
overwriting data.

Assuming your second long list is tab separated and been read into a
variable tManyRecords

set the itemDel to tab
repeat for each line tRecord in tManyRecords
   put item 1 of tRecord into tParent
   put item 2 of tRecord into tChild
   if (aArray[tParent] = empty)  then
     put tChild into aArray[tParent]
   else
   --add another child
     put aArray[tParent] & comma & tChild into aArray[tParent]
   end if
end repeat
put aArray[138] into msg -- 43,131,6 should appear in the msg box

--be careful about choosing a list delimiter
--comma is a BAD choice unless you KNOW it's ALWAYS going to be a number
--but even then someone's going to come along with 5,678 and use a comma as
a thousand separator

It's really just a matter of testing whether the Array Key is empty or not.

HTH
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to