Re: TreeView

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

------=_NextPart_000_0025_01C0054B.F1AB5F00
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,=20

Below is a working example of the method I use in a database that is =
similar to what I think you are going to use.
I Create the .edb first in the example (obviously) and open the file to =
gather the info created by the user (not all at once of course)
but as you'll see this will take away from haveing the world see the =
info in your text file and accomplish the same effect.

If I can be of further assistance let me know.

euman at bellsouth.net AKA Wayne Overman

-- Begin Code -------------------------------------------------

include win32lib.ew
include database.e

--- Create the Database -----------------------------------

integer i, ii, i1, fn
i1 =3D db_create("Automadb2",DB_LOCK_NO)
ii =3D db_open("Automadb2",DB_LOCK_NO)

i  =3D db_create_table("Alfa Romeo")
i  =3D db_select_table("Alfa Romeo")=20
ii =3D db_insert("Spyder", {"Engine","Tires","Tranny"})
ii =3D db_insert("model #2", {"Engine","Tires","Tranny"})

i  =3D db_create_table("BMW")
i  =3D db_select_table("BMW")=20
ii =3D db_insert("Model #1", {"Engine","Tires","Tranny"})
ii =3D db_insert("Anyother model", {"Engine","Tires","Tranny"})

fn =3D open("autoedb.txt", "w")
db_dump(fn, 0)
close(fn)

db_close()

--- Open to aquire info ---------------------------------------

constant
MainWin =3D create(Window, "Auto Program", 0, Default, Default, 800, =
600,0)

atom TV
TV =3D create(TreeView, "Treeview", MainWin, 10, 35, 200, 525,
 or_all({TVS_HASLINES, TVS_LINESATROOT, TVS_HASBUTTONS,
 TVS_SHOWSELALWAYS}))

integer DONE, open_db, closefolder, openfolder=20
DONE    =3D 0
open_db =3D -1
closefolder =3D addIcon( extractIcon( "clsdfold.ico" ))
openfolder  =3D addIcon( extractIcon( "openfold.ico" ))


procedure Auto_DB_class()
sequence Manufacturer_names, Machine_names, sub_class, folders
integer get_table, fx, gx, count, table_size, sub_class_count
Machine_names =3D {}
sub_class =3D {}

fx=3D1 gx=3D1 count=3D0

if DONE =3D 0 then
=20
open_db =3D db_open("Automadb2",DB_LOCK_NO)

     Manufacturer_names =3D db_table_list()=20
     folders =3D {}

     for x =3D 1 to length(Manufacturer_names) do  ------This is the =
(Automotive or any) manufacturer
         get_table =3D db_select_table(Manufacturer_names[x])
         folders &=3D addTVItem( TV, closefolder, openfolder, =
Manufacturer_names[x] , 0 )       =20
         fx =3D x + count

         table_size =3D db_table_size()

            for i =3D 1 to table_size do  ------------------------- This =
could be the model / models of the manufacturer
                Machine_names =3D db_record_key(i)=20
                folders &=3D addTVItem( TV, closefolder, openfolder, =
Machine_names , folders[fx] )
                sub_class =3D db_record_data(i)
                sub_class_count =3D length(sub_class)
                count +=3D 1
                gx =3D x + count               =20

                   for j =3D 1 to sub_class_count do  -------This could =
be any info on a particular Manufacturers Model i.e: Engine, Tires, =
Trans etc.      =20
                        folders &=3D addTVItem( TV, closefolder, =
openfolder, sub_class[j] , folders[gx] )
                        count +=3D 1 =20
                   end for

             sub_class =3D {}
             Machine_names =3D {}

             end for
       end for
    =20
     db_close()=20

     DONE =3D 1

else=20
end if

end procedure

onOpen[MainWin]=3Droutine_id("Auto_DB_class")

WinMain( MainWin, Normal )


--- End of Code =
------------------------------------------------------------


P.S there is a bug in Matts code=20

