BR! Client Server (Client Environment Variables).

More advanced topics discussed.

Moderators: Susan Smith, admin, Gabriel

Post Reply
GomezL
Posts: 258
Joined: Wed Apr 29, 2009 5:51 am
Contact:

BR! Client Server (Client Environment Variables).

Post by GomezL »

I found that i wanted to know information about the workstation or client.
I clipped The following code from my startup routine (Hopefully I didn't miss anything important), but you should get the idea.

The end result is every "Client Environment Variable" will be assigned a BR Environment variable like CS_TEMP.
So CS_TEMP will point to the "REAL TEMP FOLDER" on the client computer.

I also substituted a few WSID or SESSION specific files to use Computername instead. We decided not to worry about WSID's any more except for creating temp files and such.

Here is the snippet:

Code: Select all

39000 DEF Fncs_Env
39010   DIM Tempenv$*2048, Addstr$*3, Leftstr$*2048, Rightstr$*2048, Tmp$*2048,Cs_Textfile$*256,Client_Drive_N_Path$*256,Server_Drive_N_Path$*256
39020   LET Gw_Strgchk$="="
39030   LET Cs_Textfile$="cs-"&Session$&".txt"
39040   EXECUTE "*sys -M set > "&Cs_Textfile$
39050   OPEN #1: "NAME="&Cs_Textfile$,DISPLAY,INPUT ERROR XIT_FNCS_ENV
39060 STARTLOOP: !
39070   LET Addstr$="CS_"
39080   DO
39090     LINPUT #1: Tempenv$ ERROR XIT_LOOP
39100     LET Gw_Wholeline=Len(Rtrm$(Tempenv$)) !:
          LET Gw_Addlen=1 !:
          LET Gw_Posfnwp=Pos(Uprc$(Tempenv$),"=")
39110     IF Gw_Posfnwp>0 THEN
39120       LET Gw_Equal =Pos(Tempenv$,'=')
39130       LET Gw_Nextequal =Pos(Tempenv$,'=',Gw_Posfnwp+Gw_Addlen)
39140       IF Gw_Equal > 0 THEN
39150         LET Leftstr$ = Addstr$&Tempenv$(1:Gw_Posfnwp-1)
39160         LET Rightstr$ = Tempenv$(Gw_Posfnwp+1:Gw_Wholeline)
39170         LET Setenv(Leftstr$,Rightstr$) ERROR 39180
39180 ! Should SETENV FAIL, Ignore it
39190       END IF
39200     END IF
39210   LOOP
39220 XIT_LOOP: ! End of Startloop
39230   CLOSE #1: ERROR 39240
39240 !
39260 XIT_FNCS_ENV: LET _Session_Len=Len(Session$) : LET Session_Id$=Session$(_Session_Len:_Session_Len) ! End of Function
39261   IF Trim$(Env$("CS_COMPUTERNAME"))<>"" THEN !:
          EXECUTE "*CONFIG SUBSTITUTE N:CPRIN."&Wsid$&" N:PRN-"&Env$("CS_COMPUTERNAME")&".INT" ERROR 39262
39262   IF Trim$(Env$("CS_COMPUTERNAME"))<>"" THEN !:
          EXECUTE "*CONFIG SUBSTITUTE FIN-"&Session$&".HTM FIN-"&Env$("CS_COMPUTERNAME")&"-"&Session_Id$&".HTM" ERROR 39263
39263   EXECUTE "*sys -M CD > "&Cs_Textfile$
39264   OPEN #1: "NAME="&Cs_Textfile$,DISPLAY,INPUT ERROR XIT_FNCS_OS_PATH
39265   LINPUT #1: Client_Os_Path$ ERROR XIT_FNCS_OS_PATH
39267   CLOSE #1: ERROR XIT_FNCS_OS_PATH
39268   IF Exists(Cs_Textfile$) THEN !:
          EXECUTE "*Free "&Cs_Textfile$
39269 XIT_FNCS_OS_PATH: ! @
39299 FNEND
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

Wow! Very nice Luis! And thanks!

To those who are reading these messages from the old mailing list rather than the newer BR Forum, note that the text of Luis' function may have been altered in the routine that sends the forum messages back to the mailing list. So if you can't get it to run, go directly to the BR Forum (which is the preferred method ANYWAY) and snag the code from there. I copied and pasted it into MyEdit, and saved it that way. You can do the same with any text editor, and then load it as source in BR to continue.

To test the routine, add a few lines to the front end:
10000 let FNCS_ENV
10100 PAUSE

After you run it and hit the pause, do a STATUS ENV and you will see all of the new environment variables that his routine created - right on the end of the list. Very cool!

-- Susan

P.S. I know that the majority of people already know what to do with this routine, but I thought I'd post just in case there are some who don't
Post Reply