home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / ZINKY.ZIP / SAMPLE.PRG < prev   
Encoding:
Text File  |  1990-05-01  |  7.4 KB  |  257 lines

  1. ***************************************
  2. *                                     *  
  3. *   MAIN PROGRAM: SAMPLE.PRG          *
  4. *   THREE MODULES INCLUDED:           *
  5. *                                     *
  6. *   1. MAKEDBF.PRG                    *
  7. *   2. EDIT.PRG                       *
  8. *   3. REPORTS.PRG                    *
  9. *                                     *
  10. ***************************************
  11.  
  12. *The #define "Net_use.ch" in Clipper 5.0 tells the
  13. *preprocessor to bring into the program the file
  14. *specified in quotes. 
  15.  
  16. *A practical use of this would be to take the functions
  17. *found at the bottom of our MAIN.PRG and place them in
  18. *a file where you could include them in any network
  19. *application that you would be writing. This saves code
  20. *writing.
  21.  
  22. CLEAR
  23. DO WHILE .T.
  24.   IF ISCOLOR()
  25.     SET COLOR TO n/w,r+/b
  26.   ENDIF
  27.  
  28. *Never assume that the end user has or will always have
  29. *a color monitor. Prompts can be unreadable when the
  30. *color is set wrong.
  31.  
  32.  PUBLIC boxframe, boxfram2
  33.  
  34. *Any global references that you need in you program
  35. *should be located in this section. If at a later time
  36. *you find that you want a variable to be declared
  37. *PUBLIC, come back and place it here. If all the
  38. *variables are kept in one place, it is easier to
  39. *maintain the application and avoid duplicate names.
  40.  
  41.  
  42.  
  43.   boxframe = chr(201)+chr(205)+chr(187)+;
  44.              chr(186)+chr(188)+chr(205)+;
  45.              chr(200)+chr(186)+chr(177)
  46.  
  47. *The above variable boxframe will define the frame of
  48. *our main screen. It will be defined as a PUBLIC
  49. *variable so that we can use it throughout the
  50. *program without having to redefine it.                 
  51.        
  52. *The characters are from the IBM extended character
  53. *set, and the fill character for the box is indicated
  54. *by the final chr(177).             
  55.  
  56.   boxfram2= chr(201)+chr(205)+chr(187)+;
  57.             chr(186)+chr(188)+chr(205)+;
  58.             chr(200)+chr(186)+chr(255)
  59.  
  60. *The above variable boxfram2 will define the middle
  61. *screen where we will display our menu.  
  62. *You do not need a third - party package to do clean
  63. *attractive screens.                          
  64.  
  65. *For example, boxframe consists of the nine characters
  66. *from the extended IBM character set. Many ASCII charts
  67. *contain a handy reference for making frames. The frame
  68. *is described starting with the upper left corner, and
  69. *follows a clockwise motion until arriving where we
  70. *started.      
  71.  
  72. *The extended ASCII characters are as follows:
  73.  
  74. *top left = 201, top center = 205, 
  75. *top right = 187, center right = 186,
  76. *bottom right = 188, bottom center = 205,
  77. *bottom left = 200, center left = 186.
  78. *The last character (177) is used to fill the box. 
  79. *   ╔     ═     ╗   
  80. *  201   205   187       
  81. *   ║           ║        
  82. *  186         186           
  83. *   ╚     ═     ╝   
  84. *  200   205   188       
  85.  
  86. *These characters can be described using Clipper's
  87. *CHR() function, or can be typed diectly into the code
  88. *by using an alt-numeric pad combination. Many word
  89. *processors can create extended ASCII characters by
  90. *holding down the alt key, and typing the desired ASCII
  91. *number in at the numeric keypad. The character desired
  92. *should appear on the screen, allowing the user to
  93. *create lines and frames, as well as other graphics. 
  94.  
  95.  
  96.   @0,0,24,79 BOX boxframe
  97.   @5,5  SAY  DATE()        
  98.   @5,67 SAY  TIME()        
  99.  
  100. *display date at location 5,5
  101. *display time at location 5,67
  102.  
  103.   DO Makedbf             
  104.  
  105. *When a DO (filename) is encountered, it is a call to a
  106. *procedure. A procedure can be defined within the file
  107. *or as a seperate *.PRG.
  108. *Initiating the makedbf  procedure will make the
  109. *program compatible with networking systems by setting  
  110. *exclusive off, more than one user can open datafile.
  111.  
  112. *The Use_udf statement passes a parameter to a function
  113. *that will detemine if you can use the file "a_d" in
  114. *shared mode on the network. 
  115. *Use_udf is a "user defined" function.
  116.  
  117.   IF Use_udf("a_d")      
  118.     SET INDEX TO a_d     
  119.     SET EXCLUSIVE OFF    
  120.   ELSE                 
  121.     RETURN
  122.   ENDIF
  123.   @5,20,19,60 BOX boxfram2   && place box in boxfram2
  124.   @7,31 SAY  "ALBUM COLLECTION"
  125.   @8,31 SAY  "     1990       "
  126.   SET WRAP ON
  127.  
  128. *The SET WRAP ON command is convenience that allows the
  129. *user to scroll across the menu using the right arrow.
  130. *In other words, when reaching the end of a line, the
  131. *user doesn't have to type a carriage return to get to
  132. *the next line.  
  133.  
  134.   main_in = 0
  135.   SET MESSAGE TO 21 CENTER
  136.   @11,32 SAY   "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀█"
  137.   @12,32 PROMPT"█ ADD and EDIT █";
  138.   MESSAGE " ADD,EDIT ALBUMS"
  139.   @13,32 PROMPT"█   REPORTS    █";
  140.   MESSAGE " VIEW AND PRINT REPORT"
  141.   @14,32 PROMPT"█    QUIT      █";
  142.   MESSAGE " CLOSE DATABASES & QUIT "
  143.   @15,32 SAY   "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄█"
  144.   @12,48 SAY                     "▓▓"
  145.   @13,48 SAY                     "▓▓"
  146.   @14,48 SAY                     "▓▓"
  147.   @15,48 SAY                     "▓▓"
  148.   @16,32 SAY     " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"
  149.   MENU TO main_in
  150.   DO CASE
  151.     CASE main_in = 1
  152.       DO Edit
  153.     CASE main_in = 2
  154.       DO Reports
  155.     CASE main_in = 3
  156.       CLEAR SCREEN
  157.       CLOSE DATABASES
  158.       IF ISCOLOR()
  159.         SET COLOR TO n/n
  160.       ENDIF
  161.       STORE 0 TO col,row
  162.       DO WHILE col < 36
  163.         @ row, col CLEAR TO row, 79-col
  164.         @ 24-row, col CLEAR TO 24-row, 79-col
  165.         @ row, col CLEAR TO 24-row, col+3
  166.         @ row, 79-col-3 CLEAR TO 24-row, 79-col
  167.         row = row + 1
  168.         col = col + 3
  169.         x=0
  170.         DO WHILE x < 115
  171.           x= x + 1
  172.         ENDDO
  173.       ENDDO
  174.       SET COLOR TO w/n
  175.       CLEAR
  176.       RETURN
  177.   ENDCASE
  178. ENDDO
  179.  
  180. *A good application requires that you prepare for any
  181. *eventuality. What steps
  182. *should be taken IF ACCESS IS DENIED in a networking
  183. *situation, or how should the program handle erroneous
  184. *keystrokes?
  185.  
  186. *FUNCTION Use_udf is a function used to test whether
  187. *you will be allowed to use the file in shared mode on
  188. *a network. Shared mode means that more than one user
  189. *can use the file at once.
  190.  
  191. FUNCTION Use_udf
  192. PARAMETERS datfil
  193. delay = 5
  194. DO WHILE .T.
  195.   USE &datfil
  196.   IF .NOT. NETERR()
  197.     RETURN (.T.)
  198.   ELSE
  199.     IF delay > 0
  200.       INKEY(1)
  201.       delay = delay - 1
  202.       LOOP
  203.     ELSE
  204.       SAVE SCREEN TO scr1
  205.       conf = ' '
  206.       @ 8,15 CLEAR TO 20,60
  207.       @ 8,15 TO 20,60 DOUBLE
  208.       @ 10,20 SAY "PROGRAM UNAVAILABLE NOW.."
  209.       @ 14,20 SAY "PLEASE TRY AGAIN IN    "
  210.       @ 16,20 SAY "IN FIVE MINUTES        "
  211.       WAIT
  212.       RESTORE SCREEN FROM scr1
  213.       RETURN .F.
  214.     ENDIF
  215.   ENDIF
  216. ENDDO
  217.  
  218. *The following function will attempt to lock a record.
  219. *What this does is lock out other users from using the
  220. *record for input. This ensures that two or more users
  221. *won't be writing to the same record at once. 
  222.  
  223. *There is much more involved in locking
  224. *procedures and networking. Those interested should
  225. *consult their Clipper manuals for more detailed
  226. *explanations.
  227.  
  228. FUNCTION Rlok        
  229. delay = 5            
  230. DO WHILE .T.         
  231.   IF RLOCK()         
  232.     RETURN (.T.)
  233.   ENDIF
  234.   IF delay >0
  235.     INKEY(1)
  236.     delay = delay -1
  237.     LOOP
  238.   ELSE
  239.     SAVE SCREEN TO scr1
  240.     conf=''
  241.     @ 8,15 CLEAR TO 18,60
  242.     @ 8,15 TO 18,60 DOUBLE
  243.     @ 10,20 SAY "RECORD LOCK UNSUCCESSFUL"
  244.     @ 12,20 SAY "DO YOU WANT TO CONTINUE "
  245.     @ 16,20 SAY "   <Y/N> ------------>  "
  246.     SET CURSOR OFF
  247.       IF UPPER(conf)='Y'
  248.         delay = 5
  249.         RESTORE SCREEN FROM scr1
  250.         LOOP
  251.       ELSE
  252.         RESTORE SCREEN FROM scr1
  253.         RETURN .F.
  254.       ENDIF
  255.   ENDIF
  256. ENDDO
  257.