Welcome to %s forums

BrainModular Users Forum

Login Register

Newbie scripting help

I need help on a Patch
Post Reply
ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 26 Apr 2014, 03:11

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!
Regards,

Scott

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 26 Apr 2014, 15:35

//////////////////////////
// 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;
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 26 Apr 2014, 15:40

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;
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 26 Apr 2014, 15:51

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.)
Regards,

Scott

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 26 Apr 2014, 17:02

this part allowed for the value to be more than "1" as I understand : SetMax(countr,20000000);
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 26 Apr 2014, 17:03

Thanks Oli!
Regards,

Scott

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests