Get App Name

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
melliott42
Posts: 119
Joined: Wed Feb 18, 2009 2:14 pm

Get App Name

Post 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

User avatar
esgici
Posts: 4538
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 410 times
Been thanked: 118 times
Contact:

Post by esgici »

Hello Michael

GetProgramFileName() => <cProgramFileNameWithFullPath>

For only file name you can use :

TOKEN( GetProgramFileName(),"\" )

Regards

--

Esgici
Viva INTERNATIONAL HMG :D

melliott42
Posts: 119
Joined: Wed Feb 18, 2009 2:14 pm

Post 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

User avatar
Rathinagiri
Posts: 5324
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 200 times
Been thanked: 210 times
Contact:

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
esgici
Posts: 4538
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 410 times
Been thanked: 118 times
Contact:

Post 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
Viva INTERNATIONAL HMG :D

melliott42
Posts: 119
Joined: Wed Feb 18, 2009 2:14 pm

Post by melliott42 »

Guys,

Thanks. Good suggestions!

Michael

Post Reply