#!/bin/csh -f
#+
# goisleep -- acquire images with pauses in between
#
# Purpose:
#	Take a series of images and pause for a given amount of time
#	in between
#
# Usage:
#	goisleep [-dark] [nexp [sleep]]
# 
# Arguments:
#	-dark	= take DARK exposure (shutter does not open)
#	nexp	= number of exposure to take (default=1)
#	sleep	= number of seconds to sleep
# 
# Output:
#	Text feedback is sent to the terminal.
# 
# Restrictions:
# 
# Exit values:
#	 0 = normal completion
#	 1 = wrong number of arguments
#
# Example:
#
#-
# Modification history:
#	2000-Jan-01	GDW	Original version
#-----------------------------------------------------------------------

# define defaults...
@ nexp = 1
set sleep = 10
set args = ""

set buf = $0
set cmd = $buf:t
set usage = "Usage: $cmd [-dark] [nexp [sleep]]"

# flag check...
foreach arg ($*)

    # check optional argument...
    if ( "$1" == "-nowait" ) then
	set args = ($args -nowait)
	shift
    endif

    # check optional argument...
    if ( "$1" == "-dark" ) then
	set args = ($args -dark)
	shift
    endif

end

# verify args...
if ( $#argv > 2 ) then
  printf "$usage\n"
  exit 1
endif

# parse args...
if ( $#argv >= 1 ) then
    @ nexp = $1
    shift
endif

if ( $#argv >= 1 ) then
    @ sleep = $1
    shift
endif

# loop over number of exposures...
@ n=1
while ( $n <= $nexp )

    printf "  Iteration $n/$nexp\n"
    echo goi $args
    printf "  Sleeping $sleep seconds"
    sleepdots $sleep
    @ n++

end