ArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2008-06-24T13:31:06+02:00 https://brainmodular.org/forums/app.php/feed/topic/884 2008-06-24T13:31:06+02:00 2008-06-24T13:31:06+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4616#p4616 <![CDATA[An IIF vBasic like script]]> .
I'll complete it with more operators and perhaps download it for some "lazy" users !.
I'm sure that delphi is a powefull programming language and i'll try to make a visual user module (i have some ideas...). Congratulation and thanks to SensoMusic Team to give us a so complete software for only 50 €... I just by a Yamaha EzTP electronic trumpet and connect it yesterday to Usine... this was an extrem experience for me (not for my neighbours)
Jean-Jacques
(experimental music only)

Statistics: Posted by zenzak — 24 Jun 2008, 13:31


]]>
2008-06-24T08:55:37+02:00 2008-06-24T08:55:37+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4615#p4615 <![CDATA[An IIF vBasic like script]]>
You really should use some variables here. All the GetValues do take more CPU than needed, and also makes the script less compact and a bit harder to read than what is really neccessary. Here's a compact version (sorry, couldn't resist it):

CODE:

begin  operator &#58;= CreateParam&#40;'operator',ptListBox&#41;;  SetListBoxString&#40;operator,'"A=B","A<B","A>B","A<>B"'&#41;;  SetIsOutput&#40;operator,false&#41;;  A &#58;= CreateParam&#40;'A',ptDatafield&#41;;  SetIsOutput&#40;A,false&#41;;  B &#58;= CreateParam&#40;'B',ptDatafield&#41;;  SetIsOutput&#40;B,false&#41;;  isTrue &#58;= CreateParam&#40;'isTrue',ptDatafield&#41;;  SetIsOutput&#40;isTrue,false&#41;;  isFalse &#58;= CreateParam&#40;'isFalse',ptDatafield&#41;;  SetIsOutput&#40;isFalse,false&#41;;  outPut &#58;= CreateParam&#40;'outPut',ptDatafield&#41;;  SetIsinput&#40;outPut,false&#41;;end;var op &#58; integer;var out &#58; boolean;var fa, fb &#58; single;begin   op &#58;= trunc&#40;GetValue&#40;operator&#41;&#41;;   fa &#58;= GetValue&#40;A&#41;;   fb &#58;= GetValue&#40;B&#41;;   case op of     0 &#58; out &#58;= &#40;A=B&#41;;     1 &#58; out &#58;= &#40;A<B&#41;;     2 &#58; out &#58;= &#40;A>B&#41;;     3 &#58; out &#58;= &#40;A<>B&#41;;   end;   if &#40;out&#41; then begin     SetValue&#40;outPut, GetValue&#40;isTrue&#41;&#41;;   end   else begin     SetValue&#40;outPut, GetValue&#40;isFalse&#41;&#41;;   end;end.
The same function could also be created quite easily using modules. For example the A=B, A<B etc modules connected to the val inputs on a Selector, with a combo box to the select for the operators. Add 1 to the output of the Selector and use that for select on another Selector to switch between the isTrue and isFalse values, or instead of using a second Selector you could use Stop Event Flow and Pass Event Flow modules.

BTW, in my example code, I've used BEGIN .. END in the final IF .. ELSE statement even if it as far as I can see really shouldn't be neccessary. That's because I got a compilation error without it, which it seems that I get more often than others when I compare my scripts to what others create. It's either compilation errors or wrong behaviour in some way or another... Go figure - must be bad karma or something.

Statistics: Posted by bsork — 24 Jun 2008, 08:55


]]>
2008-06-24T00:56:15+02:00 2008-06-24T00:56:15+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4613#p4613 <![CDATA[An IIF vBasic like script]]>
/////////////////////////////////////////////////////////////////
begin
if getvalue(operator)=0 then
if getvalue(A)=getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=1 then
if getvalue(A)<>getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=2 then
if getvalue(A)<getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=3 then
if getvalue(A)<=getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=4 then
if getvalue(A)>getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=5 then
if getvalue(A)>=getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
end.

Statistics: Posted by zenzak — 24 Jun 2008, 00:56


]]>
2008-06-24T00:21:17+02:00 2008-06-24T00:21:17+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4612#p4612 <![CDATA[An IIF vBasic like script]]>
i replace SetdefaultValue(operator,int(0)) with

SetValue(operator,0);

