Version 4 of Accessing the help pages without changing the default directory

Updated 2011-02-09 17:57:11 by Didier

Didier (2011-02-09] I wonder if I can work around this difficulty. I thought I coded a very clever piece of code. In my program, if I click on a file in Directory A, A becomes a default directory. Now the problem started when I had to code the Help. If I call the Help page, the directory will be changed to the Help directory. Which is what I don't want. What I'd like is to stay in the current directory and to view the Help pages which are in another directory without changing the default directory. Is this possible?

GJS (2011-02-09) You need to use the full path of the help files. Sometimes it helps to store important directories in some sort of variable when your application starts up. One method of getting the directory your script is running from would be to use [file dirname [info script]]]. If you are developing a starkit you may choose to use $::starkit::topdir to get the directory that main.tcl is in. To get the directory the starkit is in you can use [file dirname $::starkit::topdir]. Once you have saved the main directory of the app, lets say you used a variable name dir, you can use [file join $dir help] to get the a directory named help, or [file join $dir help myhelp.txt] to get the help file. Hopefully this answers your question.

Didier (2011-02-10) It does. Thanks Gary! And thank you again for the Set windows side by side suggestion. It was for me the beginning of a new computing adventure! Working with two files in two different directories.

I thought of a more barbarian approach to the above-mentioned problem. I thought of writing some code that would work this way:

  • Change the default directory according to the file loaded
  • But Do not do this if the directory has the word User's Help in its path

It's not a very orthodox way to proceed, I agree but it's less complicated. What do you think? How should I proceed if I use this simpler approach?

Tx again!