'set novalue on' /* use KEXX and its way of SIGNAL ON NOVALUE */ /* usage: CDD [directory|-] */ /* example: CDD E:\TMP (CHDR E: + CHDir \TMP) */ /* CDD - (previous directory) */ /* CDD (use FMode and FPath) */ /* option: SYNONYM CHD MACRO CDD */ /* requires: Kedit 5.0 (Frank Ellermann 1998) */ /* CDD combines the function of COMMAND CHDRive with Kedit 5.0 */ /* COMMAND CHDir. KeditW 1.0 CHDir is similar, adding a new */ /* CHDir = for the actual file directory FPATH on drive FMODE. */ /* CDD - returns to the last directory set by CDD, like 4DOS, */ /* NDOS, 4OS2, etc. CDD without argument is almost the same */ /* as KeditW CHDir =. Note that - or = are legal but unusual */ /* directory names. */ /* CDD without argument in a *.DIR file uses the DIRFILEID in */ /* the current line as target drive and path. Furthermore it */ /* adjusts a DIR.DIR path to reflect whatever new directory: */ /* Otherwise you could get additional DIR.DIR files instead of */ /* replacing an existing DIR.DIR. When you intentionally (?) */ /* saved a DIR.DIR, then CDD won't adjust its path, and simply */ /* proposes to erase it. */ CDD.? = fmode.1() || fpath.1() /* path of current file */ if dir() then do /* CDD within any *.DIR */ 'locate' focustof() - focuseof() /* locate 0 or +1 or -1 */ CDD.? = dirf.2() || dirf.3() /* path in a *.DIR line */ end if arg() = 1 then do /* argument specified */ CDD.? = strip( arg(1) ) /* last CDD dir. if '-' */ if CDD.? = '-' then 'editv get CDD.?' if length( CDD.? ) = 2 & substr( CDD.?, 2, 1 ) = ':' then CDD.? = CDD.? || '.' /* drive's current dir. */ end PATH = CDD.? /* change to given path */ CDD.? = directory.1() /* note old directory */ 'nomsg chd' PATH /* try change directory */ if rc <> 0 then do 'emsg directory' directory.1() /* show old directory */ exit 28 /* indicate failure */ end if substr( PATH, 2, 1 ) = ':' then /* if a drive specified */ 'nomsg chdr' left( PATH, 2 ) /* change the drive too */ if dir() & fname.1() = 'DIR' then do if undo.1() = alt.1() then do /* if not saved on disk */ 'fmode .' ; 'fpath .' /* adjust DIR.DIR path */ end else 'cmsg ERASE' efileid.1() /* else propose ERASE */ end 'query dir' ; 'editv put CDD.?' /* show new, save old */ exit 0 /* indicate success */