Array script not working in V4
Posted: 18 Feb 2020, 09:28
This worked fine in v3. It also opened fine in v4. But after saving as v4, it doesn't work.
Any thoughts?
It is supposed to sort through the list of channels, and output a list of channel numbers and names that are fx channels. But, although there are four non-zero values for fxStatusIN, there is no output of either names or numbers. All the input data looks fine....
Oddly, it did work for names, but not numbers until I did a recompile and reset. Now it doesn't work for either. Just wondering if I have some wrong syntax that the v3 glossed over.....
Any thoughts?
It is supposed to sort through the list of channels, and output a list of channel numbers and names that are fx channels. But, although there are four non-zero values for fxStatusIN, there is no output of either names or numbers. All the input data looks fine....
Oddly, it did work for names, but not numbers until I did a recompile and reset. Now it doesn't work for either. Just wondering if I have some wrong syntax that the v3 glossed over.....
Code: Select all
//////////////////////////
/////////////////////////
Const MAX = 32;
// parameters declaration
var fxStatusIN,huesIN,satsIN : TParameter;
var ctIN : TParameter;
var fxChansOUT,ctOUT,huesOUT,satsOUT : TParameter;
var fxChans: array[1..MAX] of integer;
var hues: array[1..MAX] of single;
var sats: array[1..MAX] of single;
// initialisation : create parameters
procedure init;
begin
fxStatusIN := CreateParam('fx status',PtArray);
SetIsOutput(fxStatusIN,false);
SetMax(fxStatusIN,MAX);
ctIn := CreateParam('ch names',PtTextfield);
SetIsOutput(ctIn,false);
HuesIn := CreateParam('ch hues',PtArray);
SetIsOutput(HuesIn,false);
SatsIn := CreateParam('ch saturations',PtArray);
SetIsOutput(SatsIn,false);
fxChansOUT := CreateParam('fx chs',PtArray);
SetIsInput(fxChansOUT,false);
SetMax(fxChansOUT,MAX);
ctOut := CreateParam('fx prgs',PtTextfield);
SetIsInput(ctOut,false);
HuesOUT := CreateParam('fx hues',PtArray);
SetIsInput(HuesOUT,false);
satsOUT := CreateParam('fx saturations',PtArray);
SetIsInput(SatsOUT,false);
end;
// Callback procedure
Procedure Callback(N:integer);
var fxCount,len,chanNum,i : integer;
var status : integer;
var name : string;
var slIN,slOUT: TStringlist;
var hue,sat : single;
begin
slIN.create;
slOUT.create;
len := GetLength(fxStatusIN);
slIN.setCommatext(getStringValue(ctIN)); //sl count is long because of an extra comma at the end!
fxCount := 0;
if (slIN.count - 1 <> len) then strace('>>>ERROR---isfx count = ' + inttostr(len) + ',string count = ' + intToStr(slIN.count) + ':getFXprogramNames')
for chanNum := 0 to len-1
do begin
status := trunc(GetDataArrayValue(fxStatusIN,chanNum));
hue := GetDataArrayValue(huesIN,chanNum);
sat := GetDataArrayValue(satsIN,chanNum);
if status > 0 then
begin
fxChans[fxCount] := status;
name := slIN.getstrings(status - 1);// status is more reliable than string number. 1 indexed.
//strace('got value:' + name + ' for chan ' + inttostr(chanNum) + 'status ch = ' + inttostr(status));
//strace('hue = ' + floattostr(hue));
slOUT.add(name);
hues[fxCount] := hue;
sats[fxCount] := sat;
fxCount := fxCount + 1;
end;
end;
//strace('len = ' + inttostr(fxCount));
SetLength(fxChansOUT, fxCount);
SetLength(huesOUT,fxCount);
SetLength(satsOUT,fxCount);
for i := 0 to fxCount-1 do
begin
SetDataArrayValue(fxChansOUT,i,fxChans[i]);
SetStringValue(ctOUT,slOUT.getCommatext());
SetDataArrayValue(huesOUT,i,hues[i]);
SetDataArrayValue(satsOUT,i,sats[i]);
end;
slIN.free;
slOUT.free;
end;