Re: [fpc-pascal] I'm working on automated Help Output for console apps

2020-11-23 Thread James Richters via fpc-pascal
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


Re: [fpc-pascal] I'm working on automated Help Output for console apps

2020-11-23 Thread Graeme Geldenhuys via fpc-pascal
On 23/11/2020 1:26 pm, James Richters via fpc-pascal wrote:
> Any Ideas on how this, or some of it could be accomplished?  Or is it all 
> completely impossible?

If the object that you are trying to output has RTTI enabled, then maybe
you could query everything you need via TypeInfo (or the new reflection
or New RTTI of FPC and Delhi - can't remember the exact name).

Maybe looking at tiOPF's tiLog unit could also give some ideas on how
to write those - but the tiLog unit definitely doesn't do exactly what you want.
Saying that I very often used tiOPF's tiLog support (threaded output to console,
file or external window) even in not tiOPF projecst, simply because it was
so convenient. Coming back to the first point, tiOPF's tiRTTI unit might also be
of use to you.

https://github.com/graemeg/tiopf/blob/tiopf2/Core/tiLog.pas

Either way, seem there will be some work required to get what you want. ;-)

Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal