FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour hb_getEnv("PRGPATH")
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
hb_getEnv("PRGPATH")
Posted: Tue May 07, 2024 12:36 PM
Dear friends,

I am using
Code (fw): Select all Collapse
hb_getEnv("PRGPATH")
and it works very nicely.
Could someone please be so kind as to explain to me where this environment variable is being set or coming from?
It doesn´t seem to come directly from my machine... I tried what ChatGPT suggested to me ... but echo %PRGPATH" in the command prompt did not display a value.
Please allow another question... is there a way to wrap something around
Code (fw): Select all Collapse
hb_getEnv()
to get in return all the possible standard-arguments this function accepts?

Thank you very much in advance and kind regards to all
Ruth
Posts: 137
Joined: Mon Oct 22, 2012 04:43 PM
Re: hb_getEnv("PRGPATH")
Posted: Tue May 07, 2024 02:00 PM

Start, Einstellungen, System, Info, erweiterte Systemeinstellungen, Umgebungsvariablen, ...

Start, Settings, System, About, Advanced System Settings, Environment Variables, ...

Regards



Ing. Anton Lerchster
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: hb_getEnv("PRGPATH")
Posted: Tue May 07, 2024 02:19 PM
Dear Mr. Lerchster,

thank you very much for your help. I just came back from "Umgebungsvariablen" but no PRGPATH there.

I can see PATH, which I also found in the wiki
https://harbour.github.io/doc/harbour.html#hb_getenv
and some others... but also CONFIG or HARBOURCMD are not stored there.

But ... everything works wonderfully which is confusing me :lol:


Thank you so much for your patience and help. Kind regards again,
Ruth
Posts: 137
Joined: Mon Oct 22, 2012 04:43 PM
Re: hb_getEnv("PRGPATH")
Posted: Tue May 07, 2024 02:42 PM

You can set any environment variables under “New”; CONFIG and HARBURCMD are only listed as examples in the documentation, so you won't find them on your PC.

If you want to set the variable PRGPATH, you can do it there with "New".

In a DOS window (Command.com) you do this with SET <environment variable>=value e.g. set fwh=c:\fwh

  • then this environment variable applies to this one DOS session.

If it is set under System/Environmental Variables then this applies to every DOS session and can also be accessed with hb_getenv(<environmental variable>).

Regards



Ing. Anton Lerchster
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: hb_getEnv(&quot;PRGPATH&quot;)
Posted: Tue May 07, 2024 03:08 PM
Dear Ruth,

mod_harbour automatically sets that environment variable :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: hb_getEnv(&quot;PRGPATH&quot;)
Posted: Tue May 07, 2024 07:02 PM

Dear Antonio, dear Mr. Lerchster, thank you both very much!!! I learned a lot with your help. Kind regards, Ruth

Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: hb_getEnv(&quot;PRGPATH&quot;)
Posted: Tue May 07, 2024 07:49 PM
Dear friends,

now i came to c:\modHarbourSource\mod_harbour-master\source\apache.prg on our system.
Please can you help me once again to understand... it says
Code (fw): Select all Collapse
hbSetEnv("PRGPATH")
but then in the "official" environment variables of my windows system i can´t see it. maybe it is stored somewhere else?

and also i wondered what would happen if accidentally I would have an environment variable named "PRGPATH" defined manually in windows - would this cause some kind of conflict?

thank you very much again for your being so kind and so patient and have a nice evening
Ruth
Code (fw): Select all Collapse
  if File( cFileName )
      hb_SetEnv( "PRGPATH",;
                 SubStr( cFileName, 1, RAt( "/", cFileName ) + RAt( "\", cFileName ) - 1 ) )
      if Lower( Right( cFileName, 4 ) ) == ".hrb"
         pThread = hb_threadStart( @ExecuteHrb(), hb_HrbLoad( 1, cFileName ), AP_Args() )
      else
         pThread = hb_threadStart( @Execute(), MemoRead( cFileName ), AP_Args() )
      endif
      if hb_threadWait( pThread, Max( Val( AP_GetEnv( "MHTIMEOUT" ) ), 15 ) ) != 1
         hb_threadQuitRequest( pThread )
          ErrorLevel( 408 ) // request timeout
      endif    
      InKey( 0.1 )
   else
      ErrorLevel( 404 ) // not found
   endif
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: hb_getEnv(&quot;PRGPATH&quot;)
Posted: Wed May 08, 2024 01:53 AM
Dear Ruth,

Harbour's hb_SetEnv() calls Windows API SetEnvironmentVariable()

Windows API SetEnvironmentVariable() docs:
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable
The operating system creates the environment variable if it does not exist
This function has no effect on the system environment variables or the environment variables of other processes
So it seems as such environment variable just exists for your own process.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: hb_getEnv(&quot;PRGPATH&quot;)
Posted: Wed May 08, 2024 07:54 AM
Dear Antonio, thank you very much for the link and your kind explanation. It helped me a lot :)
Kind regards and have a nice day
Ruth

Continue the discussion