Page 1 of 1

Posted: 26 Apr 2014, 03:11
by ahonoe
Can anyone suggest why the following script doesn't work in HH? It has something to do with the setValue() but I don't know what.

//////////////////////////
// Basic counter
/////////////////////////
// parameters declaration
var incx : TParameter;
var countr : TParameter;
var reset : TParameter;


// initialisation : create parameters
procedure init;
begin
incx := CreateParam('incx',ptButton);
countr := CreateParam('countr',ptDataFader);
reset := CreateParam('reset',ptButton);

SetIsOutPut(incx,false);
SetIsInput(countr,false);
SetIsOutPut(reset,false);

end;

// Global variables
var c : single;

Procedure Callback(N:integer);
begin
if (n = incx) OR (n = reset) then begin
fTrace(c);
c := c - (c*getValue(reset));
c := c+getValue(incx);
setValue(countr,c);
end;
end;

Thanks!

Posted: 26 Apr 2014, 15:35
by oli_lab
//////////////////////////
// Basic counter
/////////////////////////
// parameters declaration
var incx : TParameter;
var countr : TParameter;
var reset : TParameter;
// Global variables
var c : single;



// initialisation : create parameters
procedure init;
begin
incx := CreateParam('incx',ptButton);
countr := CreateParam('countr',ptDataFader);
SetMin(countr,0);
SetMax(countr,20000000);
SetFormat(countr,'%.1f');

reset := CreateParam('reset',ptButton);

SetIsOutPut(incx,false);
SetIsInput(countr,false);
SetIsOutPut(reset,false);

end;

Procedure Callback(N:integer);
begin
case N of
0: begin
SetValue(countr,GetValue(countr) + 1);
end;
2: begin
c := 0;
SetValue(countr,0);
end;
end;
end;

Posted: 26 Apr 2014, 15:40
by oli_lab
better callback procedure :

rocedure Callback(N:integer);
begin
case N of
0: begin
c := c + 1;
if (c = 20) then c := 0;
SetValue(countr,c);
end;
2: begin
c := 0;
SetValue(countr,0);
end;
end;
end;

Posted: 26 Apr 2014, 15:51
by ahonoe
Thanks @OLI!

I'm a bit unclear as to how your changes make the script work. Is it the setformat() function that fixes the setvalue() issue? (I see by the ftrace() that the counter is working within my script. It seems that the output doesn't want to display these values.)

Posted: 26 Apr 2014, 17:02
by oli_lab
this part allowed for the value to be more than "1" as I understand : SetMax(countr,20000000);

Posted: 26 Apr 2014, 17:03
by ahonoe
Thanks Oli!