How to limit the number of user running a program design using vfp??
For a one user control, what I did was using a counter to record the number of time a program run in a dbf file. If the user number is ONE, the lncounter = 1 and so if run another time, the lncounter = 2 and since the number of user allowed was ONE, the program will display a message "Please run the program one at a time".
Well, it works just fine until yesterday the computer "hang" for whatever reasons ... when I re-run the program, the display message "Please run the program one at a time" appear. Appearantly, the lncounter that was in the dbf was not reset to zero.
I have to access the dbf file, reset the counter to Zero before running the program again. Since I have already complied the program, my user will not know how to solve this problem.
I tried the program. It works with some modification.
1. IF FOPEN(???F:\MyApp\??? + TextFile) - under VFP6, the return type is numeric and not logic. Thus unable to FOPEN this program line.
What I did was: abc = FOPEN(???F:\MyApp\??? + TextFile) if abc != -1 wait window ???open file??? timeout 1 else wait window ???cannot open file??? timeout 1 endif
One little problem I found out was that when the maximum number of users is more than one or two. If the same user logs in using the same id and password multiple times, the program is unable to detect the multi-entry by same user. Since my program will be sold to Small, Medium Enterprise (SME), it is highly probable that the buyer may log in using same id for all work-stations. Just a precaution, any ways to prevent such incidents?
Thank you vm
Sincerely
Ignatiuus Ong
Was this solution helpful? Show your Appreciation by rating it:
Show your appreciation by commenting on How to control the number of users running the software?:
Solution #4
posted on Aug 09, 2005
herself - usenet poster
Rank: Apprentice Rating: 0%, 0 votes
Ignatiuus, Rather than using a counter field, it better to use a FLOCK(). This allows you to check to see if the record is locked, then it's in use, otherwise it will be locked. If you need to support multiple users, just add the number of records you want as the maximum at a time and search for any unlocked record. The big advantage is that if the program crashes or the connection is lost for some other reason, then the server will automatically unlock the record and the record will be available to another login attempt.
Rick
Was this solution helpful? Show your Appreciation by rating it: