home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION HRULER
- *****************************************************************
-
- * Display a calibrated horizontal ruler line
-
- * Copyright(c) 1991 - James Occhiogrosso
-
- #include "inkey.ch"
- #include "setcurs.ch"
- # define RULER '└┴┴┴┼┴┴┴┘'
-
- LOCAL colcount, h_col := 0, h_row := INT(MAXROW()/2), ;
- h_ruler := '', keypress := 0, old_col := COL(), old_color, ;
- old_cursor, old_row := ROW(), old_screen
-
- * Save entry conditions
- old_cursor = SETCURSOR(SC_NONE)
- old_color = SETCOLOR(colbarhi)
- old_screen = SCRNSAVE(h_row, 0, h_row, MAXCOL())
-
- * Define horizontal ruler
- FOR colcount = 0 TO MAXCOL() STEP 10
- IF colcount % 10 = 0 .AND. colcount < 100
- * Each 10th column less than 100
- h_ruler := h_ruler + PAD(colcount, 1)
- ELSEIF colcount % 10 = 0
- * Each 10th column greater than 100
- h_ruler := h_ruler + PAD(colcount-100, 1)
- ENDIF
- h_ruler := h_ruler + RULER
- NEXT
-
- * Display horizontal ruler
- @ h_row, 0 SAY h_ruler
-
- * Process arrow keys for ruler movement
- DO WHILE keypress != K_ESC
- keypress = INKEY(0)
- SCRNREST(old_screen)
-
- * Adjust row and column for each arrow key pressed
- IF keypress = K_RIGHT
- h_col = IF(h_col < MAXCOL(), h_col+1, MAXCOL())
-
- ELSEIF keypress = K_LEFT
- h_col = IF(h_col > 0, h_col-1, 0)
-
- ELSEIF keypress = K_UP
- h_row = IF(h_row > 0, h_row-1, 0)
- old_screen = SCRNSAVE(h_row, 0, h_row, MAXCOL())
-
- ELSEIF keypress = K_DOWN
- h_row = IF(h_row < MAXROW(), h_row+1, MAXROW())
- old_screen = SCRNSAVE(h_row, 0, h_row, MAXCOL())
- ENDIF
-
- * Display ruler in new position
- @ h_row, h_col SAY SUBSTR(h_ruler, 1, (MAXCOL() - h_col)+1)
-
- IF keypress = K_ALT_V
- * Display vertical ruler
- DO vruler
- ENDIF
-
- IF keypress = K_ALT_H
- * Display another horizontal ruler
- DO hruler
- ENDIF
-
- ENDDO
-
- * Restore entry conditions and return
- SCRNREST(old_screen)
- SETPOS(old_row, old_col)
- SETCOLOR(old_color)
- SETCURSOR(old_cursor)
- RETURN NIL
-
-