So it seems like my program is a memory hog. It keeps eating, and eating..... How can I make it stop? I don't see a reason for it in my code, but I might be missing something.
Thanks in advance.
namespace Test
{
/// <summary>
/// Description of GetSystemVariablescs.
/// </summary>
public class GetSystemVariablescs
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedUsrBrk")]
private static extern int acedUsrBrk();
private string UpStringLetters (string Str, int Location) {
if (Location.Equals(0))
return "A" + Str;
else if (string.Compare("Z", Str.Substring(Location - 1, 1)).Equals(0))
return UpStringLetters (Str.Substring(0, Location - 1) + "A" + Str.Substring(Location), (Location - 1));
else if (Str.Length.Equals(1)) {
char tempChar = Str[0];
tempChar = ++tempChar;
return Convert.ToString(tempChar);
}
else {
char tempChar = Str[Location - 1];
tempChar = ++tempChar;
return Str.Substring(0, Location - 1) + Convert.ToString(tempChar) + Str.Substring(Location);
}
}
[CommandMethod("PrintVariables")]
public void Main () {
PromptResult pr = AcadApp.DocumentManager.MdiActiveDocument.Editor.GetString("\n Enter value to start at: ");
string TestString = pr.StringResult;
if (string.Compare(TestString, string.Empty).Equals(0))
return;
TestString = TestString.ToUpper();
object VarValue;
using (StreamWriter sw = new StreamWriter("C:/MyCustom/VariableList-CSharp.txt", true)) {
while (acedUsrBrk().Equals(0)) {
try {
VarValue = AcadApp.GetSystemVariable(TestString);
if (VarValue != null) {
sw.WriteLine(TestString + "," + VarValue.ToString());
sw.Flush();
}
}
catch {}
try {
VarValue = AcadApp.GetSystemVariable("_" + TestString);
if (VarValue != null) {
sw.WriteLine("_" + TestString + "," + VarValue.ToString());
sw.Flush();
}
}
catch {}
TestString = UpStringLetters (TestString, TestString.Length);
}
sw.WriteLine("** Canceled at [ " + TestString + " ]");
}
//AcadApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage(TestString);
}
}
}