Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Getting Startup Path of the running programm  (Read 9759 times)
ORGA-SOFT B.
Posts: 34


« on: September 14, 2017, 02:42:48 pm »

Hello,

i'm looking for a function that returns the startup Path of the programm.

For example i run the following comamnd fglrun /mypath/myApp/bin/startmenu.42r
In my Genero app i have to find out in which  path the 42r file is located.

is there a function that returns this path?

os.path.pwd returns the path were i stand when i run the command above
Laurent G.
Four Js
Posts: 115


« Reply #1 on: September 14, 2017, 07:18:27 pm »

Hello,

Maybe using on arg_val(0) could help:

bash-3.2$ cat GSPRP.4gl
Import os

main

  define GeneroVMArgument, StartupPath String
 
  let GeneroVMArgument = arg_val(0)
  let StartupPath = os.path.dirName(GeneroVMArgument)

  display "Startup Path of the current Running Program : " || StartupPath

end main

bash-3.2$ fglrun /Users/laurent/Desktop/TMP/GettingStartupPathRunningProgram/GSPRP.42r
Startup Path of the current Running Program : /Users/laurent/Desktop/TMP/GettingStartupPathRunningProgram

Best

Laurent
Laurent G.
Four Js
Posts: 115


« Reply #2 on: September 14, 2017, 07:20:04 pm »

I meant using os.path.dirName on arg_val(0) sorry

Hello,

Maybe using on arg_val(0) could help:

bash-3.2$ cat GSPRP.4gl
Import os

main

  define GeneroVMArgument, StartupPath String
 
  let GeneroVMArgument = arg_val(0)
  let StartupPath = os.path.dirName(GeneroVMArgument)

  display "Startup Path of the current Running Program : " || StartupPath

end main

bash-3.2$ fglrun /Users/laurent/Desktop/TMP/GettingStartupPathRunningProgram/GSPRP.42r
Startup Path of the current Running Program : /Users/laurent/Desktop/TMP/GettingStartupPathRunningProgram

Best

Laurent
ORGA-SOFT B.
Posts: 34


« Reply #3 on: September 15, 2017, 08:37:04 am »

Good Morning Laurent,

that's what i'm looking for.

So complete i have to figure out the absolute path.

let GeneroVMArgument = arg_val(0)
let StartupPath = os.path.dirName(GeneroVMArgument)
let StartupPath = os.path.fullPath(StartupPath)

with this additional line in all cases the startuppath is correct.

Many Thanks for your great support.

Martin Stigmond
Laurent G.
Four Js
Posts: 115


« Reply #4 on: September 15, 2017, 11:17:03 pm »

You are very welcome Martin,

I didn't have to use the extra os.path.fullPath(StartupPath) on my MacOs laptop, I'm glad this is working for you in all cases you need it.

Also and to be complete, my colleague Florencia pointed me to an even more efficient way to achieve what you want (in one line only, how could I miss that!)

let StartupPath = base.Application.getProgramDir()

Best

Laurent
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines