[fpc-pascal] Interactive command recognition & mapping to program functions & other 'cli' features as a unit

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Fri Jul 31 15:46:24 CEST 2015

Lukasz Sokol wrote:
> Hi,
> I tried piecing something like in $topic together,
> intended as an 'interactive' command interpreter for my program.
> (which will in time grow an 'embedded' web server and intended to run as a (windows) service,
> but it's too early for that at the moment)
> (I hooked some events of a TMemo to my interpreter, 
> which currently recognizes commands by a static map/array of record of string and function pointers;
> and passes the rest of command line to the called function as string, 
> then the function is a shim/wrapper over the deeper program functions; 
> the entire parameter sanitizing  and conversion from string to what the 'deeper' function expects,
> is done in the 'wrapper' function layer,
> and so is the function output converted back to string and spat out to the TMemo.
> It's growing too complicated to maintain for the purpose, day by day, and has problems
> with some more interactive commands or tab completion...
> Is there something I could use for the purpose that is ready-made, tested, free and open source AND of course in FreePascal ?
> (I can share my changes back if I do any, can't open the entire application though)
> Any hints, 
> Any keywords,
> any lmgtfy's
> are welcome :)

This might be better in the Lazarus mailing list.

I've knocked together a special-purpose terminal emulator, it's actually 
an IBM 2741 terminal which uses totally non-standard codes internally 
and I wanted something for APL, early ALGOL implementations and so on. 
This is obviously character-by-character, and I was just about able to 
get something working for TMemo, TRichMemo and TListBox. Somebody else 
mentioned TCmdBox (?) but I wasn't able to get it working adequately and 
in the end discarded most of my attempts, it might be worth looking at 
if you're trying to process lines rather than characters.

I think this was discussed a few months ago, and consensus was that 
there wasn't an adequate terminal emulator component. See below.


Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list