Page 1 of 1

Get App Name

Posted: Mon Mar 16, 2009 4:27 pm
by melliott42
Hello,

From within the executing HMG application how can I programmatically determine the base program name?

For instance if my program is called myapp.exe I'd like it to return myapp.

Thanks,

Michael

Re: Get App Name

Posted: Mon Mar 16, 2009 5:21 pm
by esgici
Hello Michael

GetProgramFileName() => <cProgramFileNameWithFullPath>

For only file name you can use :

TOKEN( GetProgramFileName(),"\" )

Regards

--

Esgici

Re: Get App Name

Posted: Mon Mar 16, 2009 6:24 pm
by melliott42
esgici,

Great - thanks!

I wrapped it in a function.

Michael

#include "minigui.ch"
Function Main
msginfo( getAppBaseName() )
return

function getAppBaseName()
local cGetProgramFileName, nPosOfDot, cAppName

cGetProgramFileName := TOKEN( GetProgramFileName(),"\" )
nPosOfDot := at('.', cGetProgramFileName)
cAppName := SubStr( cGetProgramFileName, 1, nPosOfDot -1 )
return cAppName

Re: Get App Name

Posted: Mon Mar 16, 2009 6:32 pm
by Rathinagiri
Instead of at, if you put rat it will be ok. Isn't it?!

If the application's name is x.y.z.exe then x will the string that will be returned.

Re: Get App Name

Posted: Mon Mar 16, 2009 6:41 pm
by esgici
Hi Michael

Good.

Or in a more short and lazy ( ;) ) way :

Code: Select all

#include "minigui.ch"
Function Main
msginfo( TOKEN( TOKEN( GetProgramFileName(), "." , 1 ), "\" ) )
return
Regards

--

Esgici

Re: Get App Name

Posted: Mon Mar 16, 2009 7:04 pm
by melliott42
Guys,

Thanks. Good suggestions!

Michael