program FExSplit ; uses Dos, JRS_EnvU ; const Help = 'FEXSPLIT www.merlyn.demon.co.uk >= 2003-03-25'^M^J + ' See comment at start of FEXSPLIT.PAS' ; { FEXSPLIT : set file name pieces into environment variables. First parameter gives a file/dir name, rest are EnvVar names in order, but - is Skip, = is Default using Drive Dir Name Ext respectively If the first parameter starts @, it gives a file to read for a name ; just @ uses standard input - try HUNT %0 x p o | FEXSPLIT @ - = = = Short File Names only. Target need not exist. Full Name is built by Dir\Name.Ext For errors, see in JRS_EnvU.pas } procedure DoIt(PN : integer ; DefVar : string ; EnvVal : string) ; var EnvVar : string ; Sts : byte ; begin if ParamCount'-' then begin if EnvVar='=' then EnvVar := DefVar ; Environ(8, Put, EnvVar, EnvVal, Sts) ; if Sts<>0 then begin Writeln(' FEXSPLIT: FAIL ', Sts) ; HALT(Sts) end ; end ; end {DoIt} ; var F : text ; P1 : string ; Dir : DirStr ; Name : NameStr ; Ext : ExtStr ; BEGIN ; P1 := ParamStr(1) ; if (P1='') or (P1='/?') then begin Writeln(Help) ; HALT end ; if Copy(P1, 1, 1)='@' then begin Assign(F, Copy(P1, 2, 255)) ; Reset(F) ; Readln(P1) ; Close(F) ; end { @ } ; FSplit(FExpand(P1), Dir, Name, Ext) ; DoIt(2, 'Drive', Dir[1]) ; Dec(Dir[0]) ; DoIt(3, 'Dir', Dir) ; DoIt(4, 'Name', Name) ; DoIt(5, 'Ext', Copy(Ext, 2, 255)) ; END.