Welcome to %s forums

BrainModular Users Forum

Login Register

New sript issue

I need help on a Patch
Post Reply
Ken29
Member
Posts: 116
Contact:

Unread post by Ken29 » 30 Aug 2011, 23:00

I guys,

I'm trying to get better in the art of scripting. I have this problem I do not understand...

Image

On this simple patch, when the "switch" change from 0 to 1, "data out" change from 0 to 1 but not the Toggle... Here's the script. Thanks

//////////////////////////
// Changement de nom
/////////////////////////
// parameters declaration

Var InA : tParameter;
Var OutA : tParameter;

// initialisation : create parameters
procedure init;
begin

InA := Createparam('Entrée', ptSwitch);
SetIsOutput(InA, False);
OutA := Createparam('Sortie', PtButton);
SetIsInput(OutA, False);

end;

//////////////////////////////
// main proc
//////////////////////////////
Procedure Process;
begin
If Getvalue (InA)= 1 then SetValue (OutA,1);
If Getvalue (InA)= 0 then SetValue (OutA,0);
end;

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

Unread post by nay-seven » 30 Aug 2011, 23:38

it's not a script issue, add a switch to a toggle module and you'll have the same result..
as the toggle module receive 1, he toggle..
and as long as it receives a 1 he will toggle

Ken29
Member
Posts: 116
Contact:

Unread post by Ken29 » 31 Aug 2011, 13:16

Hi,

You're right, I've just add a switch to a toggle and tried. When the switch goes to 1, toggle out should be 1, then the switch goes to 0 and then to 1 again, the toggle out should be 0. But it doesn't work and I don't understand why.

Kenan

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

Unread post by nay-seven » 31 Aug 2011, 13:44

try to create a wire from the inlet of the toggle button, you'll see that Usine propose you a button not a switch
the toggle module work this way, each time he receive an impulsion (like button) he toggle, this mean he change the value
if you use a switch with a fixed value your force the module to always toggle..?

Ken29
Member
Posts: 116
Contact:

Unread post by Ken29 » 31 Aug 2011, 18:22

Ok, I changed my script like this and it works now... Thanks

//////////////////////////
// Test
/////////////////////////
// parameters declaration

Var InA : tParameter;
Var OutA : tParameter;

// initialisation : create parameters
procedure init;
begin

InA := Createparam('Entrée', ptButton);
SetIsOutput(InA, False);
OutA := Createparam('Sortie', PtButton);
SetIsInput(OutA, False);

end;

//////////////////////////////
// main proc
//////////////////////////////
Procedure Process;
begin
If Getvalue (InA)= 1 then SetValue (OutA,1);
If Getvalue (InA)= 0 then SetValue (OutA,0);
end;

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests