home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / cuaclip.zip / EX4.PRG < prev    next >
Text File  |  1993-06-01  |  2KB  |  76 lines

  1. /*********************************************************************
  2.  
  3.     EX4.PRG - CUA-Clip Library examples.
  4.  
  5.     This file contains sample code illustrating a basic STDBrowse.
  6.  
  7.     For a more elaborate example of STDBrowse, and an example of
  8.     using STDBrowse with arrays, see the functions _BrowseFile()
  9.     and GetFile() in Misc.PRG.
  10.  
  11.     Author: Dave Rooney
  12.     Date  : Feb. 22, 1993
  13.  
  14. *********************************************************************/
  15.  
  16. #include "Demo.CH"
  17.  
  18. //
  19. // Example 4 - Basic STDBrowse.
  20. //
  21.  
  22. FUNCTION Browse_Examples
  23.  
  24. LOCAL aFields,    ; // Fields array for the browse
  25.         cColor,     ; // Colour string for the browse
  26.         cTitle,     ; // Title text
  27.         i             // Loop counter
  28.  
  29. //
  30. // Ensure Printer.DBF/.NTX are there.  If not, make 'em!
  31. //
  32. IF !( FILE( "Printer.DBF" ) .AND. FILE( "Printer.NTX" ))
  33.     _BuildPrinter()
  34. ENDIF
  35.  
  36. //
  37. // Open the printer file.
  38. //
  39. IF DBNetUse( .T., "DBFNTX", "Printer" )
  40.     DBSETINDEX( "Printer" )
  41. ELSE
  42.     RETURN NIL
  43. ENDIF
  44.  
  45. //
  46. // Load the fields array from Printer...
  47. //
  48. aFields := ARRAY( FCOUNT(), 2 )
  49.  
  50. FOR i := 1 TO FCOUNT()
  51.     aFields[ i, 1 ] := FIELDNAME( i )
  52.     aFields[ i, 2 ] := FIELDBLOCK( FIELDNAME( i ))
  53. NEXT
  54.  
  55. cColor := "B/BG,GR+/BG,W+/BG,W+/R"
  56. cTitle := " Printer Lookup File "
  57.  
  58. Message( "Press <ESC> to return..." )
  59.  
  60. //
  61. // Simple as that!
  62. //
  63. STDBrowse( 5, 3, MAXROW() - 5, MAXCOL() - 3, aFields, cTitle,, cColor, .F. )
  64.  
  65. //
  66. // Close the printer file...
  67. //
  68. DBNetClose( "Printer" )
  69.  
  70. Message("")
  71.  
  72. RETURN NIL
  73. //
  74. // That's all folks!
  75. //
  76.