in win32lib.ew on line 9077

global function getParent( integer id )
    return tvitem_owner[ id ]
end function

This should be:

global function getParent( integer id )
    return tvitem_parent[ id ]
end function


  ----- Original Message -----=20
  From: Tony Steward=20
  To: EUPHORIA at LISTSERV.MUOHIO.EDU=20
  Sent: Sunday, August 13, 2000 8:31 AM
  Subject: TreeView


  Hi Guys & Gals,
  I'm trying to figure this TreeView thingy. Attached is the start of my =
program. The idea is it will take a line from a text file which is a =
list of vehicle manufacturers and add it to the main (0) folder in =
TreeView. Next it scans the database in feild 1, it finds a vehicle with =
the same manufacturer it should make a secondary folder under that =
manufacturer titled as the vehicle model. When finnished scanning the DB =
it goes back to get the next line of the text file and so on. I've done =
something wrong or I'm going about it the wrong way. I'm not up to =
filling the list yet as I have to change the structure of the DB.

  Help please

  Tony

------=_NextPart_000_0025_01C0054B.F1AB5F00
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV>
<DIV><FONT face=3DArial size=3D2>Hello, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Below is a <U><FONT =
color=3D#ff0000>working=20
example</FONT></U> of the method I use in a database that is similar to =
what I=20
think you are going to use.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I Create the .edb first in the example =
(obviously)=20
and open the file to gather the info created by the user (not all at =
once of=20
course)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>but as you'll see this will take away =
from haveing=20
the world see the info in your text file and accomplish the same=20
effect.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If I can be of further assistance let =
me=20
know.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:euman at bellsouth.net">euman at bellsouth.net</A>&nbsp;AKA =
Wayne=20
Overman</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-- Begin Code=20
-------------------------------------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>include win32lib.ew<BR>include=20
database.e</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--- Create the Database=20
-----------------------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>integer i, ii, i1, fn<BR>i1 =3D=20
db_create("Automadb2",DB_LOCK_NO)<BR>ii =3D=20
db_open("Automadb2",DB_LOCK_NO)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i&nbsp; =3D db_create_table("Alfa =
Romeo")<BR>i&nbsp;=20
=3D db_select_table("Alfa Romeo") <BR>ii =3D db_insert("Spyder",=20
{"Engine","Tires","Tranny"})<BR>ii =3D db_insert("model #2",=20
{"Engine","Tires","Tranny"})</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i&nbsp; =3D =
db_create_table("BMW")<BR>i&nbsp; =3D=20
db_select_table("BMW") <BR>ii =3D db_insert("Model #1",=20
{"Engine","Tires","Tranny"})<BR>ii =3D db_insert("Anyother model",=20
{"Engine","Tires","Tranny"})</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>fn =3D open("autoedb.txt", =
"w")<BR>db_dump(fn,=20
0)<BR>close(fn)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>db_close()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--- Open to aquire info=20
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>constant<BR>MainWin =3D create(Window, =
"Auto=20
Program", 0, Default, Default, 800, 600,0)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>atom TV<BR>TV =3D create(TreeView, =
"Treeview",=20
MainWin, 10, 35, 200, 525,<BR>&nbsp;or_all({TVS_HASLINES, =
TVS_LINESATROOT,=20
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>integer DONE, open_db, closefolder, =
openfolder=20
<BR>DONE&nbsp;&nbsp;&nbsp; =3D 0<BR>open_db =3D -1<BR>closefolder =3D =
addIcon(=20
extractIcon( "clsdfold.ico" ))<BR>openfolder&nbsp; =3D addIcon( =
extractIcon(=20
"openfold.ico" ))</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;</DIV></FONT><FONT =
face=3DArial=20
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2>procedure Auto_DB_class()<BR>sequence=20
Manufacturer_names, Machine_names, sub_class, folders<BR>integer =
get_table, fx,=20
gx, count, table_size, sub_class_count<BR>Machine_names =3D =
{}<BR>sub_class =3D=20
{}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>fx=3D1 gx=3D1 count=3D0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>if DONE =3D 0 then<BR>&nbsp;<BR>open_db =
=3D=20
db_open("Automadb2",DB_LOCK_NO)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; =
Manufacturer_names =3D=20
db_table_list() <BR>&nbsp;&nbsp;&nbsp;&nbsp; folders =3D {}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; for x =3D 1 to =

length(Manufacturer_names) do&nbsp; <FONT color=3D#0000ff>------This is =
the=20
(Automotive or any)=20
get_table =3D=20
nbsp;&nbsp;&nbsp;=20
folders &amp;=3D addTVItem( TV, closefolder, openfolder, =
Manufacturer_names[x] , 0=20
)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fx =3D x + =
count</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
table_size =3D db_table_size()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
p; for i=20
=3D 1 to table_size do&nbsp; <FONT =
color=3D#0000ff>------------------------- This=20
could be the model / models of the=20
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Machine_names =3D db_record_key(i)=20
sp;&nbsp;&nbsp;&nbsp;=20
folders &amp;=3D addTVItem( TV, closefolder, openfolder, Machine_names , =

folders[fx]=20
bsp;&nbsp;&nbsp;&nbsp;=20
sub_class =3D=20
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
sub_class_count =3D=20
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
count +=3D=20
bsp;&nbsp;&nbsp;&nbsp;=20
gx =3D x +=20
bsp;&nbsp;&nbsp;&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
for j =3D 1 to sub_class_count do<FONT color=3D#0000ff>&nbsp; =
-------This could be=20
any info on a particular Manufacturers Model i.e: Engine, Tires, Trans=20
etc.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
sp;=20
folders &amp;=3D addTVItem( TV, closefolder, openfolder, sub_class[j] ,=20
folders[gx]=20
count +=3D 1&nbsp;=20
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
end for</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
p;&nbsp;=20
sub_class =3D=20
nbsp;=20
Machine_names =3D {}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
p;&nbsp;=20
end for<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end=20
for<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; db_close()=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; DONE =3D =
1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>else <BR>end if</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>end procedure</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>WinMain( MainWin, Normal =
)<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>--- End of Code=20
------------------------------------------------------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG><U>P.S there is a bug in Matts=20
code</U></STRONG> </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>in win32lib.ew on <FONT face=3DArial size=3D2>line =
9077</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>global function getParent( integer id=20
)<BR>&nbsp;&nbsp;&nbsp; return tvitem_owner[ id ]<BR>end =
function</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT><BR><FONT=20
face=3DArial size=3D2><U>This&nbsp;should be:</U></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>global function getParent( integer id=20
)<BR>&nbsp;&nbsp;&nbsp; return tvitem_parent[ id ]<BR>end =
function</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;</DIV></FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dfigjam at nlc.net.au href=3D"mailto:figjam at nlc.net.au">Tony =
Steward</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3DEUPHORIA at LISTSERV.MUOHIO.EDU=20
  =
</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Sunday, August 13, 2000 =
8:31=20
  AM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> TreeView</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>Hi Guys &amp; Gals,</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>I'm trying to figure this TreeView =
thingy.=20
  Attached is the start of my program. The idea is it will take a line =
from a=20
  text file which is a list of vehicle manufacturers and add it to the =
main (0)=20
  folder in TreeView. Next it scans the database in feild 1, it finds a =
vehicle=20
  with the same manufacturer it should make a secondary folder under =
that=20
  manufacturer titled as the vehicle model. When finnished scanning the =
DB it=20
  goes back to get the next line of the text file and so on. I've done =
something=20
  wrong or I'm going about it the wrong way. I'm not up to filling the =
list yet=20
  as I have to change the structure of the DB.</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Help please</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial=20

------=_NextPart_000_0025_01C0054B.F1AB5F00--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu