Results 1 to 7 of 7

Thread: Reading other files (ini, txt)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82

    Arrow Reading other files (ini, txt)

    I am making a game that needs to read a long list of coordinates from another file for my collision detector, but I don't know how to do that. I saw someone do something similar using

    Open App.Path + Filename For Input As #1

    but I don't know how to use it. Any help would be welcome.
    Last edited by Killerguppy101; Feb 14th, 2002 at 03:04 PM.

  2. #2
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    if the number of coordinates remains constant the easiest way would be to use a binary file and use put and get directly into an array.
    Sanity is a full time job

    Puh das war harter Stoff!

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    To read from an InI file
    VB Code:
    1. Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    2. Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    3. Private Sub Form_Load()
    4.     'KPD-Team 1999
    5.     'URL: [url]http://www.allapi.net/[/url]
    6.     'E-Mail: [email][email protected][/email]
    7.     Dim Ret As String, NC As Long
    8.     'Write the setting to the file (c:\test.ini) under
    9.     '   Project1 -> Keyname
    10.     WritePrivateProfileString App.Title, "KeyName", "This is the value", "c:\test.ini"
    11.     'Create a buffer
    12.     Ret = String(255, 0)
    13.     'Retrieve the string
    14.     NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
    15.     'NC is the number of characters copied to the buffer
    16.     If NC <> 0 Then Ret = Left$(Ret, NC)
    17.     'Show our string
    18.     MsgBox Ret
    19. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    I already have something like this that I use. I was wondering how I coudl use something simple, easy, and without knowing how many coordinates would be entered. (So that the user might make a map of his own)

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    you could still do that
    just save a long/integer specifying the number of coordinates stored and than dimension an array with that lenght and load it.
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    Thnx. But do you know what the "Open filename for input as #1" means and how i could use it?

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Using "Open filename for input as #1" is VB 101.

    If you have VB installed, look at the help file.

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