Statistics: Posted by zenzak — 24 Jun 2008, 00:21


]]>
2008-06-24T00:06:37+02:00 2008-06-24T00:06:37+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4611#p4611 <![CDATA[An IIF vBasic like script]]> Jean-Jacques


//////////////////////////////////////////////////////
// A iif vbasic like
//////////////////////////////////////////////////////

//////////////////////////////////////////////////////
// Parameters declaration
//////////////////////////////////////////////////////
var A : Tparameter;
var B: Tparameter;
var isTrue: Tparameter;
var isFalse: Tparameter;
var outPut: Tparameter;
var operator: Tparameter;

//////////////////////////////////////////////////////
// initialisation procedure
//////////////////////////////////////////////////////
procedure init;
begin
operator := CreateParam('operator',ptListBox);
SetListBoxString(operator,'"A=B","A<B","A>B","A<>B"');
SetdefaultValue(operator,int(0)); // doesn't run !!!!!!!!!
SetIsinput(operator,false);
SetIsOutput(operator,false);
SetReadOnly(operator, true);

A := CreateParam('A',ptDatafield);
SetIsinput(A,true);
SetIsOutput(A,false);

B := CreateParam('B',ptDatafield);
SetIsinput(B,true);
SetIsOutput(B,false);

isTrue := CreateParam('isTrue',ptDatafield);
SetIsinput(isTrue,false);
SetIsOutput(isTrue,false);

isFalse := CreateParam('isFalse',ptDatafield);
SetIsinput(isFalse,false);
SetIsOutput(isFalse,false);

outPut := CreateParam('outPut',ptDatafield);
SetIsinput(outPut,false);
SetIsOutput(outPut,true);

end;


//////////////////////////////////////////////////////
// Main Loop procedure
//////////////////////////////////////////////////////
begin
case int(getvalue(operator)) of
0:if getvalue(A)=getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
1:if getvalue(A)=getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
2:if getvalue(A)<getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
3:if getvalue(A)>getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
4:if getvalue(A)<>getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
end;
end.

Statistics: Posted by zenzak — 24 Jun 2008, 00:06


]]>
BrainModular BrainModular Users Forum 2008-06-24T13:31:06+02:00 https://brainmodular.org/forums/app.php/feed/topic/884 2008-06-24T13:31:06+02:00 2008-06-24T13:31:06+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4616#p4616 <![CDATA[An IIF vBasic like script]]> .
I'll complete it with more operators and perhaps download it for some "lazy" users !.
I'm sure that delphi is a powefull programming language and i'll try to make a visual user module (i have some ideas...). Congratulation and thanks to SensoMusic Team to give us a so complete software for only 50 €... I just by a Yamaha EzTP electronic trumpet and connect it yesterday to Usine... this was an extrem experience for me (not for my neighbours)
Jean-Jacques
(experimental music only)

Statistics: Posted by zenzak — 24 Jun 2008, 13:31


]]>
2008-06-24T08:55:37+02:00 2008-06-24T08:55:37+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4615#p4615 <![CDATA[An IIF vBasic like script]]>
You really should use some variables here. All the GetValues do take more CPU than needed, and also makes the script less compact and a bit harder to read than what is really neccessary. Here's a compact version (sorry, couldn't resist it):

CODE:

begin  operator &#58;= CreateParam&#40;'operator',ptListBox&#41;;  SetListBoxString&#40;operator,'"A=B","A<B","A>B","A<>B"'&#41;;  SetIsOutput&#40;operator,false&#41;;  A &#58;= CreateParam&#40;'A',ptDatafield&#41;;  SetIsOutput&#40;A,false&#41;;  B &#58;= CreateParam&#40;'B',ptDatafield&#41;;  SetIsOutput&#40;B,false&#41;;  isTrue &#58;= CreateParam&#40;'isTrue',ptDatafield&#41;;  SetIsOutput&#40;isTrue,false&#41;;  isFalse &#58;= CreateParam&#40;'isFalse',ptDatafield&#41;;  SetIsOutput&#40;isFalse,false&#41;;  outPut &#58;= CreateParam&#40;'outPut',ptDatafield&#41;;  SetIsinput&#40;outPut,false&#41;;end;var op &#58; integer;var out &#58; boolean;var fa, fb &#58; single;begin   op &#58;= trunc&#40;GetValue&#40;operator&#41;&#41;;   fa &#58;= GetValue&#40;A&#41;;   fb &#58;= GetValue&#40;B&#41;;   case op of     0 &#58; out &#58;= &#40;A=B&#41;;     1 &#58; out &#58;= &#40;A<B&#41;;     2 &#58; out &#58;= &#40;A>B&#41;;     3 &#58; out &#58;= &#40;A<>B&#41;;   end;   if &#40;out&#41; then begin     SetValue&#40;outPut, GetValue&#40;isTrue&#41;&#41;;   end   else begin     SetValue&#40;outPut, GetValue&#40;isFalse&#41;&#41;;   end;end.
The same function could also be created quite easily using modules. For example the A=B, A<B etc modules connected to the val inputs on a Selector, with a combo box to the select for the operators. Add 1 to the output of the Selector and use that for select on another Selector to switch between the isTrue and isFalse values, or instead of using a second Selector you could use Stop Event Flow and Pass Event Flow modules.

