From: John Sybalsky Subject: Lisp Odometer Package I've packaged up my odometer hack, and it is available for general toying around What's an Odometer? It's a collection of 1 or more side-by-side windows on the screen, each of which can display a single digit. The windows can be scrolled up and down, either by mouse action, or by calls to the appropriate functions. The windows are coupled so that carrying and borrowing occur whenever a window scrolls between 0 and 9 in either direction. Carrying/borrowing off the left end has no effect. The Odometer Object An odometer is represented internally as a list of the windows which implement it. The elements of the list are in the same order as the digits in the odometer, with the first element in the list being the highest-order digit in the odometer, and the last element the units digit. Each window has the following data associated with it (using the WINDOWPROP function), under the indicators shown: Indicator Description DGT An integer; the digit this window contains, or -1 if the window is blank. Every window is blank when it is first created, and can be blanked out using ODOSET (below). NXTD A window; this is the next higher window, and is used for carrying or borrowing. The highest-order window has nothing associated with it under this indicator; you may suppress carrying from any given window by doing (WINDOWPROP window 'NXTD NIL). BUTTONEVENTFN The function that's called when a mouse button is hit with the cursor inside the window. This is initialized to ODOBUTTONFN for all digit windows. ODOBUTTONFN scrolls to the next higher digit when the RED button is hit, and the next lower digit when the YELLOW button is hit. It will continue to scroll as long as the button is held down, even if the mouse is Moved out of the window. This can lead to counter-intuitive results. ODOINCFN A function to be called when this digit is incremented, or NIL. This is initially NIL, and may be set by the user as needed. This is intended to provide a synchronizing interface to other packages. ODODECFN A function to be called wen this digit is decremented, or NIL. Analogous to ODOINCFN. BMARRAY An array of bitmaps containing the digits that can be displayed. This should not be changed. Functions Available ODOCREATE[ #digits font place ] Creates and returns an odometer containing #digits digits. The digits will be displayed in font font, and place is the POSITION of the lower lefthand corner of the high-order digit's window. The remaining digits are positioned automatically, according to the font being used. font defaults to TimesRomanD 36, and place defaults to a request that the user indicate a spot using GETPOSITION. ODOCLOSE[ odometer ]œCloses all the windows in the list odometer. These may later be reopened. ODOOPEN[ odometer ]œOpens all the windows in the list odometer. ODOSET[ odometer value ]œSets the digits of odometer to represent value, which is an integer. Any high-order digits of value's representation which don't fit are discarded without comment; any high-order digits or the odometer which aren't needed to represent value are blanked out rather than being filled with zeros. Therefore, to blank all the digits of an odometer, do (ODOSET odometer 0). ODOPUT[ window value ]œSets the odometer digit window window to contain the digit representing the integer value. value should be in the range -1 to 9. Values of 0›9 represent themselves; -1 blanks the windowÂ. ODOINC[ window ]œScrolls the odometer window window to the next higher digit, carrying as needed. As a side effect, anything associated with the window under the indicator ODOINCFN will be applied to the window after the scrolling is complete. ODODEC[ window ]œScrolls the odometer window window to the next lower digit, borrowing as needed. As a side effect, anything associated with the window under the indicator ODODECFN will be applied to the window after the scrolling is complete.