|
-
Feb 14th, 2002, 02:56 PM
#1
Thread Starter
Lively Member
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.
-
Feb 14th, 2002, 06:38 PM
#2
Frenzied Member
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!
-
Feb 15th, 2002, 10:38 AM
#3
To read from an InI file
VB Code:
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
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
Private Sub Form_Load()
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
Dim Ret As String, NC As Long
'Write the setting to the file (c:\test.ini) under
' Project1 -> Keyname
WritePrivateProfileString App.Title, "KeyName", "This is the value", "c:\test.ini"
'Create a buffer
Ret = String(255, 0)
'Retrieve the string
NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
'NC is the number of characters copied to the buffer
If NC <> 0 Then Ret = Left$(Ret, NC)
'Show our string
MsgBox Ret
End Sub
-
Feb 15th, 2002, 02:52 PM
#4
Thread Starter
Lively Member
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)
-
Feb 16th, 2002, 07:53 AM
#5
Frenzied Member
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!
-
Feb 17th, 2002, 01:35 PM
#6
Thread Starter
Lively Member
Thnx. But do you know what the "Open filename for input as #1" means and how i could use it?
-
Feb 17th, 2002, 02:08 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|