Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!lll-winken!sun-barr!newstop!jethro!looney!toone From: toone@looney.Corp.Sun.COM (Nolan Toone) Newsgroups: comp.windows.open-look Subject: Re: Help! with scrolling lists and xv_create Message-ID: <4247@jethro.Corp.Sun.COM> Date: 30 May 91 22:15:09 GMT Sender: news@jethro.Corp.Sun.COM Reply-To: toone@looney.Corp.Sun.COM Organization: Sun Microsystems Lines: 75 brentb@montagne.Eng.Sun.COM (Brent Browning) writes: > In article <1991May24.211132.10282@cci632.cci.com> sz@cci632.cci.com (Stephen Zehl) writes: > > This is fine if you know what you want in the list ahead of time, but > >what if you want to read in a list of files from a directory? I figured I > >could just substitute a pointer to an array of strings in place of the > >strings themselves as shown below: > > > > static char *mylist[3] = { "One", "Two", "Three" }; > > PANEL_LIST_STRINGS must *really* have a NULL terminated list > of strings, *not* a char ** pointing at a NULL terminated list > of strings. > > I've included a sample program that does just what you > need to do. Type in a filename, then hit the load button. It > will load that file into the scrolling list. Hitting the > save button saves it out to a file. > The way Brent indicated is probably the best for this example, but just FYI: Another way is to use ATTR_LIST. This allows you to create a list of char ** and pass them to xv_{create/set}. The one thing to watch for is that you MUST include the ATTRIBUTE in the array as well as the NULL termiator and the max size for the list is 256. For example: if the array were: char *list[10]; list[0] = (char *)PANEL_LIST_STRINGS; list[1] = "item 1"; list[2] = "item 2"; list[3] = "item 3"; list[4] = "item 4"; list[5] = "item 5"; list[6] = "item 6"; list[7] = "item 7"; list[8] = (char *)NULL; list[9] = (char *)NULL; The first NULL to termiate PANEL_LIST_STRINGS the second to termiate the attribute list. Then you could use the above list in: xv_create(panel, PANEL_LIST, ATTR_LIST, list, NULL); which is the the same as: xv_create(panel, PANEL_LIST, PANEL_LIST_STRINGS, "item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7", NULL, NULL); Regards, /\ \\ \ Nolan C. Toone, ISV Engineering \ \\ / Sun Microsystems / \/ / / MailStop PAL1-316 / / \//\ 2550 Garcia Avenue \//\ / / Mountain View, California 94043 / / /\ / / \\ \ Phone: 415-336-0391 \ \\ EMail: toone@Corp.Sun.Com \/