language grl 0.1
module W2ControlFlow
  const speed v = joint(30 %)
  const zone zf = fine
  var bool ready = true
  var bool fault = false
  var int mode = 2
  var int retry = 0
  target home = joint_target { joints: [0 deg, 0 deg, 0 deg, 0 deg, 0 deg, 0 deg] }
  proc main()
    if ready == true
      movej home speed v zone zf
    elseif fault == true
      alarm FAULT "fault"
    else
      alarm NOT_READY "not ready"
    end
    while retry < 1
      retry = 1
      continue
    end
    for i = 1 to 2 step 1
      movej home speed v zone zf
    end
    switch mode
      case 1
        alarm MODE1 "mode 1"
        break
      case 2
        movej home speed v zone zf
      default
        alarm MODE_OTHER "mode other"
    end
  end
end
