[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

543.0. "Using $GETDVI from Basic" by SSDEVO::YESSE (Computing at 6200 ft.) Thu Sep 03 1987 22:29

	I'm trying to get $GETDVI to work properly from BASIC.
	My eventual goal is to get a parent process communicating
	with a spawned subprocess using pipes (see note 163), but
	for now I just want to get 2 channels assigned to one device.

	Can anyone tell me what's wrong with the test program below?
	(I'm using TT: as a test device for the time being.) I'm
	probably not setting up my item descriptor list properly,
	but don't know quite what to do. The program returns OK
	status for the calls to ASSIGN & GETDVI, but nothing in the
	descriptor itemlist.

	Thanks in advance,
	Keith Yesse / CXO Storage Subsystems

	- - - - - - - - - - - - - - - - - - -

	EXTERNAL LONG FUNCTION SYS$ASSIGN &
	  (STRING BY DESC, WORD BY REF, , )
	EXTERNAL LONG FUNCTION SYS$GETDVIW &
	  ( , WORD BY VALUE, STRING BY DESC, LONG BY REF, , , , )

	EXTERNAL INTEGER CONSTANT IO$_READVBLK, IO$M_NOW, IO$_WRITEVBLK, &
	  DVI$_DEVNAM

	DECLARE LONG rtl_stat, dviiosb(2)
	DECLARE WORD ch1, ch2
	MAP (ilist) LONG itemlist(4)


	! GETDVI item descriptor (list of one to retrieve device name)
	itemlist(0) = (DVI$_DEVNAM * (2**16)) + 64%
	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(0), , , )
	print "GETDVI stat = "; rtl_stat

	print "Itemlist(1) = "; itemlist(1), "Itemlist(2) = "; itemlist(2)

	end
T.RTitleUserPersonal
Name
DateLines
543.1Try thisCHOVAX::YOUNGBack from the Shadows Again,Fri Sep 04 1987 00:1246
    	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


543.2Length OK, but still get no device nameSSDEVO::YESSEComputing at 6200 ft.Fri Sep 04 1987 16:3011
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

543.3Voila!SSDEVO::YESSEComputing at 6200 ft.Fri Sep 04 1987 18:0453
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

543.4If you don't want to spare the CHANGEFROST::HARRIMANI've heard this song beforeTue Sep 08 1987 12:1244
    
    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.