Help - how to do a thing!
#1
Hey,

For my XinBox 2 script, users will have FOLDERS just like Outlook express.
They can have as many folders inside folders etc as they want.

I need ideas of how to keep track of this.
I have a DB that will hold the info but can't think of a good way to do this.
On the screen, it is just a control list, when the user opens a folder, the sub folders are added to the list under that position etc etc.

Inbox -
----Matt Box +
----Matt2 Box -
------Foooo
------Foo2
Outbox

etc

I just can't think of a good way to keep track of each folder heirichy and list postion.

I want it to also remember wich fodlers are open etc.

Any thoughts by a smarty person?
Reply
#2
I would give each structure two fields for hierarchy. ID and Parent_ID
Then say Inbox has an ID of 1 then 'Matt Box' and 'Matt2 Box' would have a Parent_ID of 1

for controlling what is open, have another field called 'open', then when building the list if a folder has 'open' set to true, then open it up and also make sure all parents of that folder are also opened up.
Reply
#3
that was my original plan.
But, say they just close Matt2 Box.
I will need to remove the list items of Fooo and Foo2.
Easy, I will go find any entries in the DB with a parent ID which == Matt2 box id and remove these from the list if they are "open"

Ok, no problems there:
But, if they close Inbox.
It will need to find all entries with the parent ID which == Inbox (Matt Box, Matt Box2).
But, then it will need to remove any folders inside those.
And then there could more folders in there etc etc.

How can i do that?
A loop maybe?
Reply
#4
This is how i would do the list:

The SQL DB is opened. I grab the Id's, names and open status of folders from the DB.
When the list of folders is created, they are assigned a INFO label of there DB unique ID.
(This is easier than trying to keep track of there ever changing position in the list in the DB as folders are opened/closed.)
When a folder containing folders is closed, i run through the list items checking for the correct IDs in the list items info tag that is going to be removed and then remove that list item.
But, thinking it might take some time running through the list items, but thinking it would be quicker than updating each entry in the DB whenever the list gets larger/smaller.

Or...
i keep track of how many folders are in each folder, and then remove this amount below the current position selected on the list.... this may be a better way...
Reply
#5
Quote:How can i do that?
A loop maybe?

yeah, just loop through, use recursive programming.
I'm not sure how python works, but you should do a function and call it recursivelly

function CloseFolder(folder_id)
'find folder
'find all sub folders
for each subfolder
CloseFolder(subfolder.id)
end for
end function
Reply

Logout Mark Read Team Forum Stats Members Help
Help - how to do a thing!0