Two informations: 1. All caller adresses of a function (lets say rs( s : pchar ) : shortstring ) 2. All pchar pointers to the test snippets
That was all I need. Your solution sounds not practical to me. (scan the code with another tool, modify the source code or what do you mean? I don't want to have boast of tools for a simple solution). I never talked about that my solution should be portable. That was interjected here in this thread. If you followed the discussion then I first asked for a (portable) solution. I asked if the compiler can provide the 2 informations above. But that was not possible. So I looked for an own solution. Of course I am proud to find a solution and make some kind of marketing here. You call it "boast about programming skills". You try now to make a bad atmosphere out of it. Am Tuesday 14 August 2012 23:43:23 schrieb Jorge Aldo G. de F. Junior: > Why not scan the code with passrc, find the strings, build a table and > then replace the strings with calls to a function that does the > translation ? > > your hack sounds like a maintenance nightmare... Thats what a C > programmer would do and then boast about his programming skills, just > to later discovar that his solution is nor portable nor safe... > > 2012/8/14 Rainer Stratmann <rainerstratm...@t-online.de>: > > Am Tuesday 14 August 2012 14:36:44 schrieb Martin: > >> 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 > > > > Then you have to put _all_ text snippets at once there (!) > > I didn't count my text snippets in this project, but they are spread over > > about more than 10 units. > > > >> 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. > > > > I considered this, but the solution now is - in my view - unbeatably > > easy. And that is what counts for me. > > > >> 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. > > > > I do not worry about this. The search procedure can easily adapted then. > > > >> And it is cross platform (includes cross-CPU) > > > > Yes, that's true. But I am confident to find here also a solution once it > > will be necessary. > > _______________________________________________ > > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal