Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/device_axes.pro'
;+
; NAME:
;	device_axes
; PURPOSE:
;	Return the device-axis structures for axes that are being used.
; CALLING:
;	dev_axes = device_axes( Maxis )
; INPUTS:
;	Maxis = max and min # of axes to return (always returns Maxis elements),
;		default = 1.
; KEYWORDS:
;	/INITIALIZE : just return empty axis structures, for initialization.
; OUTPUTS:
;	Function returns an array of structures with positions of device-axes.
; EXTERNAL CALLS:
;	function N_struct
;	function gpib_dev_struct
; COMMON BLOCKS:
;	common gpib, devices				;the device positions.
;	common gpib_dev_struct, gpib_dev, dev_axis	;structure templates
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1994.
;-

function device_axes, Maxis, INITIALIZE=init

  common gpib, devices
  common gpib_dev_struct, gpib_dev, dev_axis

	if N_elements( Maxis ) NE 1 then Maxis=1
	Maxis = Maxis > 1

	if keyword_set( init ) then begin
		if N_struct( dev_axis ) NE 1 then d = gpib_dev_struct(1)
		return, replicate( dev_axis, Maxis )
	   endif

	if N_struct( devices ) LE 0 then begin
		message,"common gpib, devices structure is not defined",/INFO
		return, replicate( dev_axis, Maxis )
	   endif

	axes = devices.axis
	axes = axes( where( strlen( strtrim( axes.name, 2 ) ) GT 0, nax ) > 0 )
	nax = nax > 1 
	if (nax GT Maxis) then return, axes(0:Maxis-1)
	if (nax LT Maxis) then return,[ axes, replicate( dev_axis, Maxis-nax ) ]

return, axes
end