File I/O IMPLEMENTED

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

User avatar
BlueSkies
a ghoul
a ghoul
Posts: 132
Joined: Tue Oct 01, 2002 6:22 pm

File I/O IMPLEMENTED

Post by BlueSkies » Sat Jun 28, 2003 5:36 am

Well, sorta. ;)

Jalapeno and I have implemented File I/O using INI files. We have a $ini function and a /ini command. We've tested them, and everything works 100%.

We're currently updating our pathing script to use this feature, so that people won't have to download and run a VB app (or any other language :P) to parse the log file output. It'll simply save the data to an INI file while recording, and read from the INI while walking.

We'll be releasing the source changes (I'll probably just post them in here somewhere), and we'll post our updated path walking scripts.
Live your dreams! Blue Skies everyone

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Sat Jun 28, 2003 9:26 am

told ya ini file support would be really easy, aren't all those API functions for it easy to work with? *grin*

User avatar
BlueSkies
a ghoul
a ghoul
Posts: 132
Joined: Tue Oct 01, 2002 6:22 pm

Post by BlueSkies » Sat Jun 28, 2003 1:58 pm

Damn right. :) It's awesome :D

We're still having some minor problems with it. GetPrivateProfileString is supposed to return a null-delimited string containing either section names or key names, if either of those paramaters is null. Well, I'm having a hard time getting the code to recognize when the user wants to specify a null value.

Here's the syntax of our command:
$int(<filename>,<section>,<key>)

And here's the section of our MacroParser entry that checks to see if the second or third argument is null:

Code: Select all

if (szArg3=="null") {
    DebugSpew("INI -- Arg3 was null.");
	num=GetPrivateProfileString(szArg2,NULL,"NOTFOUND",szTemp,MAX_STRING,szArg1);
} else if (szArg2=="null") {
	DebugSpew("INI -- Arg2 was null.");
	num=GetPrivateProfileString(NULL,NULL,"NOTFOUND",szTemp,MAX_STRING,szArg1);
} else {
	num=GetPrivateProfileString(szArg2,szArg3,"NOTFOUND",szTemp,MAX_STRING,szArg1);
}
So, in theory, when I supply:
$int("thefile.ini","thesection","null")
I should see in the debugspew file: "INI -- Arg3 was null."
And I should get a return value of all the key names in "thefile.ini".
But I don't. And it returns 'NOTFOUND' -- which is what I specify as the default return when a section or key isn't in the INI file.

So... ???

If we can't get this working, then we won't be able to do things like messing with the Bazaar INI file, because we need to be able to return the list of keys. Oh -- that's another thing: how would the szOutput string deal with null characters? Will I need to replace the null delimiter with something else; a pipe character maybe?

I'd appreciate any help anyone can supply with this. Would LOVE to get this set up to manipulate the Bazaar file.
Live your dreams! Blue Skies everyone

User avatar
BlueSkies
a ghoul
a ghoul
Posts: 132
Joined: Tue Oct 01, 2002 6:22 pm

Post by BlueSkies » Sat Jun 28, 2003 4:56 pm

It just occurred to me...

With INI support being so easy to implement (a couple of VB programmers with minimal C++ experience could do it), why hasn't it been done already? It took up the better part of 4 hours to do, and we only have one unresolved bug that I'm sure is something that came about only because of our lack of C++ experience. 4 hours for two complete newbies...
Live your dreams! Blue Skies everyone

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sat Jun 28, 2003 5:15 pm

Not trying to be a smart a%%, but probably because no one needs(ed) it?

There is alot in MQ I don't use as it is. I mainly use it for tradeskilling to save the multiple clicks.

User avatar
BlueSkies
a ghoul
a ghoul
Posts: 132
Joined: Tue Oct 01, 2002 6:22 pm

Post by BlueSkies » Sat Jun 28, 2003 5:56 pm

According to the poll I posted, 66% of people feel like they need / could use File I/O. That's a pretty big no one.

You're free to express your opinion. :)

Right now, however, I need C++ help. So, do you know C++?
Live your dreams! Blue Skies everyone

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sat Jun 28, 2003 8:16 pm

69% of 13 people.

I'm fairly certain there are more than 13 people using MQ.

/shrug...

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Sat Jun 28, 2003 9:04 pm

not bothering to test this code to see if it works, but try something similar to this instead...

Code: Select all

if ([b]stricmp(szArg3,"null")[/b]) { 
    DebugSpew("INI -- Arg3 was null."); 
   num=GetPrivateProfileString(szArg2,NULL,"NOTFOUND",szTemp,MAX_STRING,szArg1); 
} else if ([b]stricmp(szArg2,"null")[/b]) { 
   DebugSpew("INI -- Arg2 was null."); 
   num=GetPrivateProfileString(NULL,NULL,"NOTFOUND",szTemp,MAX_STRING,szArg1); 
} else { 
   num=GetPrivateProfileString(szArg2,szArg3,"NOTFOUND",szTemp,MAX_STRING,szArg1); 
}
not sure if that's correct, they may need to be if (!stricmp())... *shrug* points you in the right direction though Mister VB Programmer... string manipulation in C++ is a lot different than in Basic :lol:

Jalapeno
orc pawn
orc pawn
Posts: 15
Joined: Sat Jun 28, 2003 9:29 pm
Location: Charleston, SC

Post by Jalapeno » Sat Jun 28, 2003 9:42 pm

BlueSkies wrote:It just occurred to me...

With INI support being so easy to implement (a couple of VB programmers with minimal C++ experience could do it), why hasn't it been done already? It took up the better part of 4 hours to do, and we only have one unresolved bug that I'm sure is something that came about only because of our lack of C++ experience. 4 hours for two complete newbies...
Well I must say we weren't done programming yet =p You are right it was because of our total lack of C++ experience. And to clarify your last sentence BlueSkies: "two complete C++ newbies" =) Just so no one gets that mixed up with programming newbies.


Anyway. I looked over our code a bit and came up with a solution to our problem. Will be reviewing and finalizing everything with BlueSkies later this evening then we'll probably be releasing this. Thanks for the input Valerian that would most likely work also, although that was just half our problem.