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 need
> to load the file and for each line split it up into the 3 parts and add an
> item to the treeview, then do the same for the next line, and the next etc.
> I'm completely lost on where to start. The LINE INPUT page on the wiki only
> 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
WEND
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
...
...
next
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.
Salutations,
Doriano Blengino.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user