Gale Paeper wrote:
Frank Heckenbach wrote:
(*) Just a thought. Perhaps the syntax could be handled with more-advanced preprocessor features, in particular string handling. Something like:
{$define Scan(A, B, C) {$if MacroIsPrefix (<>, MacroTrim (B))} ScanNE (A, MacroRemovePrefix (<>, MacroTrim (B)), C) {$else} ScanEQ (A, MacroRemovePrefix (=, MacroTrim (B)), C) {$endif} }
How about:
{$define Scan(A, B, C) repeat var ScanExpression : string(4) value (#B); if (Length(ScanExpression) = 4) and_then (index(ScanExpression, '<>') = 1) then ScanNE((A),ScanExpression[4],(C)) else if (Length(ScanExpression) = 3) and_then (index(ScanExpression, '=') = 1) then ScanEQ((A),ScanExpression[3],(C)) else ParameterError; until true; }
Note: The above assumes the preprocessor treats #B like the C preprocessor does (i.e., string quotes the macro parameter) and that PEXPR parameter is required to be in the exact form that Adriaan cited
without quotes for CH. If the CH part is a quoted char constant, some adjustments are needed to take into accout the embedded quote characters. If the CH part can be any expression of char type, forget it - I don't think a macro hack is possible for that.
The CH part can be an expression and it is quoted for char constants. I think it is (much) better to replace Scan by ScanEQ and ScanNE in the source code. What would be helpful, of course, is a chapter in the manual "Porting from ..." as has already been done for Borland Pascal and partly for CodeWarrior/Think/MPW Pascal (see <www.microbizz.nl/gpcdiffs.html>).
Regards,
Adriaan van Os