/**/ signal on novalue /* force REXX and its way of 'NOVALUE ON' */ /* Usage: [MACRO] ENV var[=[value]] */ /* Examples: ENV COMSPEC=C:\NORTON\NDOS.COM (affects DOS) */ /* ENV COMSPEC (interactive) */ /* ENV KEDIT=WIDTH 4096 (nice try :-) */ /* IMM 'ENV PATH=A:\HEADER;' || dosenv( 'PATH' ) */ /* Purpose: Modify a variable in Kedit's DOSENVironment */ /* Details: Some OS/2 "features" like allowing SET ==VALUE */ /* or not stripping the blanks in SET VAR = VALUE */ /* but in SET = = VALUE are imitated by macro ENV. */ /* Quote and caret aren't treated as shell escape, */ /* i.e. ENV ID= has the same effect as */ /* SET ID="" or SET ID=^. */ /* Caveat: SET translates all VARiable names to upper case */ /* using the actual codepage (CHCP) for "accented" */ /* characters. ENV supports only CHCP 437 or 850, */ /* and gets it wrong if CHCP is changed within the */ /* Kedit session. The reason for this problem is: */ /* - CMD.EXE uses e.g. CHCP 437 and calls KEDIT.EXE */ /* - KEDIT.EXE sets e.g. DOS CHCP 850 and calls ENV */ /* - ENV.KEX uses ADDRESS CMD CHCP finding wrong 437 */ /* - avoid  ƒ…ˆŠ‹¡Œ¢“•£–— in environment VARiables, */ /* these characters flip to AEIOU after a CHCP 437 */ /* - avoid ÆäÐìç› too if you switch to/from CHCP 850 */ /* - VALues are not translated (independent of CHCP) */ /* Requires: Kedit 5.0 and OS/2 resp. Quercus REXX/personal */ /* (Frank Ellermann, 1999) */ SET = sign( pos( '=', arg( 1 ))) ; parse arg VAR '=' VAL CAP = xrange( 'A', 'Z' ) /* common -- accented -- ignore */ LOW = xrange( 'a', 'z' ) '„”˜‡‚‘¤†' ' ƒ…ˆŠ‹¡Œ¢“•£–—' 'ÆäÐìç›' if opsys.1() = 'OS/2' /* check codepage 437,850 */ then address CMD '@CHCP | FIND /V "850" | FIND "437" > NUL' else address COMMAND 'CHCP | FIND /V "850" | FIND "437" > NUL' if rc = 0 then CAP = CAP 'Ž™šY€’¥' 'AAAEEIIIIOOOUUU' 'ÆäÐìç›' if opsys.1() = 'OS/2' /* check codepage 850,437 */ then address CMD '@CHCP | FIND /V "437" | FIND "850" > NUL' else address COMMAND 'CHCP | FIND /V "437" | FIND "850" > NUL' if rc = 0 then CAP = CAP 'Ž™šY€’¥' 'µ¶·ÒÔØÖ×Þàâãéêë' 'ÇåÑíè' if length( CAP ) = length( LOW ) /* support CHCP 437 or 850 */ then VAR = translate( VAR, CAP, LOW ) else VAR = translate( VAR ) /* else upper case a .. z */ if VAR = '' & SET then do /* SET = shows value of = */ SET = sign( pos( '=', VAL )) ; parse var VAL VAR '=' VAL if VAR = '' then VAR = '=' /* OS/2: SET ==XYZ is okay */ else VAR = '' /* OS/2: SET =X=Y not okay */ VAL = strip( VAL ) /* SET = = Y would SET ==Y */ end /* SET X = Y doesn't strip */ if VAR = '' then do /* no argument unsupported */ say 'usage: ENV VAR (allow to edit environment VARiable)' say 'or : ENV VAR=VAL (sets a value like OS/2 SET VAR=VAL)' say "unlike DOS SET macro ENV modifies Kedit's environment." exit 1 end if SET then do /* use REXX value function */ SET = 'environment' /* use DOS Quercus REXX or */ if opsys.1() = 'OS/2' then SET = 'os2' || SET /* any REXX */ call value VAR, VAL, SET end VAL = dosenv( VAR ) /* show environment value */ if SET = 0 then do /* cmsg to modify a value */ SET = length( 'env ' ) + length( VAR ) + 1 + length( VAL ) if SET < width.1() then do /* else don't truncate it */ SET = SET - length( VAL ) + verify( VAL || '$', ' ' ) 'cmsg env' VAR || '=' || VAL /* assuming IMPMACRO ON */ 'nomsg cursor cmdline' SET /* first non-blank in VAL */ end end SET = VAR || '=' || VAL /* split in msgline length */ do while length( SET ) > lscreen.2() say left( SET, lscreen.2()) SET = substr( SET, 1 + lscreen.2()) end if VAL == '' then say VAR 'not set in environment' else if VAL = ' ' then say SET '[' || length( VAL ) 'blank(s)]' else say SET /* last of 1 or more lines */