Results 1 to 4 of 4

Thread: saving record score automatically

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Location
    Colorado
    Posts
    8

    Unhappy saving record score automatically

    I have some games where I save the record score automatically when the user has beat it. My code is as follows:
    Private Function BringinRS()
    On Error GoTo SetRS
    Open "C:\My Documents\Chris Games\Quad2RS.txt" For Input As #1
    Input #1, RS
    Close #1
    Exit Function
    SetRS:
    RS = 0
    Open "C:\My Documents\Chris Games\Quad2RS.txt" For Output As #1
    Print #1, RS
    Close #1
    End Function
    Private Function SaveRS()
    Open "C:\My Documents\Chris Games\Quad2RS.txt" For Output As #1
    Print #1, S
    Close #1
    End Function
    If there is no record score yet, then I set it to 0. When they beat it, the program goes to SaveRS. On some PC's this works fine, like on mine Windows ME. On some, like Windows 98 and XP, when they run the executable of my game, there is a path error. I don't know what to do different so I can save the record score without errors. How else can I do this?

    vbsslink

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    (Like in my other post) use App.Path instead of hardcoding it

    Ex:

    VB Code:
    1. Private Function BringinRS()
    2. On Error GoTo SetRS
    3. Open App.Path & "\Quad2RS.txt" For Input As #1
    4.     Input #1, RS
    5. Close #1
    6. Exit Function
    7.  
    8. SetRS:
    9. RS = 0
    10. Open App.Path & "\Quad2RS.txt" For Output As #1
    11.     Print #1, RS
    12. Close #1
    13. End Function
    14.  
    15. Private Function SaveRS()
    16. Open App.Path & "\Quad2RS.txt" For Output As #1
    17.     Print #1, S
    18. Close #1
    19. End Function
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Location
    Colorado
    Posts
    8

    record score

    Thanks jemidiah. The app.path works fine on my PC.

    vbsslink

  4. #4
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    Any time
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

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