home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
netdor3.zip
/
DISK_12
/
IMAGE11.ZIP
/
ADMTOOLS
/
QDESKTOP.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-08-20
|
5KB
|
154 lines
/****************************************************************************
* QDESKTOP - Determine directory of active OS/2 desktop *
* Tom Bridgman (CORE at WATSON) *
*****************************************************************************
* Licensed Materials-Property of IBM *
* 5604-472 (c) Copyright IBM Corporation, 1993 *
* All rights reserved. *
* US Government Users Restricted Rights - *
* Use, duplication or disclosure restricted *
* by GSA ADP Schedule Contract with IBM Corp. *
****************************************************************************
* Acknowledgements: *
* Code to locate the desktop directory adapted from code by Georg Haschek *
* (61804212 at VIEVMA). *
****************************************************************************/
trace 'O'
signal on syntax
signal on novalue
parse upper source . How Me
parse upper arg Opt Extra
Valid = 'SWITCH'
if (Opt <> '' & wordpos(Opt, Valid) = 0) | Extra <> ''
then signal Tell
call RxFuncAdd 'SYSLOADFUNCS', 'REXXUTIL', 'SYSLOADFUNCS'
SynRef = 'SYSLOADFUNCS'
call SysLoadFuncs
drop SynRef
Cmd = (How = 'COMMAND')
if pos('\', Me) > 0
then do
MyPath = left(Me, max(3, lastpos('\', Me)-1))
call setlocal
call value 'PATH', MyPath';'value('PATH',,'OS2ENVIRONMENT'), 'OS2ENVIRONMENT'
end
Desktop = GetPath('<WP_DESKTOP>')
if Desktop = '' /* Second attempt if first fails */
then do
SynRef = 'BOOTDRIVE'
BDr = SysBootDrive()
SynRef = 'QFOLDER'
Desktop = 'QFOLDER'('OS/2 2.0 Desktop', BDr'\')
if Desktop = '' /* Third attempt (for 2.1 systems) if 3rd fails */
then Desktop = 'QFOLDER'('Desktop', BDr'\')
drop SynRef
end
call endlocal
if Cmd
then if Desktop = ''
then say 'The active OS/2 desktop directory could not be located!'
else do
say 'The active OS/2 desktop directory is "'Desktop'".'
if Opt = 'SWITCH'
then call directory Desktop
end
return Desktop
GetPath: procedure
parse arg ObjId
GpiNode = substr(sysIni('USER', 'PM_Workplace:Location', ObjId), 1, 2)
if GetNodes() <> 0
then say 'Warning: Could not locate the node table.'
GP = ''
do GPI = 1 to Nodes.0
if substr(Nodes.GPI, 7, 2) = GpiNode
then do
GP = substr(Nodes.GPI, 33, length(Nodes.GPI)-33) /* Name of desktop */
GPParent = substr(Nodes.GPI, 9, 2)
do until GPParent = '0000'x
do GPL = 1 to Nodes.0
if substr(Nodes.GPL, 7, 2) = GPParent
then do /* Qualified name of desktop */
GP = substr(Nodes.GPL, 33, length(Nodes.GPL)-33)'\'GP
GPParent = substr(Nodes.GPL, 9, 2)
leave GPL
end
end
end
leave GPI
end
end
return GP
GetNodes: procedure expose Nodes.
Handles = sysIni('SYSTEM', 'PM_Workplace:ActiveHandles', 'HandlesAppName')
if abbrev(Handles, 'ERROR:') /* No service pack */
then Handles = 'PM_Workplace:Handles'
Block1 = ''
parse value '0' with 1 Nodes. 1 I 1 L
do I = 1 to 999
Block = sysIni('SYSTEM', Handles, 'BLOCK'I)
if abbrev(Block, 'ERROR:')
then if I = 1
then return 10 /* could not locate NODE table */
else leave
else Block1 = Block1||Block
end I
do until L >= length(Block1)
if substr(Block1, L+5, 4) = 'DRIV'
then do
XL = pos('00'x||'NODE'||'01'x, Block1, L+5) - L
if XL <= 0
then leave
L = L + XL
iterate
end
else if substr(Block1, L+1, 4) = 'DRIV'
then do
XL = pos('00'x||'NODE'||'01'x, Block1, L+1) - L
if XL <= 0
then leave
L = L + XL
iterate
end
else do
Data = substr(Block1, L+1, 32)
XL = c2d(substr(Block1, L+31, 1))
if XL <= 0
then leave
Data = Data||substr(Block1, L+33, XL+1)
L = L + length(Data)
end
I = I + 1
Nodes.I = Data
end
Nodes.0 = I
return 0
Tell:
say
say ' QDESKTOP [SWITCH]'
say
say ' Returns the name of the directory corresponding to the active'
say ' OS/2 Desktop. If "SWITCH" is specified, the desktop directory'
say ' will be made active.'
exit 0
Syntax:
signal off novalue
select
when SynRef = 'SYSLOADFUNCS'
then say 'REXXUTIL.DLL could not be initialized.'
when SynRef = 'BOOTDRIVE'
then say Me 'requires the IUO version of REXXUTIL.DLL.'
when SynRef = 'QFOLDER'
then say 'QFOLDER.CMD has to be in the PATH or the same directory as' Me'.'
otherwise
say 'Syntax error' rc '('errortext(rc)') raised in line' sigl'.'
end
exit 2
Novalue:
say 'Novalue error ('condition('D')') raised in line' sigl'.'
exit 2