No it doesn't! Thanks to Kevin the function now looks like this:


function getMyObjects someGroup
  put empty into myControls
  repeat with controlNum = 1 to the number of controls in someGroup
    put the long name of control controlNum of someGroup into controlObject
    if word 1 of controlObject is "group" then
      add the number of layers in controlObject to controlNum
    end if
    put controlObject & return after myControls
  end repeat
  delete last char of myControls
  return myControls
end getMyObjects

Which is a little simpler than:

function getMyObjects someGroup
  if someGroup is empty then put the long name of the target into someGroup
  
  put getMyButtons(someGroup) into myObjects
  get getMyFields(someGroup)
  addTo_Container it, myObjects
  get getMyGroups(someGroup)
  addTo_Container it, myObjects
  return myObjects
end getMyObjects

on addTo_Container linesToAdd, @containerToSet
  if containerToSet is empty then
    put linesToAdd into containerToSet
  else if linesToAdd ‚ empty then
    put containerToSet & return & linesToAdd into containerToSet
  end if
end addTo_Container

function getMyButtons someGroup
  put empty into allNestedObjects
  put the number of buttons of someGroup into someMax
  repeat with btnNum = 1 to someMax
    put the long name of btn btnNum of someGroup into someObject
    put someObject & return after allNestedObjects
  end repeat
  delete last char of allNestedObjects
  return filterLevelOneObjects(allNestedObjects, someGroup, "button")
end getMyButtons

function getMyFields someGroup
  put empty into allNestedObjects
  put the number of flds of someGroup into someMax
  repeat with fldNum = 1 to someMax
    put the long name of fld fldNum of someGroup into someObject
    put someObject & return after allNestedObjects
  end repeat
  delete last char of allNestedObjects
  return filterLevelOneObjects(allNestedObjects, someGroup, "field")
end getMyFields

function getMyGroups someGroup
  if someGroup is empty then put the long name of the target into someGroup
  put allMyGroups(someGroup) into nestedGroups
  return filterLevelOneObjects(nestedGroups, someGroup, "group")
end getMyGroups

function filterLevelOneObjects objectIndex, someObject, objectType
  put "^" & objectType && "(" & anyQuotedReg() & ")" && "of" && someObject
into someReg
  put empty into filteredObjects
  repeat for each line someGroup in objectIndex
    if matchText(someGroup, someReg) is true then
      put someGroup & return after filteredObjects
    end if
  end repeat
  delete last char of filteredObjects
  return filteredObjects
end filterLevelOneObjects

function allMyGroups someObject
  if someObject is empty then put the name of the target into someObject
  put the number of groups of someObject into allNestedGroupNum
  put empty into myGroups
  repeat with groupNum = 1 to allNestedGroupNum
    put the long name of group groupNum of someObject into someGroupName
    put someGroupName & return after myGroups
  end repeat
  delete last char of myGroups
  return myGroups
end allMyGroups

function anyQuotedReg
  return quote & "[^" & quote & "]*" & quote
end anyQuotedReg


Which also works but is around 25 lines longer. Great, and in the process I
learnt about layers and the use of the word control to refer to objects.


Thanks Kevin


xxx


Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to