[Gambas-user] ~ doesn't seem to work.

Georg Brandl g.brandl at ...18...
Fri Aug 20 22:27:32 CEST 2004


Michael Sullivan wrote:
> My TODO program is coming along nicely.  I finished Stage 1 last night
> (which is get all the necessary functions working) and now I'm on the
> Stage 2 (which is enhancements).  I want to be able to place the
> executable file generated from my code in a location outside of the
> /home directory and have my program generate preference files within a
> users home directory.  There are two user accounts on my computer, mine
> (michael) and my wife's (amy).  When I run the executable, I want it to
> generate a preferences file in /home/michael/.TODO_preferences unless
> one already exists, in which case I want the program to read in the
> values in the file.  Likewise, if my wife runs the program, I want the
> preferences file to be generated in /home/amy/.TODO_preferences.  As you
> know, in Linux, the symbol ~ is used to represent the current user's
> home directory, but when I told Gambas that I wanted to "Open
> "~/.TODO_preferences" FOR CREATE AS #myFile" it said that the file
> didn't exist, However, when I changed ~ to /home/michael it worked
> fine.  Is there a workaround for what I'm trying to do?

It's not "in Linux", it's mainly "in the shell".

When you enter something like

$ ls -l ~

your shell transforms it into

$ ls -l $HOME

So, if you want to do this in Gambas, you should read the environment
variable "HOME" and concat this with your path.

mfg
Georg




More information about the User mailing list