OpenVMS Source Code Demos

This function will read a logical name and return the value. In the VAX days calling this function (WCSM_trnlnm) was more efficient than calling lib$get_logical but, today, we use lib$get_logical all the time.

WCSM_TrnLnm.fun

	!
	function string WCSM_TrnLnm ( string logical_name$, table_name$ )
	!========================================================================================================================
	! Title  : wcsm_trnlnm.fun
	! Author : Neil S. Rieck
	! Purpose: an external function to translate logical names
	! Notes  : 1. all our programs call this function so optimizations here will speed up the whole system
	!	 : 2. use LIB$TRNLNM if speed isn't important
	! History:
	! 100 NSR 910911 1. original work
	!     NSR 940420 2. changed mapsize from 31 to 255
	!     NSR 000208 3. modified for use with 'starlet'
	!     NSR 021019 4. optimizations
	!     NSR 040516 5. now only do SUPERVISOR mode translations							bf_100.5
	!     NSR 040519 6. returned this program to its previous functionality
	!========================================================================================================================
	! Notes  :
	!
	! 1. please include the next line near the top of your source program (after 'option type=explicit')
	!
	!	external string function WCSM_TrnLnm (string, string)
	!
	! 2. please include the next 2 lines near the bottom of of your source program (after 'END' of the main module)
	!
	!	%include "[.fun]wcsm_trnlnm.fun"
	!!	! function string WCSM_TrnLnm ( logical_name$, table_name$ )
	!
	!========================================================================================================================
	option	type=explicit							! cuz tricks are for kids...
	!
!~~~	%include "[.inc]vms_externals.inc"					x calls many modules from starlet
	%include "starlet"	%from %library "sys$library:basic$starlet"      ! system services
	%include "$ssdef"	%from %library "sys$library:basic$starlet"      ! ss$
	%include "$lnmdef"	%from %library "sys$library:basic$starlet"      ! lnm$
	%include "$psldef"	%from %library "sys$library:basic$starlet"      ! psl$
	%include "[.inc]vms_structures.inc"					! IosbRec etc.
	!
	declare long  constant	MapSize%	= 255
	!+
	!	<<< declare variables >>>
	!-
	map(WCSM_TrnLnm)string	Equiv_Name$	= MapSize%
	declare 	long	sys_status		,			! for return codes	&
				bytes_returned%		,			! for system calls	&
				my_attributes%		,			! ''			&
			string	temp$			,			!			&
			byte	access_mode%	 				!
	!
	declare	ItemRec	LogLst(2)						! 3 items (0-2)
	!
	!==================================================
	! clean up data (before table fill)
	!==================================================
	!
	logical_name$	= edit$(logical_name$, 32+4+2)
	table_name$	= edit$(table_name$,   32+4+2)
!~~~	access_mode%	= PSL$C_SUPER						x					bf_100.5
	!
	!==================================================
	! prep for call (fill in table)
	!==================================================
	!
	my_attributes% = LNM$M_TERMINAL
	!
	LogLst(0%)::BuffLen		= 4%					! 4 bytes=long
	LogLst(0%)::ItemCode		= lnm$_Attributes			! desired code
	LogLst(0%)::BuffAddr		= loc(my_attributes%)			!
	LogLst(0%)::RtnLenAdr		= 0%					! don't care
	!
	LogLst(1%)::BuffLen		= MapSize%				! from map statement
	LogLst(1%)::ItemCode		= lnm$_String				! desired code
	LogLst(1%)::BuffAddr		= loc(Equiv_Name$)			! address of string variable
	LogLst(1%)::RtnLenAdr		= loc(Bytes_Returned%)			! address of length variable
	!
	LogLst(2%)::List_Terminator	= 0%					! end of list
	!
	!	this is it folks, the big Kahoona...
	!
	sys_status = sys$trnlnm(		,				! attributes					&
				table_name$	,				!						&
				logical_name$	,				!						&
						,				!				bf_105.6	&
				LogLst()	)				!
	!
	select sys_status
	    case ss$_nolognam
		temp$ = ""							! make sure this is clear
	    case ss$_normal
		temp$ = left$(Equiv_Name$, bytes_returned%)
	    case else								! paranoia, should never happen
		temp$ = "-e-SYSERR_" + str$(sys_status)				!
		print	temp$ + bel + " In 'WCSM_TrnLnm'"			!
		sleep 2%							!
	end select
	!
	!	copy data back to function and return to caller
	!
	WCSM_TrnLnm = temp$
	!
	end function								!

Back to Home
Neil Rieck
Waterloo, Ontario, Canada.