Welcome to %s forums

BrainModular Users Forum

Login Register

Script not working in the V4

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

Script not working in the V4

Unread post by woodslanding » 13 Jan 2020, 00:57

Edit: I pasted the code twice here, but it's not that way in the module (just checked....) I guess I'll log this as a bug...
////////////////////////////////////////////

This worked fine in V3, but not in version 4. It's supposed to scan a directory and return an item number and a name in text. The number part is still working, but the text part is broken. Just wondering what might have changed to cause this.

Thanks in advance!
-eric

Code: Select all

/////////////////////////////////////////////
// strip filenames
////////////////////////////////////////////

// parameters declaration
var idxIN,pathsIN,selIN     : Tparameter;
var filenameOUT,displayOUT,idxOUT   : Tparameter;
var pathList : TstringList; 
var count : integer;

// initialisation : create parameters
procedure init;
var i : integer;
begin     
    SetModuleColor($807080+909960);
    pathsIN := CreateParam('full paths ct',ptTextField);        SetIsOutPut(pathsIN,false);   
    selIN := CreateParam('selection',ptDatafield);                  SetIsOutput(selIN,false);  
    idxIN := CreateParam('index',ptDatafield);                  SetIsOutput(idxIN,false);
    filenameOUT := CreateParam('inst filename',ptTextField);             SetIsInPut(filenameOUT,false);
    displayOUT := CreateParam('inst name',ptTextField);             SetIsInPut(displayOUT,false);
    idxOUT := CreateParam('index',ptDatafield);                  SetIsInput(idxOUT,false);         
    pathList.create; 
end; 

procedure destroy;  begin pathList.free end;
                           
//TODO:  do we need to be able to get an index out from a selection in????                           
procedure Callback(n:integer);
var filename,name : string;
var i,id,idx,sel : integer; 
begin
    if (n = pathsIN) then
    begin   
       
        pathList.SetCommaText(GetStringValue(pathsIN));  
        count := pathList.count;
    end
    else if (n = selIN) then
    begin
        sel := trunc(getValue(selIN));
        filename := SubFileExt(ExtractFileName(pathList.GetStrings(sel)));
        name := copy(filename,5,length(filename) - 4);
        idx := strToInt(copy(filename,1,3));
        setValue(idxOUT, idx);
        setStringValue(filenameOUT,filename);
        setStringValue(displayOUT, name);
    end
    else if (n = idxIN) then
    begin
        id := trunc(getValue(idxIN)); 
        setValue(idxOUT, id);
        For i := 0 to count - 1 do 
        begin     
            filename := SubFileExt(ExtractFileName(pathList.GetStrings(i)));
            strace('filename = ' + filename);
            name := copy(filename,5,length(filename) - 4);
            idx := strToInt(copy(filename,1,3));            
            if (id = idx) then 
            begin
                setStringValue(filenameOUT,filename);
                setStringValue(displayOUT, name);                 
            end;
        end;                                   
    // strace(GetStringValue(namesOUT));
    end;   
end;

// no process bloc
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 15 Jan 2020, 16:38

okay, isolated the script and made a test patch, and it works fine in HH4. Maybe it just didn't load properly as part of the wkp. I'll do more tests....
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 15 Jan 2020, 16:52

cool, good news !

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 18 Feb 2020, 09:34

Sure enough, HH4 cabled to the wrong node. Instead of cabling to the input called index, it treated the OUTPUT called index as an input, and cabled to that. Of course it didn't work.

This is an old bug, (which I thought was dead) but evidently an even older script. I have taken to adding IN and OUT to the names of all ports, because this used to happen so frequently.... but I guess I hadn't yet gotten into the habit when I wrote this one.

Now I have to dig 3 layers down into 15 subpatches to fix them all... :/
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 18 Feb 2020, 09:40

ok, i understand,
but maybe you can send us an example, and we try to fix it ?
use support@brainmodular.com

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 18 Feb 2020, 16:56

I'll see if I can replicate it on a smaller scale than my 1 gig wkp ;)
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 05 Oct 2020, 05:30

Well, this took a while, but I'm back to trying to get things working in the V4. Here's the patch in question (Have to re-fix these bugs as part of the update process, so I'm back here trying to remember what I did 8 months ago ;))

It's the script called 'instNameFromIndex'. Under hh3, it cables correctly.
Attachments
loadInstData.pat
(47.9 KiB) Downloaded 359 times
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

SylvainT
Site Admin
Posts: 494
Contact:

Unread post by SylvainT » 05 Oct 2020, 10:10

Please, send a bug report. Unfortunately, I guess no one can help you on the forum.
Sometimes, from HH3 to HH4, some wires were cabled to the wrong node. Not often. The problem was solved in many cases. Be sure to work with the latest version.

I see you like scripting, there's many many improvements in scripting solutions in latest HH4 updates. Have a look in the manual (https://www.brainmodular.com/manuals/hh4/en/scripting)

All the best

Sylvain

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 06 Oct 2020, 22:03

Thanks for the tip. I'll go check out the scripting manual. If Olivier wants to look for this bug, that's fine, but I fixed the issue easily, so no big deal...

cheers!
-eric
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 06 Oct 2020, 22:12

one question: there is a lot of new syntax. Will using this syntax improve speed, or is it just for readability and ease of writing?
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

SylvainT
Site Admin
Posts: 494
Contact:

Unread post by SylvainT » 08 Oct 2020, 10:37

Hello,

I thing new syntax is it just for readability and ease of writing. And for new possibilities.
But many improvements were made for speed, script are really faster than ever.

All the best

Sylvain

Post Reply

Who is online

Users browsing this forum: No registered users and 142 guests