Welcome to %s forums

BrainModular Users Forum

Login Register

How do I convert a number to a single

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

Unread post by ahonoe » 12 Nov 2015, 04:59

Another noob scripting question. I'm comparing values stored in an array to a previous version of the same array. I've specified the "current" and "last" arrays as being of type single. I get an "invalid expression" error when I try to compare values at the same index in each array. Does this mean that the values are of different types? If so, how do I convert them (presumably to singles)? Thanks.
Regards,

Scott

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 12 Nov 2015, 11:44

Doesnt sound like thats the problem, can you please share your code so I can look at and maybe help?

-s
"Every act of creation is first an act of destruction." -Picasso

ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 14 Nov 2015, 02:18

Thanks for responding to my request, Seph. Here's the code:

//////////////////////////
//
/////////////////////////
const ar_size = 512;

// parameters declaration
var aux_send_levels : Tparameter;
var tr_fader_levels : Tparameter;
var last_ar, cur_ar : array [0..ar_size] of single;

// initialisation : create parameters
procedure init;
var i : integer;
begin
SetModuleColor($606060+302060);

aux_send_levels := CreateParam('aux_rec_lvls',ptArray);
SetIsOutPut(aux_send_levels,false);

tr_fader_levels := CreateParam('tr_fdr_lvls',ptArray);
SetIsInPut(tr_fader_levels,false);
for i:= 0 to ar_size do
begin
last_ar := -1.0;
end;
end;

// Callback procedure
Procedure Callback(N:integer);
var i : integer;
var cv,lv : single;
begin
for i := 0 to ar_size - 1 do
begin
cv := GetDataArrayValue(aux_send_levels, i);
lv := last_ar;
// if (cv <> lv) then do <--- error occurs here
// begin
// end;
end;
last_ar := cur_ar;
end;
Regards,

Scott

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 14 Nov 2015, 04:18

So maybe try this:

if (cv<>lv) then
begin

end;

I think the "do" is throwing your invalid expression.

-s
"Every act of creation is first an act of destruction." -Picasso

ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 14 Nov 2015, 04:37

Lol. Thanks, seph.

Community FTW
Regards,

Scott

Post Reply

Who is online

Users browsing this forum: No registered users and 87 guests