How can I tell if my application is running in the WebClient environment or another environment?

Question ID : 316
Created on 2020-12-22 at 7:42 AM
Author : Veryant Support [support@veryant.com]

Online URL : http://support.veryant.com/support/phpkb/question.php?ID=316



A call to C$GETRUNENV will return your environment, with possible values defined in iscobol.def.
Because the user-id for sessions running in WebClient will always be the user-id of the account that started the WebClient, you may need to create a unique user-id for each WebClient session.
An example of how to use this to create a unique user-name is:

  call "C$GETRUNENV" giving env-code

  evaluate env-code
  when runenv-standalone
       call "C$SYSINFO" using system-information
       move user-id to user-name
  when runenv-thin-client
       call client "C$SYSINFO" using system-information
       move user-id to user-name
  when runenv-web-client
       call client "C$GETPID" using process-id
       string "webc", process-id into user-name
   end-evaluate.

Another way to tell if you are running in thin-client mode or web-client mode is to use A$CURRENT-USER.
It returns an optional parameter called type.
A value of 0 or 2 means the connection is a standard thin client connection, and a value of 1 means the connection is through the WebClient.

  01 run-environment-variables.
     05 usr-id      pic x(35).
     05 usr-name    pic x(35).
     05 usr-ip-addr pic x(35).
     05 usr-pc-name pic x(35).
     05 thread-id   pic 9(10).
     05 usr-program pic x(35).
     05 env-type    pic x(35).

...

  call "A$CURRENT-USER" using usr-id
                        usr-name
                        usr-ip-addr
                        usr-pc-name
                        thread-id
                        usr-program
                        env-type

  evaluate env-type 
  when 0
  when 2
       move "thin" to my-run-environment
       perform COUNT-PRINTERS
  when 1
       move "webc" to my-run-environment
       move 1 to number-of-printers
  end-evaluate.



Back to Original Question