| { Multiply the first and second argument } Mul := StrToFloat(Arg1^._Lexeme) * StrToFloat(Arg2^._Lexeme); { Check what to do with the result } if Arg3^._Type = T_ARG_VAR_EMPTY then begin { Convert value to a string } s := FloatToStr(Mul); { Allocate memory to store the result in, this memory will be deleted by Trinc-Prolog if it is no longer necessary, the allocated block is already filled with zero's } PC := TP_MEMALLOC( Length(s) + Length(TP_VALUE_FUNCTOR) + Length('().') + 1 ); { Copy string to the buffer, a predicate like 'value(16).' is created if the first two arguments are both 4 } StrCat(PC, TP_VALUE_FUNCTOR); StrCat(PC, '('); StrCat(PC, PChar(s)); StrCat(PC, ').'); { Assign address of buffer to the argument structure } Arg3^._VarValue := PC; Result := TP_EXIT; end else begin { Compare value of third argument with the result of multiplication } Val3 := StrToFloat(Arg3^._Lexeme); if Val3 = Mul then begin { The values are the same } Result := TP_EXIT; end else begin { Different results } Result := TP_FAIL; end; end; |