diff --git a/ng/ng.tcl b/ng/ng.tcl index 003b745c..7343eae0 100644 --- a/ng/ng.tcl +++ b/ng/ng.tcl @@ -269,7 +269,22 @@ if { $stereo == "defined" } { } -catch { source ${ngdir}/ngsolve.tcl } +set ngsolve_loaded 0 +catch { + source ${ngdir}/ngsolve.tcl; + set ngsolve_loaded 1 +} + +# try to find ngsolve.tcl in PATH +set pathlist [split $::env(PATH) \ [expr {$::tcl_platform(platform) == "windows" ? ";" : ":"}]] +foreach dir $pathlist { + if { $ngsolve_loaded != 1 } { + catch { + source ${dir}/ngsolve.tcl + set ngsolve_loaded 1 + } + } +} set scriptfilename [Ng_GetCommandLineParameter script] diff --git a/ng/onetcl.cpp b/ng/onetcl.cpp index 53348262..4eec1ab2 100644 --- a/ng/onetcl.cpp +++ b/ng/onetcl.cpp @@ -5948,7 +5948,20 @@ const char * ngscript[] = {"" ,"Ng_SetVisParameters;\n" ,"redraw\n" ,"}\n" -,"catch { source ${ngdir}/ngsolve.tcl }\n" +,"set ngsolve_loaded 0\n" +,"catch {\n" +,"source ${ngdir}/ngsolve.tcl;\n" +,"set ngsolve_loaded 1\n" +,"}\n" +,"set pathlist [split $::env(PATH) \\ [expr {$::tcl_platform(platform) == \"windows\" ? \";\" : \":\"}]]\n" +,"foreach dir $pathlist {\n" +,"if { $ngsolve_loaded != 1 } {\n" +,"catch {\n" +,"source ${dir}/ngsolve.tcl\n" +,"set ngsolve_loaded 1\n" +,"}\n" +,"}\n" +,"}\n" ,"set scriptfilename [Ng_GetCommandLineParameter script]\n" ,"if { $scriptfilename != \"undefined\" } {\n" ,"if { [catch { source $scriptfilename } errstring] == 1 } {\n"