BTW, in my example code, I've used BEGIN .. END in the final IF .. ELSE statement even if it as far as I can see really shouldn't be neccessary. That's because I got a compilation error without it, which it seems that I get more often than others when I compare my scripts to what others create. It's either compilation errors or wrong behaviour in some way or another... Go figure - must be bad karma or something.

Statistics: Posted by bsork — 24 Jun 2008, 08:55


]]>
2008-06-24T00:56:15+02:00 2008-06-24T00:56:15+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4613#p4613 <![CDATA[An IIF vBasic like script]]>
/////////////////////////////////////////////////////////////////
begin
if getvalue(operator)=0 then
if getvalue(A)=getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=1 then
if getvalue(A)<>getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=2 then
if getvalue(A)<getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=3 then
if getvalue(A)<=getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=4 then
if getvalue(A)>getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
if getvalue(operator)=5 then
if getvalue(A)>=getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
end.

Statistics: Posted by zenzak — 24 Jun 2008, 00:56


]]>
2008-06-24T00:21:17+02:00 2008-06-24T00:21:17+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4612#p4612 <![CDATA[An IIF vBasic like script]]>
i replace SetdefaultValue(operator,int(0)) with

SetValue(operator,0);

Statistics: Posted by zenzak — 24 Jun 2008, 00:21


]]>
2008-06-24T00:06:37+02:00 2008-06-24T00:06:37+02:00 https://brainmodular.org/forums/viewtopic.php?t=884&p=4611#p4611 <![CDATA[An IIF vBasic like script]]> Jean-Jacques


//////////////////////////////////////////////////////
// A iif vbasic like
//////////////////////////////////////////////////////

//////////////////////////////////////////////////////
// Parameters declaration
//////////////////////////////////////////////////////
var A : Tparameter;
var B: Tparameter;
var isTrue: Tparameter;
var isFalse: Tparameter;
var outPut: Tparameter;
var operator: Tparameter;

//////////////////////////////////////////////////////
// initialisation procedure
//////////////////////////////////////////////////////
procedure init;
begin
operator := CreateParam('operator',ptListBox);
SetListBoxString(operator,'"A=B","A<B","A>B","A<>B"');
SetdefaultValue(operator,int(0)); // doesn't run !!!!!!!!!
SetIsinput(operator,false);
SetIsOutput(operator,false);
SetReadOnly(operator, true);

A := CreateParam('A',ptDatafield);
SetIsinput(A,true);
SetIsOutput(A,false);

B := CreateParam('B',ptDatafield);
SetIsinput(B,true);
SetIsOutput(B,false);

isTrue := CreateParam('isTrue',ptDatafield);
SetIsinput(isTrue,false);
SetIsOutput(isTrue,false);

isFalse := CreateParam('isFalse',ptDatafield);
SetIsinput(isFalse,false);
SetIsOutput(isFalse,false);

outPut := CreateParam('outPut',ptDatafield);
SetIsinput(outPut,false);
SetIsOutput(outPut,true);

end;


//////////////////////////////////////////////////////
// Main Loop procedure
//////////////////////////////////////////////////////
begin
case int(getvalue(operator)) of
0:if getvalue(A)=getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
1:if getvalue(A)=getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
2:if getvalue(A)<getvalue(B) then
setvalue(outPut,getvalue(isTrue))
else setvalue(outPut,getvalue(isfalse));
3:if getvalue(A)>getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
4:if getvalue(A)<>getvalue(B) then
setvalue(outPut,getvalue(isTrue)) else
setvalue(outPut,getvalue(isfalse));
end;
end.

Statistics: Posted by zenzak — 24 Jun 2008, 00:06


]]>