Page 1 of 1

Array script not working in V4

Posted: 18 Feb 2020, 09:28
by woodslanding
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....
2020-02-18 01_02_50-getFXprogNames.png
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;

Re: Array script not working in V4

Posted: 05 Mar 2020, 16:55
by woodslanding
Anybody? I can't get any effects to work in my WKP without this script. Works fine in V3.... I've been through the code, it all looks like it should work, and it did before.

Re: Array script not working in V4

Posted: 05 Mar 2020, 16:58
by nay-seven
As said before, consider sending it to support@brainmodular.com

Re: Array script not working in V4

Posted: 05 Mar 2020, 19:46
by woodslanding
Okay, I have found out that this type of line:

var sats: array[1..MAX] of single;

Is no longer supported.

I made variable length arrays and set their length in the init.

BUT, I am still getting nothing from the get and set commatext methods for TStringList. Has that method changed???

[edit: nevee mind, I had commented out that line....]

ALL WORKING NOW!

cheers,
-e

Re: Array script not working in V4

Posted: 05 Mar 2020, 19:49
by nay-seven
good news !