Progress
Language Tutorial
for Character


Slider Programming Example

Follow these steps to contrast horizontal and vertical sliders.

  1. Open lt-07-07a.p and run it. The following display appears:
  2. To change the value, drag the pointer located in the trackbar. At each increment, the value changes, a trigger executes, and the X character moves.
  3. Press TAB to move to the second slider, or just click on the pointer in the second slider.
  4. Use the cursor keys to move the pointer. At each increment, the value changes, a trigger executes, and the X character moves.
  5. Choose Exit, then press SPACEBAR to return to the Procedure Editor.

Here is the code that created the sliders:

lt-07-07a.p
      /**********  DEFINE WIDGETS  **********/
/*1*/  DEFINE VARIABLE X-Coord AS INTEGER INITIAL 1 VIEW-AS SLIDER 
          MIN-VALUE 1 MAX-VALUE 20 HORIZONTAL SIZE-CHARS 20 BY 2.5
          TIC-MARKS BOTTOM FREQUENCY 5 NO-CURRENT-VALUE.
/*2*/  DEFINE VARIABLE Y-Coord AS INTEGER INITIAL 1 VIEW-AS SLIDER 
          MIN-VALUE 1 MAX-VALUE 10 VERTICAL SIZE-CHARS 10 BY 10.
         TIC-MARKS RIGHT FREQUENCY 1 LARGE-TO-SMALL NO-CURRENT-VALUE.
      DEFINE VARIABLE Point AS CHARACTER INITIAL "X" FORMAT "x" 
           VIEW-AS TEXT.
      DEFINE VARIABLE Coords AS CHAR FORMAT "x(5)" VIEW-AS TEST.
      DEFINE BUTTON btn-Exit LABEL "Exit".
      /**********  DEFINE FRAMES  **********/
      DEFINE FRAME Frame1
          Coords NO-LABEL AT ROW 1 COLUMN 1
          X-Coord NO-LABEL AT ROW 1 COLUMN 12 SKIP
           Y-Coord NO-LABEL
           btn-Exit AT ROW 14 COLUMN 1
           Point NO-LABEL 
               WITH SIZE-CHARS 36 BY 15 THREE-D.
      /**********  DEFINE TRIGGERS  **********/
/*3*/  ON VALUE-CHANGED OF X-Coord, Y-Coord
       DO:
          ASSIGN X-Coord
                 Y-Coord
/*4*/           Point:COL = (X-Coord:COL) + (X-Coord - 1)
                         /* (Starting Position) + (Offset) */
                Point:ROW = (Y-Coord:ROW) + (Y-Coord - 1)
                         /* (Starting Position) + (Offset) */
               Coords:SCREEN-VALUE = STRING(X-Coord, "99") + "," +
                                  STRING(Y-Coord, "99").
       END.  
      /**********  MAIN LOGIC  **********/
      DISPLAY X-Coord Y-Coord Point WITH FRAME Frame1.
      ENABLE ALL WITH FRAME Frame1.
      WAIT-FOR CHOOSE OF btn-Exit. 

These notes help explain the code highlights:

  1. The first slider is horizontal and displays the X coordinate of the character that moves within the area of the sliders. Tic marks are defined for every fifth position in the range and the tic marks display on the bottom of the slider. The NO-CURRENT-VALUE option indicates that the current value of a position on the slider will not automatically display.
  2. The second slider is vertical and displays the Y coordinate of the character. This slider also has tic marks defined for every numeric position in the defined range. The tic marks display on the right-hand side of the slider. Also, the LARGE-TO-SMALL option is defined; for this vertically orientated slider, this means that the bottom most position on the trackbar displays the maximum value and the top most position displays the minimum value of the range. The NO-CURRENT-VALUE is set indicating the current position of the pointer on the slider will not automatically display.
  3. On VALUE-CHANGED of either slider, this trigger moves the character to the appropriate position.
  4. The ROW and COL attributes specify the location of the widget within a frame.
NOTE: Keep in mind that ToolTip information can be added to a slider widget. Refer to the code examples in either the Toggle Box Programming Example or the Radio Set Programming Example presented earlier in this chapter that show how to define the TOOLTIP option.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095