Appendix I: The full code for the Listview example

Previous: Appendix H: HOMER.FOR written as HOMER.F
Next: Appendix J: Efficient use of Fortran (and computing resources)

Appendix I: The full code for the Listview example

      WINAPP
      OPTIONS (INTL, DREAL)
      PROGRAM LV_EXAMPLE
C     ------------------
      INCLUDE 
      CHARACTER*(80) ROWS(11)
      COMMON /INPUT_GRID/ ROWS, X(10), Y(10), Z(10), ISEL(10)
      INTEGER, EXTERNAL:: KB_FOR_LV_GRID

      NROWS   = 11
      iSEL    = 0   ! initialise the array
      iSEL(1) = 1
      iVIEW   = 1

      ROWS    = '| | | | '
      DO 10 I=2,11
      ROWS(I) = '|'//CHAR(I+63)//'| | | '
   10 CONTINUE
      ROWS(1) = '|Station_+65|Easting (m)_+105|Northing (m)_+105|'
     &        //'Altitude (m)_+75'
     
      IW = WINIO@ ('%ca[ListView example]&')
      IW = WINIO@ ('%^lv[edit_cells,go_down_on_return,'//
     &             'single_selection]&',
     &              420,    200,    ROWS,   NROWS,
     &              iSEL,   iVIEW,  KB_FOR_LV_GRID)
      IW = WINIO@ ('%lw%ff%nl%16bt[OK]', LW)
      END

      INTEGER FUNCTION KB_FOR_LV_GRID()
C     ---------------------------------
      CHARACTER*(80) ROWS(11), BAND
      COMMON /INPUT_GRID/ ROWS, X(10), Y(10), Z(10), ISEL(10)
      CHARACTER*(80) CBR, CBE
      CHARACTER*(2)  CBK
      CHARACTER*(1)  KHAR
      CHARACTER*(20) TEXT
      DIMENSION INDEX(11)
      INCLUDE 

      KB_FOR_LV_GRID = 2
      irow = clearwin_info@('ROW_NUMBER')
      icol = clearwin_info@('COLUMN_NUMBER')

      CBE  = CLEARWIN_STRING@ ('EDITED_TEXT')
      CBR  = CLEARWIN_STRING@ ('CALLBACK_REASON')

C     WRITE(*,*) IROW, ICOL, '   ', CBE(1:LEN_TRIM(CBE)), '...  ',
C    &                              CBR(1:LEN_TRIM(CBR))

      IF (iCOL .EQ. 1) RETURN

      IF (CBR .EQ. 'BEGIN_EDIT') THEN
          RETURN
          ELSE IF (CBR .EQ. 'EDIT_KEY_DOWN') THEN
               NK = clearwin_info@('KEYBOARD_KEY')
C                    write(*,*) ' NK= ', NK
                     KB_FOR_LV_GRID = 2
                     L = LEN_TRIM (CBE)
                     K = 0
                     DO 10 M=1,L
                     IF (CBE(M:M) .EQ. '.') K=1  ! decimal point exists
   10                CONTINUE
                     IF (NK .GE. 48 .AND. NK .LE. 57) RETURN
                     IF (NK .EQ. 46 .AND. K  .EQ.  0) RETURN
                     KB_FOR_LV_GRID = 4
                     RETURN
          ELSE IF (CBR .EQ. 'END_EDIT') THEN
               L = LEN_TRIM (ROWS(IROW+1))
               INDEX = L
               BAND  = ROWS (IROW + 1)
               KHAR  = BAND(1:1)
               INDEX(1) = 1
               K = 2
               DO 20 M=2,L
               IF (BAND(M:M) .EQ. KHAR) THEN
                  INDEX(K) = M
                  K        = K + 1
                  ENDIF
   20          CONTINUE
               IF (CBE .EQ. '') THEN
                     TEXT = '    '
                     GO TO 30
                     ENDIF
               READ (CBE,*) VALUE
C               write(*,*) cbe, value
               WRITE (TEXT,'(F12.3)') VALUE

          ELSE IF (CBR .EQ. 'KEY_DOWN') THEN
               CALL BEEP@
               RETURN
          ENDIF

   30 CONTINUE
      ROWS(IROW + 1) = BAND(1:INDEX(ICOL))//TEXT//BAND(INDEX(ICOL+1):L)
      CALL WINDOW_UPDATE@ (ROWS)
      KB_FOR_LV_GRID = 2
      RETURN
      END

      RESOURCES   
      1 24 default.manifest

Hard to follow? Sure. There are other examples on the Silverfrost Forum – search using the term ‘listview’. Good Luck!

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited