I use this macro to add the number of arguments to a String.Format, Console.WriteLine, etc in c#:
_command brief_AddFormatArguments() name_info(','VSARG2_REQUIRES_EDITORCTL)
{
// Ctrl+S
typeless orig_position;
int iI;
int iPos;
int iLen;
int iParms = 0;
boolean fTrue = true;
boolean fSingleLine = false;
_str strMethod;
_str strParms;
_str strLine;
_str strText;
_save_pos2(orig_position);
get_line(strMethod);
iPos = lastpos(");", strMethod);
if (iPos > 0)
{
fSingleLine = true;
strLine = strMethod;
}
iPos = lastpos("(", strMethod);
if (iPos > 0)
{
strMethod = substr(strMethod, 1, iPos);
}
else
{
iPos = pos("\"", strMethod);
if (iPos > 0)
{
strMethod = substr(strMethod, 1, (iPos - 1));
}
}
if (fSingleLine == false)
{
while (fTrue)
{
down();
get_line(strText);
if (last_char(strText) == ";")
{
iParms++;
break;
}
else
{
iParms++;
}
}
}
else
{
iLen = length(strLine);
iPos = pos("\",", strLine);
if (iPos > 0)
{
strParms = substr(strLine, iPos, (iLen - iPos));
STRARRAY strParams = split2array(strParms, ",");
iParms = (strParams._length() - 1);
}
else
{
_restore_pos2(orig_position);
return (0);
}
}
_restore_pos2(orig_position);
if (iParms > 0)
{
strMethod = strMethod:+"\"";
_str strRet = _message_box("Yes = Use a space\r\nCancel = Use a comma\r\nNo = No separation.",
"What do you want to use as a separator?",
MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON1);
for (iI = 0; iI < iParms; iI++)
{
if (strRet == IDYES)
{
if (iI < (iParms - 1))
{
strText = "{":+iI:+"} ";
}
else
{
strText = "{":+iI:+"}";
}
}
else if (strRet == IDNO)
{
strText = "{":+iI:+"}";
}
else // IDCANCEL
{
strText = "{":+iI:+"},";
}
strMethod = strMethod:+strText;
}
if (fSingleLine == true)
{
strMethod = strMethod :+ strParms :+ ";";
}
else
{
strMethod = strMethod:+"\",";
}
replace_line(strMethod);
}
return (0);
}