Archive

The Sentinel

Today in Barton’s compsci class we went over simple user-controlled looping.  This allows us to collect variable amounts of input from user, without asking them explicitly for the number of fields in advance.

We used Barton’s Constant (-999) as a sentinel value to trigger the end of the data set.  In many ways this is a lame solution, since -999 may be a valid data point for some data sets, and it also requires additional instructions at each prompt to let the user know how to exit the loop.  In the future, we’ll hopefully learn how to trap Ctrl-C or Ctrl-D to make this simpler, or maybe we can simply detect a null input to indicate list completion.

Of course, all of the above is moot once we get into Graphical User Interfaces.  But for command-line stuff, I guess there aren’t really any better solutions…