Usage example: HEXAPOD status

Suppose we prepared virtual motors scripts vm1 to vm6 in a way that they allow us to operate x, y, z, u, v, w of a hexapod. The following lines could be part of /online_dir/exp_ini.exp. The result is that vm1 to vm6 are available in Online only, if the user requested to define them and if the hexapod is online.

if noyes("Use hexapod")
  say "testing HEXAPOD status... "
  if hexapod( status)
    if !search_device( vm1) then def vm1
    if !search_device( vm2) then def vm2
    if !search_device( vm3) then def vm3
    if !search_device( vm4) then def vm4
    if !search_device( vm5) then def vm5
    if !search_device( vm6) then def vm6
  else
    if search_device( vm1) then undef vm1
    if search_device( vm2) then undef vm2
    if search_device( vm3) then undef vm3
    if search_device( vm4) then undef vm4
    if search_device( vm5) then undef vm5
    if search_device( vm6) then undef vm6
    cls/alpha
    say "HEXAPOD is offline, vm1 - vm6 NOT defined"
  endif
else
  if search_device( vm1) then undef vm1
  if search_device( vm2) then undef vm2
  if search_device( vm3) then undef vm3
  if search_device( vm4) then undef vm4
  if search_device( vm5) then undef vm5
  if search_device( vm6) then undef vm6
endif