I was working on one of my projects and doing some tedious output to the 
console and now that I have this idea in my head that this could be more 
automated, I thought that this task should be automated as well.. not sure if 
it's something that belongs in Graeme's Help Output package, but it's on a 
similar idea.

It seems that I always want to do a writeln of a variable to see that it's 
doing what I expect..
So sometimes I just stink in a writeln like this:
Writeln(ThingA); 

If I want more than one thing, I can just do:
Writeln(ThingA,ThingB);

But of course you can't always tell where ThingA stops and ThingB Starts,  so I 
have to at least put in a space:
Writeln(ThingA,' ',ThingB);

But then I sometimes have such a long list of these, I need to say what they 
are:
Writeln('ThingA: ',ThingA,' ThingB: ',ThingB);

And if the variables are some kind of floating point, I need to do something so 
I don't have to look at un-readable expanded notation... Which I absolutely 
ALWAYS forget until I run it once.. so I have to go back and put in my standard 
floating point formatting:
Writeln('ThingA: ',ThingA:0:20,' ThingB: ',ThingB:0:20);

And sometimes I want to make it a different color so I can spot it in a huge 
list of output so I will do something like:
Textcolor(14);
Write('ThingA: ');
Textcolor(10);
Write(ThingA:0:20);
Textcolor(14);
Write('ThingB: ');
Textcolor(10);
Writeln(ThingB:0:20);

Then when I'm doing I comment it all out so if I want it again someday, I don't 
have to type it all:
//Textcolor(14);
//Write('ThingA: ');
//Textcolor(10);
//Write(ThingA:0:20);
//Textcolor(14);
//Write('ThingB: ');
//Textcolor(10);
//Writeln(ThingB:0:20);

So What I would like is a procedure that simplifies all this... but I don't 
know how to implement it.  There are several things I don't have a clue how to 
do,  or if they are even possible.

First of all, can I make a procedure with maybe something like a dynamic array 
of variables of any random types??  So it works like Writeln... With Writeln I 
can mix variable types and have as many as I want.
Next.. can I have it output the name of the variable and it's contents somehow?

I would like to end up with a procedure that does all the formatting, so if I 
give it:
ShowMyVariables(Control,ThingA,ThingB); 

I get something like
If Control Then
   Begin
      Textcolor(14);
      Write('ThingA: ');
      Textcolor(10);
      Write(ThingA:0:20);
      Textcolor(14);
      Write('ThingB: ');
      Textcolor(10);
      Writeln(ThingB:0:20);
  End;

I would need to somehow figure out the variable type to see if it's floating 
point.

Any Ideas on how this, or some of it could be accomplished?  Or is it all 
completely impossible?

James


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to