!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! @ l-old-prange
!
! &1: aaa
! &2: center  [sec]
! &3: size    [sec]
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Find X and Y axis number
define integer jaxis[2] kaxis
let jaxis '&1%x_axis' '&1%y_axis'
!
! Leave center & size in seconds because they are used to compute
! true%prange%s. do%scoord is applied later on.
let true%center &2  ! [sec]
let true%size &3    ! [sec]
!
! Loop over X and Y axis
for iaxis 1 to 2
   ! Alias iaxis number to a simple variable for readability
   let kaxis jaxis[iaxis]
   ! Sanity check
   if (kaxis.eq.0) then
      ! iaxis does not exist => Try something clever...
      if (iaxis.eq.1) then
         message w prange "No X axis in data cube"
      else
         message w prange "No Y axis in data cube"
      endif
      let true%prange%p[iaxis] 0.5 &1%dim[iaxis]+0.5
      let true%prange%r[1,iaxis] &1%convert[2,iaxis]+(true%prange%p[iaxis]-0.5-&1%convert[1,iaxis])*&1%convert[3,iaxis]
      let true%prange%r[2,iaxis] &1%convert[2,iaxis]+(true%prange%p[iaxis]+0.5-&1%convert[1,iaxis])*&1%convert[3,iaxis]
      let true%prange%s[iaxis] true%prange%r[iaxis]/sec
   else
      ! iaxis exist => Use its information
      if (true%size[iaxis].ne.0) then
         ! size[iaxis] != 0 => Use the user-defined range
         if (&1%convert[3,kaxis].gt.0) then
            ! Axis increment > 0 => Plotted direction identical to native direction
            let true%prange%s[iaxis] 'true%center[iaxis]-true%size[iaxis]/2' 'true%center[iaxis]+true%size[iaxis]/2'
         else if (&1%convert[3,kaxis].lt.0) then
            ! Axis increment < 0 => Plotted direction inverse to native direction
            let true%prange%s[iaxis] 'true%center[iaxis]+true%size[iaxis]/2' 'true%center[iaxis]-true%size[iaxis]/2'
         else
            ! Axis increment = 0 => Problem
            say " "
            message e prange "&1%convert[3,"'kaxis'"] is zero valued"
            say " "
            return base
         endif
         let true%prange%r[iaxis] true%prange%s[iaxis]*sec
         let true%prange%p[iaxis] &1%convert[1,kaxis]+(true%prange%r[iaxis]-&1%convert[2,kaxis])/&1%convert[3,kaxis]
      else
         ! size[iaxis] = 0 => Default to full axis in native direction
         let true%prange%p[iaxis] 1 &1%dim[kaxis]
         ! Define true%prange%r and true%prange%s accordingly
         let true%prange%r[1,iaxis] &1%convert[2,kaxis]+(true%prange%p[1,iaxis]-0.5-&1%convert[1,kaxis])*&1%convert[3,kaxis]
	 let true%prange%r[2,iaxis] &1%convert[2,kaxis]+(true%prange%p[2,iaxis]+0.5-&1%convert[1,kaxis])*&1%convert[3,kaxis]
         let true%prange%s[iaxis] true%prange%r[iaxis]/sec
      endif
   endif
next iaxis
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
