Results 1 to 4 of 4

Thread: How do I prevent users from changing data from other users using the function?

  1. #1

    Thread Starter
    Join Date
    Jun 2000


    There's something that I don't understand.

    If you have a program that several users can access at the same time. Then how do I prevent users from changing the outcome of functions and procedures of users which are also using those functions at the same time?

    Let's say that user 1 is in a directory which has 20 files. and user 1 starts a function which retrieves the directory listing. He calls the function RetrieveDir(user) where user is 1.

    The function then retrieves the list and stores:
    Dim x
    User(user).file(x) = filename1 x=x+1)
    User(user).file(x) = filename2 x=x+1)
    etc. etc.

    This would work fine, but what if user 2 calls the same function in a directory with ony 4 files
    while the function is still working on User(1) file 5?

    wouldn't user(2) then get files 5-20 from user(1) while there are only 4 files, and wouldn't user(1) never exit that function?

    And doesn't the Dim X that user(2) triggers reset the value of X that user(1) was still using?

    um... is it a little clear what my problem is?

    How can I make a function so that everyone can access it no matter when and the outcome would be correct even if other users are in that same function at the same time?

  2. #2
    I'm not exactly sure how it works, but the key to your
    delimma should be found in record locking. Check out the
    differences between "pessimistic" and "optimistic" locking.

    Hopefully this will help.

    Good Luck

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Diiferent users will create local copies of the functions. Each user's 'x' will be private to them.

    In your example, directory listings would be retrieved from the Operating System. The OS would return data to the users independently of each other. There will not be a clash between the users use of the functions because each will be running in a separate address space. Don't forget that functions are merely used to manipulate the registers on the local machine running the EXE. Unless User 1 and User 2 are on the same PC, no clash will occur.

    Think of two users running Word. Calling the Document.Open function in Word independently will not give User 2, User 1's document...

    Locking will only apply to two users accessing the same records in a database, which I don't think is your q.

    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4

    Thread Starter
    Join Date
    Jun 2000
    I'm not working with records, but Paulw's answer answered my question.

    Thank you both for your reply.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width