SRL Archive - MML Library Development

CTS modifiers


i luffs yeww

2010-12-01 09:35:50


function set_tolerance_speed(C: TClient; nCTS: Integer); cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
C.MFinder.SetToleranceSpeed(nCTS);
except on e : Exception do
begin
last_error := e.message;
exit(RESULT_ERROR);
end;
end;
result := RESULT_OK;
end;

function get_tolerance_speed(C: TClient; out cts: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
cts := C.MFinder.GetToleranceSpeed;
result := RESULT_OK;
end;

function set_tolerance_speed_2_modifiers(C: TClient; const nHue, nSat: Extended); cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
C.MFinder.SetToleranceSpeed2Modifiers(nHue, nSat);
except on e : Exception do
begin
last_error := e.message;
exit(RESULT_ERROR);
end;
end;
result := RESULT_OK;
end;

function get_tolerance_speed_2_modifiers(C: TClient; out hueMod, satMod: Extended); cdecl;
var
h, s: Extended;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
C.MFinder.GetToleranceSpeed2Modifiers(h, s);
hueMod := h;
satMod := s;
result := RESULT_OK;
end;

I'm pretty sure I did those all right. This libMML stuff is actually pretty easy.

E: Two minutes before my alarm goes off, just wanted to ask if "const" was needed in set_color_speed_2_modifiers. It was in SetColorSpeed2Modifiers in Finder but I'm not sure if it's really necessary.. Thanks.

Nava2

2010-12-01 14:29:19

From: i luffs yeww

function set_tolerance_speed(C: TClient; nCTS: Integer); cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
C.MFinder.SetToleranceSpeed(nCTS);
except on e : Exception do
begin
last_error := e.message;
exit(RESULT_ERROR);
end;
end;
result := RESULT_OK;
end;

function get_tolerance_speed(C: TClient; out cts: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
cts := C.MFinder.GetToleranceSpeed;
result := RESULT_OK;
end;

function set_tolerance_speed_2_modifiers(C: TClient; const nHue, nSat: Extended); cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
C.MFinder.SetToleranceSpeed2Modifiers(nHue, nSat);
except on e : Exception do
begin
last_error := e.message;
exit(RESULT_ERROR);
end;
end;
result := RESULT_OK;
end;

function get_tolerance_speed_2_modifiers(C: TClient; out hueMod, satMod: Extended); cdecl;
var
h, s: Extended;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
C.MFinder.GetToleranceSpeed2Modifiers(h, s);
hueMod := h;
satMod := s;
result := RESULT_OK;
end;

I'm pretty sure I did those all right. This libMML stuff is actually pretty easy.

E: Two minutes before my alarm goes off, just wanted to ask if "const" was needed in set_color_speed_2_modifiers. It was in SetColorSpeed2Modifiers in Finder but I'm not sure if it's really necessary.. Thanks.


The ``const'' keyword merely adds some optimization into the code. Its a good habit! :) Its not necessary, but really.. why not?

This is a great start, by the way. :)

Wizzup?

2010-12-01 15:08:30

From: Nava2
The ``const'' keyword merely adds some optimization into the code. Its a good habit! :) Its not necessary, but really.. why not?

This is a great start, by the way. :)


What optimisation? Just wondering.

i luffs yeww

2010-12-01 15:44:09

^ This. I know it acts the same as without it, so I wasn't sure if I should keep it in or not (I'm fine with either, I just am trying to learn ;)).

And I am going to do much much more tonight, and I'll address pyMML accordingly. :)

Nava2

2010-12-01 19:18:10

From: Wizzup?
What optimisation? Just wondering.


Ray said the the FPC compiler makes some optimization some where to make the reference better..

.. I think it was Ray..

i luffs yeww

2010-12-01 23:18:22

I'm pretty sure the difference is just that const are compiled at compile-time, while vars are compiled at run-time.. I think.

Nava2

2010-12-01 23:57:40

From: i luffs yeww
I'm pretty sure the difference is just that const are compiled at compile-time, while vars are compiled at run-time.. I think.


That is true with true constants, but it would be impossible here. It is impossible because you will *never* know what the value is until its called.

i luffs yeww

2010-12-02 00:01:15

So then I don't see the point? And would there be any way of testing this? I suppose I could call a function a few thousand times (function wat(const a, b: Integer): Boolean; begin Result := True; end; ) and another one (function lolwut(a, b: Integer): Boolean; begin Result := True; end; ) and see which is faster. I will in about an hour if nobody else does. :p