Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parameters of the GetEnvVar function
#1
I need to make the second parameter of qmq's built-in function GetEnvVar optional.

Below is ChatGPT's answer, but it always produces garbled text in actual use.
Is there a better solution?

Function getEnv
Code:
Copy      Help
function$ $name [str&value] 

str R
if(GetEnvVar(name R))
,if(&value)
,,value = R
,,value.expandpath
,,ret value
,else
,,_s=R.expandpath
,,ret _s

Function GetEnvVar
Code:
Copy      Help
;/
function$ $name str&value

;Gets an environment variable.
;Returns value if successful, 0 if failed.

;value - variable for value.

;Added in: QM 2.3.0.


int n1(4) n2
;g1
BSTR b.alloc(n1)
n2=GetEnvironmentVariableW(@name b n1)
if(n2>n1) n1=n2; goto g1
if(n2) value.ansi(b); ret value
value.all


Messages In This Thread
Parameters of the GetEnvVar function - by Davider - 09-07-2026, 07:22 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)