On 14/08/2012 13:19, Rainer Stratmann wrote:
It was more or less exactly the way I did it before with little exaggerating
as you notice :-)
Even now I save 50% codesize in comparison to resourcestring.
If you don't like resource string, inho there are 2 alternatives that
are (IMHO) better:
1)
plain array with all text constants. You can break it into one array per
unit, and have a register a search-handler via the unit's initialization.
const MySnippets: Array [1..xxx] of string = ('text', '...', ... ];
For more readability (but it adds source code (should not add more to exe)
const
snip1: 'text';
MySnippets: Array [1..xxx] of string = (snip1, '...', ... ];
(actually, I havent testet if the compiler takes the 2nd
2)
Since you seem to want something that is easier to type.
Keep using
writeln(ls('text'));
Instead of analysing the exe, write your own pre-precessor.
The pre-processor can scan the source, create a temporary copy in which
it replaces the text in ls() with a reference to the "MySnippets[]" array.
It also creates and includes a unit with that array.
It then calls the compiler on the temporary created sources....
At least it will keep working even if fpc internals change. And it is
cross platform (includes cross-CPU)
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal