home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
kl.zip
/
kldir.kex
< prev
next >
Wrap
Text File
|
1997-03-17
|
4KB
|
122 lines
/* (c) Copyright International Business Machines Corporation 1994, 1997.
* All rights Reserved.
*
* KLDIR: Subroutine macro of KL (KEDIT FileList) macro (Ver 2.10)
*
* Requirements: KLUTIL.DLL
*
* Author: Shintaroh Hori (Yamato Lab. IBM JAPAN)
*/
parse arg new? lvl spec
if lvl=0 then lvlopt=''
else if lvl=256 then lvlopt='/D'
else lvlopt='/D'lvl
call LoadUtil
signal on syntax
rc=KLFILEUTIL(spec, 'FSPEC', 'PATH') /* resolve spec to full spec */
signal off syntax
drv =left(path,2)
path=substr(path,3)
'EDITV GETF KLSPEC.0 KLFNLEN KLFELEN KLLFLEN KLDTLEN KLTMLEN'
if klspec.0 ='' then klspec.0=0
sid = klspec.0 + 1
'EDITV SETLF KLSPEC.0' sid
'EDITV SETLF KLSPEC.'sid fspec lvlopt
'EDITV SETLF KLSPEC.'sid'.D' drv
'EDITV SETLF KLSPEC.'sid'.P' path
parse value GetTempFileID() with tmpdir tmpfile
if tmpfile='' then Return 3 'KL: Temporary file cannot be created.'
tmpname= substr(tmpfile, length(tmpdir)+1)
DIR.0=0
numlist=kllflen klfnlen klfelen (kldtlen<>8) (kltmlen<>5) lvl
parse value KLFILEUTIL(fspec, numlist, '#'sid, tmpdir, tmpname,'0','DIR.') ,
with retc num
if num\=0 then 'nomsg get' tmpfile
'dosq erase' tmpfile
if retc=0 then do
call DispSpec num fspec' 'lvlopt
if new? then call TopList /* for a new FileList */
end
else do
if new? then 'QQUIT'
if retc=2 then msg='KL: No files for "'spec'"'
else if retc=5 then msg='KL: Failed to create a work file in "'tmpdir'". The disk may not have enough space.'
else if retc\=0 then msg='KL: Fatal error from KLUTIL.DLL (rc='retc
'MSG' msg /* display error msg */
retc = 3
end
Exit retc
DispSpec: procedure expose sid klfnlen klfelen kllflen kldtlen kltmlen
parse arg n spec
'extract /pscreen'
cnt = n 'Dir/Files'
'set reserved' sid left('#'sid'='spec,pscreen.2 - length(cnt)-1) cnt
if klfelen=0 then fidl=left('Name&Ext',klfnlen)
else fidl=left('FileName',klfnlen) left('Ext',klfelen)
'set reserved' sid+1 left('Cmd_Area',8) fidl 'Attrb' right('Size',9),
center('Date',kldtlen) center('Time',kltmlen) 'ID RelPath'
'set alt 0 0'
'set lineflag nonew nochange all'
Return
TopList: procedure
'EDITV GETF KLSPEC.0'
'sos tabcmd' ; 'top'
'extract /curline/'
dn = curline.2 - klspec.0 -2 ; if dn \=0 then 'down' dn
Return
GetTempFileID: procedure
'EDITV GET KLTMP'
fid = 'KL!!????.KL!'
if kltmp\='' then do
tmpfile=kltmp''fid
if NoSpace(left(kltmp,1)) then kltmp=''
else do
tmpfile= SysTempFileName(tmpfile)
if tmpfile='' then kltmp='' /* use root of local drives ... */
end
end
if kltmp='' then do
drvlist= KlFileUtil() SysDriveMap('C','LOCAL')
do i=1 to words(drvlist)
drv = word(drvlist,i)
if NoSpace(drv) then iterate
kltmp=drv'\'
tmpfile=kltmp''fid
tmpfile=SysTempFileName(tmpfile)
if tmpfile \='' then leave
end
'EDITV PUT KLTMP' /* save for the next use */
end
Return kltmp tmpfile
NoSpace: procedure
arg drv
parse value SysDriveInfo(drv) with . free .
if free\='' & free > 32768 then return 0
Return 1
LoadUtil: procedure
/* RxFuncAdd always returns 1. It's a bug. */
if RxFuncQuery('KLFILEUTIL') then
rc=RxFuncAdd('KLFILEUTIL', 'KLUTIL','KLFILEUTIL')
funcs ='SysTempFileName SysDriveMap SysDriveInfo'
do i=1 to words(funcs)
f = word(funcs,i)
if RxFuncQuery(f) then rc=RxFuncAdd(f, 'RexxUtil',f)
end
Return
syntax:
'MSG KLUTIL.DLL is not loaded under a path in LIBPATH.'
Exit 3