|  |     	Option type = explicit		! So BASIC will tell us if we
    					!accidentaly make an implicit
    					!variable.
	EXTERNAL LONG FUNCTION SYS$ASSIGN &
	  (STRING BY DESC, WORD BY REF, any, any)
	EXTERNAL LONG FUNCTION SYS$GETDVIW &
	  ( Any, WORD BY VALUE, STRING BY DESC, LONG Dim() BY REF, &
    		Word Dim() by ref, any, any, any)
	EXTERNAL INTEGER CONSTANT IO$_READVBLK, IO$M_NOW, IO$_WRITEVBLK, &
	  DVI$_DEVNAM
	DECLARE LONG rtl_stat, Dev_nam_len, Dummy
    	Declare string Device_name
	DECLARE WORD ch1, ch2, dviiosb(2)
	MAP (ilist) LONG itemlist(4)
    
    	! Initialize a buffer for the device name to go into.
    	Device_name = string$ ( 64%, 0% )	! Fill with nulls.
    	Dev_nam_len = 0%
	! GETDVI item descriptor (list of one to retrieve device name)
	itemlist(0) = (DVI$_DEVNAM * (2**16)) + 64%
    	Call str$Analyze_sdesc ( Device_name, dummy, itemlist(1) )
    		!  Return address of string in itemlist(1).
    	itemlist(2) = Loc ( Dev_nam_len ) ! Address of returned string length
	itemlist(3) = 0
	! Get channel assignment for device
 	rtl_stat = SYS$ASSIGN ('TT:', ch1, , )
	print "ASSIGN stat = "; rtl_stat
	! Get device name
	rtl_stat = SYS$GETDVIW ( , ch1, , itemlist(), dviiosb(), , , )
	print "GETDVI stat = "; rtl_stat, dviiosb(0)
!	print "Itemlist(1) = "; itemlist(1), "Itemlist(2) = "; itemlist(2)
    	Print "Length ="; Dev_nam_len; 
    	Print " Name = "; seg$ (Device_name, 1%, Dev_nam_len)
	end
 | 
|  | Thanks, that helps....but I am only getting a length, and no device
name. Looking at STR$ANALYZE_SDESC in the RTL manual, doesn't
Device_name have to be defined before this executes? I tried a few
things like setting it to the device specifed in the $ASSIGN, but
no success.
It appears this is the right track, now if I can just get all the pieces
to work together...
KY
 | 
|  | I think I've hacked my way out of this! Instead of:
	:
	:
	DECLARE LONG rtl_stat, Dev_nam_len, Dummy
    	Declare string Device_name
	DECLARE WORD ch1, ch2, dviiosb(2)
	MAP (ilist) LONG itemlist(4)
    
	:
	:
	! GETDVI item descriptor (list of one to retrieve device name)
	itemlist(0) = (DVI$_DEVNAM * (2**16)) + 64%
    	Call str$Analyze_sdesc ( Device_name, dummy, itemlist(1) )
    		!  Return address of string in itemlist(1).
    	itemlist(2) = Loc ( Dev_nam_len ) ! Address of returned string length
	itemlist(3) = 0
	:
...I experimented with the use of the LOC function, and sure enough,
it works fine with the buffer address part of the descriptor (itemlist(1)).
You don't even need STR$ANALYZE_SDESC.
	:
    	DECLARE BYTE Device_name(65)	! 64 char bytes + 1 for length
	DECLARE STRING output_string
    
	:
	! GETDVI item descriptor (list of one to retrieve device name)
	itemlist(0) = (DVI$_DEVNAM * (2**16)) + 64%
	itemlist(1) = Loc ( Device_name(1) )
    	itemlist(2) = Loc ( Dev_nam_len ) ! Address of returned string length
	itemlist(3) = 0
	:
Then, use the CHANGE function to turn the array of ASCII string codes
back into the device name string:
	Device_name(0) = Dev_nam_len
	CHANGE device_name TO output_string
...Nothing is easy at DEC, is it???
KY
 | 
|  |     
    Umm... couldn't you have saved yourself the CHANGE and done the
    following?
    
    DECLARE LONG Rtl_Stat, Dummy
    DECLARE WORD Dev_Name_Len
    Map (DEVNAME) String Device_Name = 64%
    RECORD Item_List
    
     Group Item_Desc
       Word Buffer_Length
       Word Item_Code
       Long Buffer_Address
       Long Return_Address
     End Group Item_Desc
    
     Long End_List
    
    End RECORD Item_List
    
    MAP (Item) Item_List Item_List
    MAP (Item) Long Item_List_Address
    
    Item_List::Item_Desc::Buffer_Length = 64%
    Item_List::Item_Desc::Item_Code = DVI$_DEVNAM
    Item_List::Item_Desc::Buffer_Address = Loc(Device_Name)
    Item_List::Item_Desc::Return_Address = Loc(Dev_Name_Len)
    Item_List::End_List = 0%
    
    Rtl_Status = SYS$GETDVIW(.........)
    
    .
    .
    .
     - VMS Documentation set says that "Device names are returned as
    64 byte, zero filled strings" [SYS-182,DVI$_DEVNAM] and additionally,
    the return length appears in the word pointed at by the "return_Addr"
    field of the item list. No need to CHANGE anything - this should
    return a string you can TRM$ to your hearts content, if you can't
    just LEFT() it instead, or live with the nulls.
    
    
    
 |