Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: ORGA-SOFT B. on September 14, 2017, 02:42:48 pm



Title: Getting Startup Path of the running programm
Post by: ORGA-SOFT B. 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


Title: Re: Getting Startup Path of the running programm
Post by: Laurent G. 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


Title: Re: Getting Startup Path of the running programm
Post by: Laurent G. 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


Title: Re: Getting Startup Path of the running programm
Post by: ORGA-SOFT B. 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


Title: Re: Getting Startup Path of the running programm
Post by: Laurent G. 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