/ini and $ini functionality + source code change

A forum for the general posts relating to MacroQuest. *DEPRECATED: This forum is no longer in public use, but remains here for your reading pleasure. Enjoy

Moderator: MacroQuest Developers

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

Post by Valerian » Sun Jun 29, 2003 3:18 pm

ah, thanks for finding that, I'll work on it a bit more... shouldn't take much tweaking to fix it.

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

Post by Valerian » Sun Jun 29, 2003 3:42 pm

And here it is. DKAA, this supercedes the Get(next)Arg()'s I emailed to you... In fact, this is the only thing to change in EQLib_Utilities, don't even bother with those last 2 funcs I added in the bottom of the one I sent you (started making new funcs, then decided modifying old funcs would be better)

Code: Select all

// ***************************************************************************
// Function:    GetNextArg
// Description: Returns a pointer to the next argument
// ***************************************************************************
PCHAR GetNextArg(PCHAR szLine, DWORD dwNumber, BOOL CSV, CHAR Separator)
{
	PCHAR szNext = szLine;
	BOOL CustomSep = FALSE;
	BOOL InQuotes = FALSE;
	if (Separator!=0) CustomSep=TRUE;

	while (
		   ((!CustomSep) && (szNext[0] == ' '))
		|| ((!CustomSep) && (szNext[0] == '\t'))
		|| ((CustomSep) && (szNext[0]==Separator))
		|| ((!CustomSep) && (CSV) && (szNext[0]==','))
		) szNext++;
	if ((INT)dwNumber < 1) return szNext;
	for (dwNumber;dwNumber>0;dwNumber--) {
		while ((
			   ((CustomSep) || (szNext[0] != ' '))
			&& ((CustomSep) || (szNext[0] != '\t'))
			&& ((!CustomSep) || (szNext[0]!=Separator))
			&& ((CustomSep) || (!CSV) || (szNext[0]!=',')) 
			&& (szNext[0] != 0)
			) 
			|| (InQuotes)
			) {
			if ((szNext[0] == 0) && (InQuotes)) {
				DebugSpew("GetNextArg - No matching quote, returning empty string");
				return szNext;
			}
			if (szNext[0] == '"') InQuotes = !InQuotes;
			szNext++;
		}
		while (
			   ((!CustomSep) && (szNext[0] == ' '))
			|| ((!CustomSep) && (szNext[0] == '\t'))
			|| ((CustomSep) && (szNext[0]==Separator))
			|| ((!CustomSep) && (CSV) && (szNext[0]==','))
			) szNext++;
	}
	return szNext;
}

// ***************************************************************************
// Function:    GetArg
// Description: Returns a pointer to the current argument in szDest
// ***************************************************************************
PCHAR GetArg(PCHAR szDest, PCHAR szSrc, DWORD dwNumber, BOOL LeaveQuotes, BOOL ToParen, BOOL CSV, CHAR Separator)
{
	DWORD i=0;
	DWORD j=0;
	BOOL CustomSep = FALSE;
	BOOL InQuotes = FALSE;
	PCHAR szTemp = szSrc;
	ZeroMemory(szDest,MAX_STRING);
	if (Separator!=0) CustomSep=TRUE;

	szTemp = GetNextArg(szTemp,dwNumber-1, CSV, Separator);

	while ((
		   ((CustomSep) || (szTemp[i] != ' '))
		&& ((CustomSep) || (szTemp[i] != '\t'))
		&& ((CustomSep) || (!CSV) || (szTemp[i]!=',')) 
		&& ((!CustomSep) || (szTemp[i]!=Separator))
		&& (szTemp[i] != 0) 
		&& ((!ToParen) || (szTemp[i] !=')'))
		) 
		|| (InQuotes)
		) {
		if ((szTemp[i] == 0) && (InQuotes)) {
			DebugSpew("GetArg - No matching quote, returning entire string");
			DebugSpew("Source = %s",szSrc);
			DebugSpew("Dest = %s",szDest);
			return szDest;
		}
		if (szTemp[i] == '"') {
			InQuotes = !InQuotes;
			if (LeaveQuotes) {
				szDest[j] = szTemp[i];
				j++;
			}
		} else {
			szDest[j] = szTemp[i];
			j++;
		}
		i++;
	}
	if ((ToParen) && (szTemp[i]==')')) szDest[j]=')';
	//DebugSpew("GetArg - Arg%d from '%s' = '%s'",dwNumber,szTemp,szDest);

	return szDest;
}

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

