Csound Csound-dev Csound-tekno Search About

[Csnd-dev] is this also a new-style UDO issue?

Date2025-09-27 01:51
Fromjoachim heintz
Subject[Csnd-dev] is this also a new-style UDO issue?
opcode one3(arrr:k[]):(b)
   ans:b init true
   //here is of course other code
   xout(ans)
endop

instr 1
   a:k[] = [1,1,1]
   if one3(a) then
     printks("True\n",0)
   else
     printks("False\n",0)
   endif
   turnoff
endin

it should print "True" but it prints "False".
it works when i write
   if true then
    ...

by the way: how can i print the boolean value?

	joachim

Date2025-09-27 02:00
Fromjoachim heintz
SubjectRe: [Csnd-dev] is this also a new-style UDO issue?
it seems that it is only an issue (swapping true and false) for booleans.
this works:

opcode one3a():(k)
   ans:k init 1
   xout(ans)
endop

instr 1
   if one3a() == 1 then
     printks("True\n",0)
   else
     printks("False\n",0)
   endif
   turnoff
endin


On 27/09/2025 09:51, joachim heintz wrote:
> opcode one3(arrr:k[]):(b)
>    ans:b init true
>    //here is of course other code
>    xout(ans)
> endop
> 
> instr 1
>    a:k[] = [1,1,1]
>    if one3(a) then
>      printks("True\n",0)
>    else
>      printks("False\n",0)
>    endif
>    turnoff
> endin
> 
> it should print "True" but it prints "False".
> it works when i write
>    if true then
>     ...
> 
> by the way: how can i print the boolean value?
> 
>      joachim

Date2025-09-27 02:13
Fromjoachim heintz
SubjectRe: [Csnd-dev] is this also a new-style UDO issue?
it seems to be more related to the init opcode --- either not working 
properly for booleans, or used in a wrong way?
this version with assignment works:

opcode one3(arrr:k[]):(b)
   ans:b = true
   xout(ans)
endop

instr 1
   a:k[] = [1,1,1]
   if one3(a) then
     printks("True\n",0)
   else
     printks("False\n",0)
   endif
   turnoff
endin


On 27/09/2025 09:51, joachim heintz wrote:
> opcode one3(arrr:k[]):(b)
>    ans:b init true
>    //here is of course other code
>    xout(ans)
> endop
> 
> instr 1
>    a:k[] = [1,1,1]
>    if one3(a) then
>      printks("True\n",0)
>    else
>      printks("False\n",0)
>    endif
>    turnoff
> endin
> 
> it should print "True" but it prints "False".
> it works when i write
>    if true then
>     ...
> 
> by the way: how can i print the boolean value?
> 
>      joachim

Date2025-09-27 03:26
FromDave Seidel
SubjectRe: [Csnd-dev] is this also a new-style UDO issue?
I would only use init with a k-var, so using = seems correct to me.

On Fri, Sep 26, 2025 at 9:13 PM joachim heintz <jh@joachimheintz.de> wrote:
it seems to be more related to the init opcode --- either not working
properly for booleans, or used in a wrong way?
this version with assignment works:

opcode one3(arrr:k[]):(b)
   ans:b = true
   xout(ans)
endop

instr 1
   a:k[] = [1,1,1]
   if one3(a) then
     printks("True\n",0)
   else
     printks("False\n",0)
   endif
   turnoff
endin


On 27/09/2025 09:51, joachim heintz wrote:
> opcode one3(arrr:k[]):(b)
>    ans:b init true
>    //here is of course other code
>    xout(ans)
> endop
>
> instr 1
>    a:k[] = [1,1,1]
>    if one3(a) then
>      printks("True\n",0)
>    else
>      printks("False\n",0)
>    endif
>    turnoff
> endin
>
> it should print "True" but it prints "False".
> it works when i write
>    if true then
>     ...
>
> by the way: how can i print the boolean value?
>
>      joachim

Date2025-09-27 05:25
Fromjoachim heintz
SubjectRe: [Csnd-dev] is this also a new-style UDO issue?
yes, and thanks to your reply i now realize that i used the wrong 
boolean type.
it should be B, not b, because it is k-rate.

but still i don't understand why this code returns "False":

opcode one3(arrr:k[]):(B)
   ans:B init true
   for el in arrr do
     if el != 1 then
       ans = false
       kgoto end
     endif
   od
   end: xout(ans)
endop

instr 1
   a:k[] = [1,1,1]
   if one3(a) then
     printks("True\n",0)
   else
     printks("False\n",0)
   endif
   turnoff
endin

it also returns "False" when i set in the UDO:
   ans:B = true

am i doing one the usual silly mistakes?

