Start firefox from a terminal window, open a text file and position the text shown at a specified line

Viewed 982

I would like to improve the help facility in a Fortran program by opening the user guide in a separate browser (Firefox) window whenever the user type a ? as answer to a question the program asks.

I can use call system('path/firefox -file user_guide.hlp')

to open the help file. But additionally I would like to position the text in the browser window at a specified line in the help text.

I know which lines in the help file that should be relevant for the user because inside the Fortran program I keep track of the commands the user has made (I use a command line interface, no GUI). At present I print these lines in the terminal window running the program but this limits the amount of lines I can print and obscures the program output. With the whole user guide available in a separate window the user may also easily search for additional explanations elsewhere in the user guide, I do not expect he or she will voluntarily read the user guide.

Thanks for any help

Bo Sundman

1 Answers

You cannot go to specific lines but you could try using named anchor tabs. In the help file,

<a name="1"/>
help topic 1
<a name="2"/>
help topic 2

When you issue your call to firefox, to go to anchor 2

system('path/firefox -file user_guide.html#2')

This should work on all browsers. The newer ones will also take id= instead of name=

EDIT If the above doesn't work, try

system('path/firefox "file://path/user_guide.html#2"')

EDIT 2 If both the firefox path and html file path have spaces, on Windows, 8.3 filenames can be used. Use dir/x to find out what the 8.3 filenames are. Alternatively filenames with spaces can be used; the syntax is pretty weird

 call execute_command_line('""C:\...\firefox.exe" "file://x:\...\userguide.html#2""')
  1. start string with '
  2. Use 2 double quotes for the first double quote ""
  3. Add your pathname to firefox
  4. Use 1 double quote to terminate the path name
  5. add a space
  6. Use 1 double quote to start the parameter
  7. Add the parameter
  8. Use 2 double quotes to terminate
  9. end the string with '
Related