Post by Jalapeno » Sun Jun 29, 2003 4:03 pm

Impressive. These are some great additions to MQ. I'd like to thank you again for taking interest in this and giving us a hand.

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

Post by BlueSkies » Sun Jun 29, 2003 4:58 pm

Oh most definately, thanks :)

Val -- excellent work with the GetArg function. :) Works great :)
Live your dreams! Blue Skies everyone

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Sun Jun 29, 2003 7:30 pm

I took the chat out of the IniOuput() routine but other than that, it's in CVS.

Download zip file updated as well.

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

Post by BlueSkies » Sun Jun 29, 2003 8:51 pm

Thanks a bunch, DKAA. :)
Live your dreams! Blue Skies everyone

AarynD
a lesser mummy
a lesser mummy
Posts: 45
Joined: Thu Jan 02, 2003 11:25 am

Post by AarynD » Wed Jul 16, 2003 3:06 pm

Will the write function actually create a new SECTION in the INI file if the section doesn't already exist?

- Aaryn

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

Post by BlueSkies » Wed Jul 16, 2003 6:43 pm

Yes, in fact it'll also create the entire INI file for you if it doesn't exist where specified.
Live your dreams! Blue Skies everyone

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Post by cww256 » Thu Jul 17, 2003 12:24 am

I thought this was in CVS?!?! But obivously my version does not have it. Any eta on a CVS for this?

BTW my last clean CVS was 7-11-03

:?

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Thu Jul 17, 2003 2:11 am

It was in then disabled now it's fixed.

Pick up the zip on the downloads page.

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Post by cww256 » Thu Jul 17, 2003 5:20 am

Downloads page zip > CVS?

Wishbringer
Contributing Member
Contributing Member
Posts: 230
Joined: Thu Nov 14, 2002 7:00 am

Post by Wishbringer » Thu Jul 17, 2003 7:04 am

Sourceforge CVS currently on a 24h backup-server.
means: devs can access changes instantly through ssl, all other anonymous :pserver:logins have to wait 24h till changes are available.
So nowadays Source-zips are more up-to-date than CVS.

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

Post by Valerian » Thu Jul 17, 2003 8:43 am

ahh... back in? does that mean my modified $arg is in there too, or did you forget that? I know GetArg() and GetNextArg() in there support my modified $arg(), but my $arg() wasn't in the CVS when I checked last...

(completely replaces the $arg(num,string) section)

Code: Select all

					// $arg(num,string[,<separator>])
					} else if (!strncmp("arg(",szVar,4)) {
						if ((!strstr(szVar,")")) || (!strstr(szVar,","))) {
							DebugSpew("PMP - Bad $arg() '%s'",szVar);
							i--;
							szOutput[j] = '@';
							j++;
						} else {
							CHAR szArg[MAX_STRING] = {0};
							CHAR szTemp[MAX_STRING] = {0};
							DWORD num = 0;

							GetArg(szArg,szVar,2,FALSE,FALSE,TRUE);
							if (szArg[strlen(szArg)-1]==')') {
								szArg[strlen(szArg)-1]=0;
							} else {
								GetArg(szTemp,szVar,3,FALSE,FALSE,TRUE);
								szTemp[1]=0;
							}
							i += (strstr(szVar,")")-szVar);
							num = atoi(szVar+4);
							//DebugSpew("$arg: Number: %d, String: '%s', Separator: '%s'",num,szArg,szTemp);
							GetArg(szTemp,szArg,num,FALSE,FALSE,FALSE,szTemp[0]);
							strcat(szOutput,szTemp);
							j+=strlen(szTemp);
						}

					// $left(num,string)

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Tue Aug 26, 2003 11:59 pm

Quick question..
Is it possible to remove a single key from an ini file with the /ini function?
If not, would it be possible to add?

ps. should really get all these awesome new features documented, I didn't even know that $arg was changed to possible hold another delimiter than space :)

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

Post by Valerian » Wed Aug 27, 2003 12:31 am

aye... I'm trying to include a bit of documentation in the CHANGES.txt file when I update CVS... hopefully the other devs will do the same

about removing a single key? not sure... I don't think it'll do that as written, and I'd have to look at the *PrivateProfileString() funcs to figure out how to remove a key before implimenting it...