On 27/09/2025 11:26, Dave Seidel wrote:
> I would only use init with a k-var, so using = seems correct to me.
> 
> On Fri, Sep 26, 2025 at 9:13 PM joachim heintz  > wrote:
> 
>     it seems to be more related to the init opcode --- either not working
>     properly for booleans, or used in a wrong way?
>     this version with assignment works:
> 
>     opcode one3(arrr:k[]):(b)
>         ans:b = true
>         xout(ans)
>     endop
> 
>     instr 1
>         a:k[] = [1,1,1]
>         if one3(a) then
>           printks("True\n",0)
>         else
>           printks("False\n",0)
>         endif
>         turnoff
>     endin
> 
> 
>     On 27/09/2025 09:51, joachim heintz wrote:
>      > opcode one3(arrr:k[]):(b)
>      >    ans:b init true
>      >    //here is of course other code
>      >    xout(ans)
>      > endop
>      >
>      > instr 1
>      >    a:k[] = [1,1,1]
>      >    if one3(a) then
>      >      printks("True\n",0)
>      >    else
>      >      printks("False\n",0)
>      >    endif
>      >    turnoff
>      > endin
>      >
>      > it should print "True" but it prints "False".
>      > it works when i write
>      >    if true then
>      >     ...
>      >
>      > by the way: how can i print the boolean value?
>      >
>      >      joachim
> 

Date2025-09-27 08:17
Fromvlz
SubjectRe: [Csnd-dev] is this also a new-style UDO issue?
b is an i-time boolean, so you should use prints not printks. B is k-time instead.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 27 Sep 2025, at 02:13, joachim heintz  wrote:
> 
> it seems to be more related to the init opcode --- either not working properly for booleans, or used in a wrong way?
> this version with assignment works:
> 
> opcode one3(arrr:k[]):(b)
>  ans:b = true
>  xout(ans)
> endop
> 
> instr 1
>  a:k[] = [1,1,1]
>  if one3(a) then
>    printks("True\n",0)
>  else
>    printks("False\n",0)
>  endif
>  turnoff
> endin
> 
> 
>> On 27/09/2025 09:51, joachim heintz wrote:
>> opcode one3(arrr:k[]):(b)
>>   ans:b init true
>>   //here is of course other code
>>   xout(ans)
>> endop
>> instr 1
>>   a:k[] = [1,1,1]
>>   if one3(a) then
>>     printks("True\n",0)
>>   else
>>     printks("False\n",0)
>>   endif
>>   turnoff
>> endin
>> it should print "True" but it prints "False".
>> it works when i write
>>   if true then
>>    ...
>> by the way: how can i print the boolean value?
>>     joachim

Date2025-09-27 10:01
Fromjoachim heintz
SubjectRe: [Csnd-dev] is this also a new-style UDO issue?
yes i noticed this, too, and here again the version from my last email:

still i don't understand why this code returns "False":

opcode one3(arrr:k[]):(B)
   ans:B init true
   for el in arrr do
     if el != 1 then
       ans = false
       kgoto end
     endif
   od
   end: xout(ans)
endop

instr 1
   a:k[] = [1,1,1]
   if one3(a) then
     printks("True\n",0)
   else
     printks("False\n",0)
   endif
   turnoff
endin

it also returns "False" when i set in the UDO:
   ans:B = true

On 27/09/2025 16:17, vlz wrote:
> b is an i-time boolean, so you should use prints not printks. B is k-time instead.
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 27 Sep 2025, at 02:13, joachim heintz  wrote:
>>
>> it seems to be more related to the init opcode --- either not working properly for booleans, or used in a wrong way?
>> this version with assignment works:
>>
>> opcode one3(arrr:k[]):(b)
>>   ans:b = true
>>   xout(ans)
>> endop
>>
>> instr 1
>>   a:k[] = [1,1,1]
>>   if one3(a) then
>>     printks("True\n",0)
>>   else
>>     printks("False\n",0)
>>   endif
>>   turnoff
>> endin
>>
>>
>>> On 27/09/2025 09:51, joachim heintz wrote:
>>> opcode one3(arrr:k[]):(b)
>>>    ans:b init true
>>>    //here is of course other code
>>>    xout(ans)
>>> endop
>>> instr 1
>>>    a:k[] = [1,1,1]
>>>    if one3(a) then
>>>      printks("True\n",0)
>>>    else
>>>      printks("False\n",0)
>>>    endif
>>>    turnoff
>>> endin
>>> it should print "True" but it prints "False".
>>> it works when i write
>>>    if true then
>>>     ...
>>> by the way: how can i print the boolean value?
>>>      joachim