define integer   ibe in i0 i1 i2 nbasebands
define double    clight freq offset pol[4,2] rx1 rx2 step
define character mode*1
define logical   up down

let clight 2.9979247E+5
let ibe  &1
let mode &2
let nbasebands febe'ibe'%header%febeband

define double rxStart[nbasebands] rxEnd[nbasebands]

let pol[1:2,2] user_ymin
let pol[3:4,2] user_ymax

let freq data'ibe'%header%crvl4f_2*1e-9

for i 1 to nbasebands
!
    let step array'ibe'%header'i'%cd4f_21*1e-9
    let offset array'ibe'%header'i'%crvl4f_2*1e-9
    let i0 array'ibe'%header'i'%crpx4f_2
    let i1 array'ibe'%header'i'%dropchan+1
    let i2 array'ibe'%header'i'%dropchan+array'ibe'%header'i'%usedchan
    let rx1 (i1-i0)*step+offset
    let rx2 (i2-i0)*step+offset
    if mode.eq."V" then
       let rx1 -(rx1-freq)/freq*clight+data'ibe'%header%crvl4r_2
       let rx2 -(rx2-freq)/freq*clight+data'ibe'%header%crvl4r_2
    endif
    let rxStart[i] min(rx1,rx2)
    let rxEnd[i]   max(rx1,rx2)
!
next
!
sic\sort rxStart rxEnd
!
for i 2 to nbasebands
    if rxStart[i].lt.rxEnd['i-1'] then
       let pol[1,1] rxStart[i]
       let pol[2,1] rxEnd['i-1']
       let pol[3,1] rxEnd['i-1']
       let pol[4,1] rxStart[i]
       poly pol /variable /fill 12
    else
       pen /col 12
       draw relocate rxStart[i] user_ymin  /user
       draw line     rxStart[i] user_ymax  /user
       draw relocate rxEnd['i-1'] user_ymin  /user
       draw line     rxEnd['i-1'] user_ymax  /user
       pen /def
    endif
next
!
return
!

