.; PARSE.IND Control file for parsing a filespec. .; .; Normally called from another control file. .; In calling file, use the following statements: .; ... .; .enable global .; .sets $DEFDV "xxx[:]" .;Include a ":" if not null device. .; .sets $DEFXT "DSK" .;Default extension. .; ... .; @PARSE 'INPUT' .; ... .; Return is $FILSP, $FILNM and $DEV, where .; $FILSP contains the entire filespec (DEV:NAME.EXT), .; $FILNM contains the name and extension, and .; $DEV separately contains the device (DEV:), terminated by a :. .; If $DEFDV is null, then $DEV will return null. .; .; In PARSE, P1 is 'INPUT' from the calling routine. .; .; Written by: .; R. W. Barnard .; BIO/Comp Applications .; Albuquerque, NM 87185 .; .; Version 3.4, 12-Mar-87. .; .parse P1 ":" DEV FNAME .if eq 1 .goto 10 .;Only 1 component was entered. .; .; We were supplied both a device and a file. .; Be sure we are using the physical name of the device. .testdevice 'DEV' .parse "," $DEV REST .sets $DEV $DEV+":" .;A device was supplied. .goto 30 .; .; See if we have just a device or just a file. .10: .test P1 ":" .;See if only a device was given. .if eq 0 .goto 20 .;Just a file - no device. .testdevice 'DEV' .parse "," $DEV REST .sets $DEV $DEV+":" .;Only a device was supplied. .sets $FILNM "" .;Set the file name to blank and return. .sets $FILSP "" .exit .; .; Process the file name here and add the default device. .20: .sets FNAME DEV .;Device was not entered. .sets $DEV $DEFDV .;Use default device name. .if $DEFDV eq "" .goto 30 .;Null default device was supplied. .test $DEFDV ":" .;See if : was supplied. .if eq 0 .sets $DEV $DEV+":" .; .; Now see if extension was entered. .30: .test FNAME "." .;See if . was entered. .if eq 0 .goto 40 .;No extension was given-use default. .parse FNAME "." FNAME EXT .if EXT ne "" .goto 50 .;Extension was provided. .sets $DEFXT "" .;Make the extension null. .40: .sets EXT $DEFXT .;Use the default extension. .50: .sets $FILNM "'FNAME'.'EXT'" .;Build the file name. .sets $FILSP "'$DEV''$FILNM'" .;Build the complete file spec. .; .exit