From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP 31-OCT-1988 13:13
To:	ARISIA::EVERHART
Subj:	Convert File-ID into Filespec


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Mon, 31 OCT 88 07:32:10 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Mon, 31 Oct 88 07:14:29 PST
Received: from DGOGWDG5.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 6328; Mon, 31 Oct 88 06:04:06 EDT
Date:    Mon, 31-OCT-1988 11:03  +0100
From:    "GWDGV1::MOELLER"  <U0012%DGOGWDG5.BITNET@CUNYVM.CUNY.EDU>
To:      info-vax@kl.sri.COM
Subject: Convert File-ID into Filespec

>       How do you get the file name, given a file id?

I'm enclosing a MACRO routine that will do just that.

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
Bitnet/Earn: U0012@DGOGWDG5         Phone: +49 551 201516 | No claim intended

$! ...................... Cut between dotted lines and save. ...................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user MOELLER
$! on 31-OCT-1988 10:57:23.55.
$!
$! It contains the following 1 file:
$!        FIDTONAME.MAR
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.03 20-Oct-1988 requires VMS V4.4 or higher."
$ EXIT 44
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY

b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) );
s_file_spec := GET_INFO( COMMAND_LINE, "output_file" );SET( OUTPUT_FILE
, b_part, s_file_spec );
b_errors := CREATE_BUFFER( "{Errors}" );i_errors := 0;
pat_beg_1 := ANCHOR & "-+-+-+ Beginning";
pat_beg_2 := LINE_BEGIN & "+-+-+-+ Beginning";
pat_end := ANCHOR & "+-+-+-+-+ End";
pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b
:= SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) )
; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER
( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; ENDLOOP; POSITION( BEGINNING_OF
( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE ) = END_OF( b_part )
; s_x := ERASE_CHARACTER( 1 );
  IF s_x = "+" THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <
> 0 THEN
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF;
  IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF;
  IF s_x = "V" THEN
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL( 1 ); ENDIF;
  IF s_x = "X" THEN
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF;
  IF s_x <> "" THEN i_errors := i_errors + 1; s_text := CURRENT_LINE; POSITION
( b_errors );
    COPY_TEXT( "The following line could not be unpacked properly:" )
; SPLIT_LINE; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part )
; MOVE_VERTICAL( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP
  r_x := SEARCH( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x )
; ERASE_CHARACTER( 1 );
  IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) );
  COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE;
  SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" );ENDIF; EXIT;
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "FIDTONAME.MAR"
$ CHECKSUM_IS = 1074987355
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X`009.title`009fid_to_name (via ATR$..FILE_SPEC)
X;
X;`009w.j.m. aug 86 after DECUS [VAX85C.TIMELINE...]
X;
X; call:`009status=FID_TO_NAME(device,fid,string[,lstring])
X;`009character*(*) device,string
X;`009integer*2 fid(3),lstring
X;
X; bugs: uses event flag 0
X;`009inefficient due to assign/deassign
X;
X;
X;*****
X;
X`009$iodef
X`009$fibdef
X`009$atrdef
X;
X;
X;*****`009data
X;
Xfib:`009.byte`0090[fib$k_length]
X;
Xfib_desc:`009.long`009fib$k_length
X`009`009.long`009fib
X;`032
Xatr:`009.word`009atr$s_file_spec
X`009.word`009atr$c_file_spec
X`009.long`009file_spec
X`009.long`0090
X;
Xfile_spec:`009.blkw`009`009; length goes here (w.j.m. aug 86 vms 4.3)
Xfile_spec_a:`009.blkb`009atr$s_file_spec-2
X;`032
Xchan:`009.blkw`0091
Xiosb:`009.blkw`0094
X;
X;
X;*****
X;`032
X`009.entry`009fid_to_name,`094m<r2,r3,r4,r5,r6>
X;
X `009movl`0092*4(ap),r0
X`009movl`009(r0)+,fib+fib$w_fid+0
X`009movw`009(r0)+,fib+fib$w_fid+4
X;
X`009$assign_s-
X`009`009devnam=@1*4(ap),-
X`009`009chan=chan
X`009blbs`009r0,2$
X`009brw`00999$
X2$:
X`009$qiow_s`009func=#io$_access,-`009;note: no deaccess required later
X`009`009chan=chan,-
X`009`009iosb=iosb,-
X`009`009p1=fib_desc,-
X`009`009p5=#atr
X`009blbc`009r0,10$
X`009movzwl`009iosb,r0
X`009blbc`009r0,10$
X;
X`009pushl`0093*4(ap)
X`009pushal`009file_spec_a
X`009pushaw`009file_spec
X`009calls`009#3,g`094lib$scopy_r_dx
X;
X`009cmpb`009(ap),#4
X`009blssu`00910$
X`009tstl`0094*4(ap)
X`009beql`00910$
X`009movw`009file_spec,@4*4(ap)`009
X;
X10$:
X`009pushr`009#`094m<r0>
X`009$dassgn_s -
X`009`009chan=chan
X`009popr`009#`094m<r0>
X;
X99$:
X`009ret
X;
X;
X`009.end
$ GOSUB UNPACK_FILE
$ EXIT

