Page 2 of 2

Posted: Sun Jun 29, 2003 3:18 pm
by Valerian
ah, thanks for finding that, I'll work on it a bit more... shouldn't take much tweaking to fix it.

Posted: Sun Jun 29, 2003 3:42 pm
by Valerian
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;
}

Posted: Sun Jun 29, 2003 4:03 pm
by Jalapeno
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.

Posted: Sun Jun 29, 2003 4:58 pm
by BlueSkies
Oh most definately, thanks :)

Val -- excellent work with the GetArg function. :) Works great :)

Posted: Sun Jun 29, 2003 7:30 pm
by dont_know_at_all
I took the chat out of the IniOuput() routine but other than that, it's in CVS.

Download zip file updated as well.

Posted: Sun Jun 29, 2003 8:51 pm
by BlueSkies
Thanks a bunch, DKAA. :)

Posted: Wed Jul 16, 2003 3:06 pm
by AarynD
Will the write function actually create a new SECTION in the INI file if the section doesn't already exist?

- Aaryn

Posted: Wed Jul 16, 2003 6:43 pm
by BlueSkies
Yes, in fact it'll also create the entire INI file for you if it doesn't exist where specified.

Posted: Thu Jul 17, 2003 12:24 am
by cww256
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

:?

Posted: Thu Jul 17, 2003 2:11 am
by dont_know_at_all
It was in then disabled now it's fixed.

Pick up the zip on the downloads page.

Posted: Thu Jul 17, 2003 5:20 am
by cww256
Downloads page zip > CVS?

Posted: Thu Jul 17, 2003 7:04 am
by Wishbringer
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.

Posted: Thu Jul 17, 2003 8:43 am
by Valerian
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)

Posted: Tue Aug 26, 2003 11:59 pm
by kagonis
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 :)

Posted: Wed Aug 27, 2003 12:31 am
by Valerian
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...