[Gambas-user] load contents of a TreeView from a file
joshiggins at ...1601...
Sun Aug 17 12:38:23 CEST 2008
Thank you very much for the reply.
I have got as far as the FOR EACH section, and I have done
sItem = Split(sLine, " ") to get another array called sItem with the 3 bits
of information I need to add to the TreeView. The problem I'm having is
identifying each part of the array. If I shell "echo " & sItem or  or
 I get the right bit of information out on the terminal, but I also get
an Out of Bounds error.
On Sun, Aug 17, 2008 at 7:30 AM, Doriano Blengino <
doriano.blengino at ...1909...> wrote:
> joshiggins ha scritto:
> > Hello.
> > I'm just starting out with gambas and need some help. I have a file
> > formatted as follows:
> > itemkey [SPACE] itemname [SPACE] path/to/icon
> > itemkey1 [SPACE] itemname [SPACE] path/to/icon etc...etc...
> > I need to load this data from a file into a treeview. I figure that I
> > to load the file and for each line split it up into the 3 parts and add
> > item to the treeview, then do the same for the next line, and the next
> > I'm completely lost on where to start. The LINE INPUT page on the wiki
> > inputs the first line. Any suggestions?
> An example from the online help:
> hFile = OPEN "/etc/hosts" FOR INPUT
> WHILE NOT Eof(hFile)
> LINE INPUT #hFile, sOneLine
> PRINT sOneLine
> CLOSE #hFile
> You open the file, then input one line at a time. This is the classic way.
> Don't forget to close the file (see later).
> Another method is to load the entire file into a string, with:
> sString = file.load("/etc/hosts")
> then you must split this long string into a string using something like:
> sLines = Split(sString, "\n")
> At this point you have a string array you can traverse with "for each":
> for each sLine in sLines
> Every single line, obtained by either the two methods, must be again
> splitted in tokes and loaded in the TreeView.
> About execute command then exit, I had no problems in doing this:
> shell "cd /usr/local/bin; xterm &"
> This launches the terminal emulator "xterm" in background. If you exit
> the application, the xterm stays there.
> It is true that open files, environment, signals and other thing may be
> inherited by the child process, but I think this can be solved by the
> ampersand in the end of the SHELL command.
> If you need more help, ask again.
> Doriano Blengino.
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> Build the coolest Linux based applications with Moblin SDK & win great
> Grand prize is a trip for two to an Open Source event anywhere in the world
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
More information about the User