Re: Building and Saving Treeviews

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tony,

My previous reply might (?) have been in the right direction, but wasn't
quite right; the following routines seem to do the job, though you might
want to do better file checking.  I've tested these routines in the demo,
and they seem to work fine, but I'm not 100% sure if they'll work elsewhere;
I've assumed that the id numbers in "folders" can be used "as-is", and that
might not be true in every case.

Dan Moyer


------------------------------------------------------------------------
-- saves tree data to file:
procedure Click_MenuSave(integer self, integer event, sequence parms)
   sequence temp, temp2
   integer tempId
   temp = {}
   temp2 = {}

   handle = open( "Tree.txt", "w" )

-- for each element in folders, make an empty sequence in temp;
   for n = 1 to length(folders) do
     temp &= {{}}
   end for


-- look at each element in folder, one at a time;
-- put that into the sequence at same position in temp;
-- look for parent of item in temp,  place that id after item,
-- then add the items text after that.

-- then write it to file.

   for n = 1 to length( folders) do
     temp[n] &= folders[n]
           temp[n] &= {getTVParent(temp[n][1])}
           temp[n] &= {getTVText(temp[n][1])}
   end for

   print(handle, temp)
   close(handle)

end procedure
-----------------------------------------------------------------

-- retrieves saved tree info, clears existing tree,
-- & rebuilds it with the saved info:
procedure Click_MenuGetTree(integer self, integer event, sequence parms)
sequence savedTree, result
savedTree = {}

-- first empty the tree:
  eraseItems(TV)

-- now get saved items:
   handle = open( "Tree.txt", "r" )
   result = get(handle)
   if result[1] = GET_SUCCESS then
      savedTree = result[2]
      folders = {}
      for n = 1 to length(savedTree) do
         folders &= addTVItem( TV, closefolder, openfolder, savedTree[n][3]
, savedTree[n][2] )
      end for
   end if
   close(handle)
end procedure



----- Original Message -----
From: "Tony Steward" <lockmaster67 at aol.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 16, 2002 11:56 PM
Subject: Building and Saving Treeviews


>
> Hi All,
> I asked this before but never really got the answers I wanted and I ran
> out of time. Now with time on my hands I'll try again.
>
> I am looking at the example that comes with win32lib 57.9.
> When a user creates a treeview as in the example titled tvedit.exw how
> can I save this TV to disk and rebuild it again later when I don't know
> how many branches/sub branches a user may have created.
>
> Thanks
> Tony Steward
>
> Give your hardest tasks to your lasiest workers.
> They will always find the easiest way to complete it.
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu