#!/bin/tcsh -f

if ("$1" == "-h" || "$1" == "-help") then
      goto HELP
endif
      
set ll = `which prompt_user`
if ($status) then  
   echo ">>>"
   if ($#argv > 0) then
      echo "$*"
   endif
   printf ">>>    Hit Enter twice when ready..."
   set jnk = ($<)
   if ($#jnk == 1) then
      if ("$jnk[1]" == 'q' || "$jnk[1]" == 'Q') then
         exit 1
      endif
   endif
   printf ">>>       again ('q' to quit)"
   set jnk = ($<)
   echo ""
   if ($#jnk == 1) then
      if ("$jnk[1]" == 'q' || "$jnk[1]" == 'Q') then
         exit 1
      endif
   endif
   exit 0
else
   if ($#argv > 0) then
      set ii = `prompt_user -pause "$*"`
   else 
      set ii = `prompt_user -pause 'Waiting for input'`
   endif
   if ($ii) then
      exit 0
   else 
      exit 1
   endif
endif 

goto END

HELP:
   echo ""
   echo "Prompts user with message and waits for acknowledgment"
   echo "Status is 0 if user presses OK, 1 if user cancels"
   echo "   Example:"
   echo '   @demo_prompt "touch your nose" ; echo $status'
   echo ""
   goto END
   
END:
