* :--------------------------------------- * ------------------------: Copybook for GetEnvironmentVariable * : and SetEnvironmentVariable * : See the documentation for details. * :--------------------------------------- * * : Note: Environmental values may be * : up to 32k in size, but this * : copybook only has a 1024 byte * : field for the value. You may * : substitute another data element * : if you need a larger value. * : * : >>>>> SetEvnironmentVariable can set * : values into the environment but * : these will not survive your job * : and will not be present when the * : program terminates. It can be * : used to pass small data elements * : to subroutines or processes * : started with winexec or shellexe * : APIs. * To use: * * COPY WIN32API. * COPY ENVIRON. * . * . * -----Get Evnironment Variable Example ----------------------- * * MOVE LENGTH OF ENV-VARIABLE-VALUE TO ENV-VALUE-LENGTH * MOVE LOW-VALUES TO ENV-VARIABLE-VALUE * : This is the environment variable name * : we want to retrieve * MOVE "TEMP" TO ENV-VARIABLE-NAME * ------------------------: Call the API to get the value * * SET API-GETENVIRONMENTVARIABLE TO TRUE. * CALL 'GSWINAPI' USING WIN32API-PARMS * ENV-VALUE-LENGTH * ENV-VARIABLE-NAME * ENV-VARIABLE-VALUE * WIN32API-D * WIN32API-E * WIN32API-F. * * -----Set Evnironment Variable Example ----------------------- * * MOVE LENGTH OF ENV-VARIABLE-VALUE TO ENV-VALUE-LENGTH * MOVE TIME-OF-DAY TO ENV-VARIABLE-VALUE * : This is the environment variable name * : we want to Save * MOVE "STARTTIME" TO ENV-VARIABLE-NAME * ------------------------: Call the API to get the value * * SET API-SETENVIRONMENTVARIABLE TO TRUE. * CALL 'GSWINAPI' USING WIN32API-PARMS * ENV-VALUE-LENGTH * ENV-VARIABLE-NAME * ENV-VARIABLE-VALUE * WIN32API-D * WIN32API-E * WIN32API-F. * * ------------------------: If function failed, * : display a textual error message. * * IF WIN32API-FAILED * MOVE WIN32API-ERROR-TEXT TO my-error-message * do whatever to display my-error-message. * * ------------------------: NOTE: For API-GETENVIRONMENTVARIABLE * : * : If your buffer wasn't large enough, * : WIN32API-FAILED will be true, and * : the ENV-VALUE-LENGTH will have the * : size of the data area required to hold * : returned value. * : If the call succeeds, WIN32API-RC will * : have the length (not including the * : trailing low-value) of the value * : returned. * * ---------------------------------------------------------------- * 01 ENV-VALUE-LENGTH PIC 9(9) COMP-5. 01 ENV-VARIABLE-NAME PIC X(512). * : Size of the buffer 01 ENV-VARIABLE-VALUE PIC X(1024).