Valhalla Legends Forums Archive | Battle.net Bot Development | I need help creating Access for my bot

AuthorMessageTime
Almighty
I wanna make access load and read from Access.ini or Users.txt file but i really dont know where to start jus need a lil a help
December 29, 2005, 6:46 AM
JoeTheOdd
I'm not totally evil, so here, I'll give you a place to start.

Kernel32.dll:
[code]
GetPrivateProfileStringA {
    LPCSTR lpApplicationName,
    LPCSTR lpKeyName,
    LPCSTR lpDefault,
    LPCSTR lpReturnedString,
    int nSize,
    LPCSTR lpFileName
};
int WritePrivateProfileStringA {
    LPCSTR lpApplicationName,
    LPCSTR lpKeyName,
    LPCSTR lpString,
    LPCSTR lpFileName
};[/code]
December 29, 2005, 3:58 PM
Ryan Marcus
Uh.. either I'm dumb or your code makes no sence for writting and reading files...


Here is some REALbasic code that simply writes out a text file and looping through an array of users, pretty basic stuff.. You should have learned this before you came close to being able to write a bot.. You should be able to adapt it to VB easily.

[code]
dim textout as textoutputstream
dim f as folderitem
dim i as integer

f = GetFolderItem("users.txt")
textout = f.CreateTextFile

while i<>UBound(users) + 1
textout.writeline(users(i).someprop)
textout.writeline(users(i).someprop)
textout.writeline(users(i).someprop)
i =i + 1
wend
[/code]

Hope that helps.
January 1, 2006, 3:46 AM
Myndfyr
[quote author=Ryan Marcus link=topic=13691.msg139989#msg139989 date=1136087175]
Uh.. either I'm dumb or your code makes no sence for writting and reading files...
[/quote]

The information that Joe provided are exports from Windows' kernel32.dll (and kernel32.lib) for reading and writing .ini files.
January 1, 2006, 10:43 AM
JoeTheOdd
It may be worth noting that Visual Basic has no TextOutputStream. Asuming you were going to do it Ryan's way, which I don't recomment (the Kernel32 calls are more efficient, and easier), then you'd use the following code:

[code]Dim FileHandle&: FileHandle = #FreeFile
Open App.Path & "\config.ini" For Append as FileHandle '// Note: You may want to change config.ini to whatever setting file you're using.
  Print #1, "SettingName=SettingValue"
Close FileHandle[/code]

EDIT -
If for some reason you wanted to write UTF-8 widestrings, define the DLL calls as GetPrivateProfileStringW and WritePrivateProfileStringW.
January 1, 2006, 11:36 AM
Myndfyr
[quote author=Joe link=topic=13691.msg140002#msg140002 date=1136115384]
It may be worth noting that Visual Basic has no TextOutputStream. Asuming you were going to do it Ryan's way, which I don't recomment (the Kernel32 calls are more efficient, and easier), then you'd use the following code:

[code]Dim FileHandle&: FileHandle = #FreeFile
Open App.Path & "\config.ini" For Append as FileHandle '// Note: You may want to change config.ini to whatever setting file you're using.
   Print #1, "SettingName=SettingValue"
Close FileHandle[/code]

EDIT -
If for some reason you wanted to write UTF-8 widestrings, define the DLL calls as GetPrivateProfileStringW and WritePrivateProfileStringW.
[/quote]

Why are you posting rather pointless nonsense trying to criticize Ryan?  The original poster never said ANYTHING about what he's writing in.  For all you know he might be in RB; he certainly never said he was using VB.

Of course, the quality of the original post made everyone ASSUME it was a VB luser, but that's another debate.
January 1, 2006, 11:49 AM
Quarantine
haha @ luser.
January 1, 2006, 12:41 PM
Ryan Marcus
[quote]
Why are you posting rather pointless nonsense trying to criticize Ryan?  The original poster never said ANYTHING about what he's writing in.  For all you know he might be in RB; he certainly never said he was using VB.
[/quote]
Its cool. I know Joe pretty well from x86. I don't think he met any offense, but he could have worded that a bit better.

[quote]
Of course, the quality of the original post made everyone ASSUME it was a VB luser, but that's another debate.
[/quote]

I would'nt even call it a debate... If somebody can write a bot before they can write out to a file and read one in, they are using CSB (and thus have no idea what they are doing), or they are some crazy raised from birth by evil anti-blizzard nazi's who want to conquer all of battle.net with an ultimate flood bot... The later does not seem too promising, but it sounds cooler. ;)


I posted the RB because I assumed it could be easily converted to VB. Apartly, thats something that can't.
January 1, 2006, 4:32 PM
FrOzeN
[quote author=Joe link=topic=13691.msg140002#msg140002 date=1136115384]
It may be worth noting that Visual Basic has no TextOutputStream.
[/quote]
It may be worth noting that Ryan said that was for REALbasic.

In Visual Basic 6 his code would look like:
[code]Dim oFSO As New Scripting.FileSystemObject
Dim oFile As Scripting.File
Dim i As Integer

Set oFile = oFSO.OpenTextFile(App.Path & "\users.txt", ForWriting, True)

While i <> UBound(users) + 1
    oFile.WriteLine users(i).someprop
    oFile.WriteLine users(i).someprop
    oFile.WriteLine users(i).someprop
    i = i + 1
Wend

Set oFile = Nothing[/code]
January 3, 2006, 9:03 AM

Search