Page 1 of 1

Memrec Group's Children Indexing / Group Options

Posted: Thu Aug 19, 2021 9:17 am
by EpicBirdi
Trying to write up some freeform functions I can pull from, but I'm not sure how to change the Index of children.. I see that you have access to a memrec's Index as read-only, and you can access a group's children via Child[index].

So.. how would I change a child's index under a group? Using appendToEntry() always puts it at the bottom of the group, and I'd like more control over that.

Currently I've just got this, but it doesn't work because the Index field is read-only, I'm guessing.

Code: Select all

local function childAppend(memDesc, parent)
  local al=getAddressList()
  for i=0,al.Count-1 do
    if al[i].Description == parent then
       trueParent = al[i]
    end
  end
  for i=0,al.Count-1 do
    if al[i].Description == memDesc then
       al[i].appendToEntry(trueParent)
    end
  end
  local TPCC = trueParent.Count -- Stores the index of the newly appended memrec
  trueParent[TPCC].Index = 0  -- Desired effect, anyway.. move the index/order of children.. can be expanded upon but I need this first
end
  -- trueParent.Child[TPCC].Index = 0 also doesn't work, presumably for the same reason?
I also fail to understand the Options property.. The wiki's small example doesn't really do it for me I guess.
I figured it was something like this, but no dice.

Code: Select all

Group.Options = [moHideChildren,moDeactivateChildrenAsWell]

Re: Memrec Group's Children Indexing / Group Options

Posted: Thu Aug 19, 2021 11:10 am
by aSwedishMagyar
So for the first problem, I would just save the memrecs in a table and do a loop that appends them in that order to the parent rec. You can create the table and then use table.insert to put your new record in the right spot.
EpicBirdi wrote:
Thu Aug 19, 2021 9:17 am
I also fail to understand the Options property.. The wiki's small example doesn't really do it for me I guess.
I figured it was something like this, but no dice.

Code: Select all

Group.Options = [moHideChildren,moDeactivateChildrenAsWell]
This is luckily a simple fix, the options need to be a string so just put quotes around them like this: "[moHideChildren,moDeactivateChildrenAsWell]"

Re: Memrec Group's Children Indexing / Group Options

Posted: Thu Aug 19, 2021 11:42 am
by EpicBirdi
Thanks again Magyar, pretty easy fixes both ways haha. Hopefully I can finish what I'm writing so I can post it soon.