home *** CD-ROM | disk | FTP | other *** search
- ***************************************
- * *
- * MAIN PROGRAM: SAMPLE.PRG *
- * THREE MODULES INCLUDED: *
- * *
- * 1. MAKEDBF.PRG *
- * 2. EDIT.PRG *
- * 3. REPORTS.PRG *
- * *
- ***************************************
-
- *The #define "Net_use.ch" in Clipper 5.0 tells the
- *preprocessor to bring into the program the file
- *specified in quotes.
-
- *A practical use of this would be to take the functions
- *found at the bottom of our MAIN.PRG and place them in
- *a file where you could include them in any network
- *application that you would be writing. This saves code
- *writing.
-
- CLEAR
- DO WHILE .T.
- IF ISCOLOR()
- SET COLOR TO n/w,r+/b
- ENDIF
-
- *Never assume that the end user has or will always have
- *a color monitor. Prompts can be unreadable when the
- *color is set wrong.
-
- PUBLIC boxframe, boxfram2
-
- *Any global references that you need in you program
- *should be located in this section. If at a later time
- *you find that you want a variable to be declared
- *PUBLIC, come back and place it here. If all the
- *variables are kept in one place, it is easier to
- *maintain the application and avoid duplicate names.
-
-
-
- boxframe = chr(201)+chr(205)+chr(187)+;
- chr(186)+chr(188)+chr(205)+;
- chr(200)+chr(186)+chr(177)
-
- *The above variable boxframe will define the frame of
- *our main screen. It will be defined as a PUBLIC
- *variable so that we can use it throughout the
- *program without having to redefine it.
-
- *The characters are from the IBM extended character
- *set, and the fill character for the box is indicated
- *by the final chr(177).
-
- boxfram2= chr(201)+chr(205)+chr(187)+;
- chr(186)+chr(188)+chr(205)+;
- chr(200)+chr(186)+chr(255)
-
- *The above variable boxfram2 will define the middle
- *screen where we will display our menu.
- *You do not need a third - party package to do clean
- *attractive screens.
-
- *For example, boxframe consists of the nine characters
- *from the extended IBM character set. Many ASCII charts
- *contain a handy reference for making frames. The frame
- *is described starting with the upper left corner, and
- *follows a clockwise motion until arriving where we
- *started.
-
- *The extended ASCII characters are as follows:
-
- *top left = 201, top center = 205,
- *top right = 187, center right = 186,
- *bottom right = 188, bottom center = 205,
- *bottom left = 200, center left = 186.
- *The last character (177) is used to fill the box.
- * ╔ ═ ╗
- * 201 205 187
- * ║ ║
- * 186 186
- * ╚ ═ ╝
- * 200 205 188
-
- *These characters can be described using Clipper's
- *CHR() function, or can be typed diectly into the code
- *by using an alt-numeric pad combination. Many word
- *processors can create extended ASCII characters by
- *holding down the alt key, and typing the desired ASCII
- *number in at the numeric keypad. The character desired
- *should appear on the screen, allowing the user to
- *create lines and frames, as well as other graphics.
-
-
- @0,0,24,79 BOX boxframe
- @5,5 SAY DATE()
- @5,67 SAY TIME()
-
- *display date at location 5,5
- *display time at location 5,67
-
- DO Makedbf
-
- *When a DO (filename) is encountered, it is a call to a
- *procedure. A procedure can be defined within the file
- *or as a seperate *.PRG.
- *Initiating the makedbf procedure will make the
- *program compatible with networking systems by setting
- *exclusive off, more than one user can open datafile.
-
- *The Use_udf statement passes a parameter to a function
- *that will detemine if you can use the file "a_d" in
- *shared mode on the network.
- *Use_udf is a "user defined" function.
-
- IF Use_udf("a_d")
- SET INDEX TO a_d
- SET EXCLUSIVE OFF
- ELSE
- RETURN
- ENDIF
- @5,20,19,60 BOX boxfram2 && place box in boxfram2
- @7,31 SAY "ALBUM COLLECTION"
- @8,31 SAY " 1990 "
- SET WRAP ON
-
- *The SET WRAP ON command is convenience that allows the
- *user to scroll across the menu using the right arrow.
- *In other words, when reaching the end of a line, the
- *user doesn't have to type a carriage return to get to
- *the next line.
-
- main_in = 0
- SET MESSAGE TO 21 CENTER
- @11,32 SAY "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀█"
- @12,32 PROMPT"█ ADD and EDIT █";
- MESSAGE " ADD,EDIT ALBUMS"
- @13,32 PROMPT"█ REPORTS █";
- MESSAGE " VIEW AND PRINT REPORT"
- @14,32 PROMPT"█ QUIT █";
- MESSAGE " CLOSE DATABASES & QUIT "
- @15,32 SAY "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄█"
- @12,48 SAY "▓▓"
- @13,48 SAY "▓▓"
- @14,48 SAY "▓▓"
- @15,48 SAY "▓▓"
- @16,32 SAY " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"
- MENU TO main_in
- DO CASE
- CASE main_in = 1
- DO Edit
- CASE main_in = 2
- DO Reports
- CASE main_in = 3
- CLEAR SCREEN
- CLOSE DATABASES
- IF ISCOLOR()
- SET COLOR TO n/n
- ENDIF
- STORE 0 TO col,row
- DO WHILE col < 36
- @ row, col CLEAR TO row, 79-col
- @ 24-row, col CLEAR TO 24-row, 79-col
- @ row, col CLEAR TO 24-row, col+3
- @ row, 79-col-3 CLEAR TO 24-row, 79-col
- row = row + 1
- col = col + 3
- x=0
- DO WHILE x < 115
- x= x + 1
- ENDDO
- ENDDO
- SET COLOR TO w/n
- CLEAR
- RETURN
- ENDCASE
- ENDDO
-
- *A good application requires that you prepare for any
- *eventuality. What steps
- *should be taken IF ACCESS IS DENIED in a networking
- *situation, or how should the program handle erroneous
- *keystrokes?
-
- *FUNCTION Use_udf is a function used to test whether
- *you will be allowed to use the file in shared mode on
- *a network. Shared mode means that more than one user
- *can use the file at once.
-
- FUNCTION Use_udf
- PARAMETERS datfil
- delay = 5
- DO WHILE .T.
- USE &datfil
- IF .NOT. NETERR()
- RETURN (.T.)
- ELSE
- IF delay > 0
- INKEY(1)
- delay = delay - 1
- LOOP
- ELSE
- SAVE SCREEN TO scr1
- conf = ' '
- @ 8,15 CLEAR TO 20,60
- @ 8,15 TO 20,60 DOUBLE
- @ 10,20 SAY "PROGRAM UNAVAILABLE NOW.."
- @ 14,20 SAY "PLEASE TRY AGAIN IN "
- @ 16,20 SAY "IN FIVE MINUTES "
- WAIT
- RESTORE SCREEN FROM scr1
- RETURN .F.
- ENDIF
- ENDIF
- ENDDO
-
- *The following function will attempt to lock a record.
- *What this does is lock out other users from using the
- *record for input. This ensures that two or more users
- *won't be writing to the same record at once.
-
- *There is much more involved in locking
- *procedures and networking. Those interested should
- *consult their Clipper manuals for more detailed
- *explanations.
-
- FUNCTION Rlok
- delay = 5
- DO WHILE .T.
- IF RLOCK()
- RETURN (.T.)
- ENDIF
- IF delay >0
- INKEY(1)
- delay = delay -1
- LOOP
- ELSE
- SAVE SCREEN TO scr1
- conf=''
- @ 8,15 CLEAR TO 18,60
- @ 8,15 TO 18,60 DOUBLE
- @ 10,20 SAY "RECORD LOCK UNSUCCESSFUL"
- @ 12,20 SAY "DO YOU WANT TO CONTINUE "
- @ 16,20 SAY " <Y/N> ------------> "
- SET CURSOR OFF
- IF UPPER(conf)='Y'
- delay = 5
- RESTORE SCREEN FROM scr1
- LOOP
- ELSE
- RESTORE SCREEN FROM scr1
- RETURN .F.
- ENDIF
- ENDIF
- ENDDO
-