Mariusz Zynel wrote:
I'm porting some software written in BP to GPC. How to simulate SetTextBuf which takes two or optionaly three arguments?
Grmpf. Another of these pseudo-overloaded BP routines... :-(
There is SetTextBuf in GPC System unit, but this takes two arguments.
Should I drop using the buffer size - third argument?
Possibilities are:
- Drop the buffer size, as you said.
- We add a 3rd parameter in the system unit (but then every program which uses only 2 parameters would "suffer").
- We make it dependent on an ifdef, like the type sizes etc., but I don't like this (and still programs that use both versions will have problems).
- Use the following dirty trick to ignore the 3rd (and any following) parameters. Note that macros are case-sensitive and don't work across units (so you have to put it in each program/unit that does this).
{$define SetTextBuf(a,b,c...) SetTextBuf(a,b)}
- Put two versions of the procedure under slightly different names in the unit. (I'll do this for now. SetTextBuf3 will be in the next release.)
- Build SetTextBuf into the compiler and use compiler magic. (I don't like this, either, because actually we want to reduce the number of magic routines in the compiler.)
- Implement procedure overloading in GPC. That's, of course, the right solution, but too much work for us to do right now (but if you'd like to volunteer to implement it in GPC... ;-).
Thanks in advance for any suggestion
I hope these were enough for today... ;-)
Frank