{ Check type of parameters }
if (Arg1^._Type <> T_ARG_INTEGER) AND (Arg1^._Type <> T_ARG_FLOAT) then
    begin
    { Raise an exception because first argument is not a float or integer,
    the string composed is 'type_error(number, <Arg1-Lexeme>).'
    Allocate the memory for the exception string. }

    { Create a string with all the arguments in it }
    ConcatArgs(Arg1, args);

    { Allocate the necessary memory }
    Exc^._String := TP_MEMALLOC( 32 + StrLen(PChar(args)) );

    { Create a valid Prolog expression }
    StrCopy( Exc^._String, 'type_error(number, ' );
    StrCat( Exc^._String, PChar(args) );
    StrCat( Exc^._String, ').' );

    { Return the result code that indicates to Trinc-Prolog throw an exception }
    Result := TP_EXCEPTION;
    Exit;
end;

 

 

info@trinc-prolog.com