11.01.2014, 14:25
Nice, that method does gives me an idea though.
---
Here's a function I've written for my mode.
INI_WriteData
Allows you to write arguments into an INI file - y_ini only.
Example:
And the output:
---
Here's a function I've written for my mode.
INI_WriteData
Allows you to write arguments into an INI file - y_ini only.
pawn Код:
stock INI_WriteData(INI:file, const fmat[], {Float,_}:...)
{
static
i,
ch,
idx,
str[32],
string[YSI_MAX_STRING];
if (((numargs() - 2) / 2) != strlen(fmat))
return printf("** Warning: %d specifiers, but only %d arguments.", strlen(fmat), (numargs() - 2) / 2);
while ((ch = fmat[i++]))
{
if (!('z' >= ch >= 'a'))
continue;
va_getstring(str, (idx = ((i - 1) << 1) + 2));
switch (ch)
{
case 'd', 'i':
INI_WriteInt(file, str, getarg(idx + 1));
case 'f':
INI_WriteFloat(file, str, Float:getarg(idx + 1));
case 'h':
INI_WriteHex(file, str, getarg(idx + 1));
case 's':
INI_WriteString(file, str, (va_getstring(string, idx + 1), string));
default:
printf("** Warning: Invalid specifier '%c'.", ch);
}
}
return 1;
}
pawn Код:
new
INI:file = INI_Open("file.ini");
INI_WriteData(file, "sdf",
"String", "My name is Emmet.",
"Integer", 50,
"Float", 73.8
);
INI_Close(file);
Код:
Float = 73.800003 Integer = 50 String = My name is Emmet.