Hello

I want in my little tool using "personalised variable" for formatting text.

i.e I have a First Name and Last Name and i want to write it into a text file, but the user can chose all the sentence in the file, thus I want to have %F for first name and %L for last name

To make the sentence the user do :" Hello my name is %F %L" or "First Name %F and Last Name %L"

How can i create %F and %L (and other one) and implement it in my tool?

Thanks in advance
Posted on 2007-10-19 09:32:50 by Bros
If the template is in code then just search for keywords "%F, %L, etc" and replace with value. This can easily be done with wsprintf: replace keyword character with "s", so "First Name %F" becomes "First Name %s" and make note of value type. All that is needed now is to push the values and the modified string (I assume in a loop) to wsprintf.

- search for '%', scasb instruction.
- lookup following byte in table
- store value in array for wsprintf
- replace character with 's'
- push modified string
- load each array value
- - lookup in database
- - push string
- wsprintf

I have assumed there is a database of firstnames, etc.

About 20 years ago I wrote a very similar program in Lisp - remember MadLibs - it was a computerized version. It is also like mail merge within wordprocessor.
Posted on 2007-10-19 11:37:33 by bitRAKE