hb_getEnv("PRGPATH")

hb_getEnv("PRGPATH")

Postby Ruth » Tue May 07, 2024 12:36 pm

Dear friends,

I am using
Code: Select all  Expand view  RUN
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: Select all  Expand view  RUN
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
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: hb_getEnv("PRGPATH")

Postby alerchster » Tue May 07, 2024 2:00 pm

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

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

Ing. Anton Lerchster
User avatar
alerchster
 
Posts: 95
Joined: Mon Oct 22, 2012 4:43 pm

Re: hb_getEnv("PRGPATH")

Postby Ruth » Tue May 07, 2024 2: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
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: hb_getEnv("PRGPATH")

Postby alerchster » Tue May 07, 2024 2: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
User avatar
alerchster
 
Posts: 95
Joined: Mon Oct 22, 2012 4:43 pm

Re: hb_getEnv("PRGPATH")

Postby Antonio Linares » Tue May 07, 2024 3:08 pm

Dear Ruth,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: hb_getEnv("PRGPATH")

Postby Ruth » Tue May 07, 2024 7:02 pm

Dear Antonio, dear Mr. Lerchster, thank you both very much!!! I learned a lot with your help. Kind regards, Ruth
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: hb_getEnv("PRGPATH")

Postby Ruth » Tue May 07, 2024 7: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: Select all  Expand view  RUN
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: Select all  Expand view  RUN
 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  
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: hb_getEnv("PRGPATH")

Postby Antonio Linares » Wed May 08, 2024 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: hb_getEnv("PRGPATH")

Postby Ruth » Wed May 08, 2024 7: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
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests