[Csnd] Reading String value from channel with functional syntax

Hey hey,
I also have issues reading a string value from a channel.
instrt 1
   chn_S("Strings", 3)
   chnset("Hello World", "Strings")
   ...
endin

instr 2
   ...
   Sname = chnget("Strings")
endin
results in an error:
INIT ERROR in instr 2 (opcode chnget.i) line 21: channel already exists with incompatible type
#i0 chnget.i "Strings"

When not using the functional form on the chnget it works.

I also tried chnget:i("Strings"), but no luck. What am I doing wrong?

Best wishes and many thanks,

Jeanette

I get this too, again essentially cutting/[pasting your code (minus the typo "instrt"!)
Don't see anyting wrong with your syntax!

  -- Pete --

Hi!

It is good practice to always add the type after opcode in functional syntax - you never know what is the default type - if there are several output types for the opcode. Thus:

chnset:S(“Hello World”, “Strings”)

chnget:S(“Strings”)

tarmo

Kontakt Pete Goodeve (<pete.goodeve@computer.org>) kirjutas kuupäeval K, 31. märts 2021 kell 05:02:

I get this too, again essentially cutting/[pasting your code (minus the typo “instrt”!)
Don’t see anyting wrong with your syntax!

– Pete –

Hey hey,
I also have issues reading a string value from a channel.
instrt 1
chn_S(“Strings”, 3)
chnset(“Hello World”, “Strings”)

endin

instr 2

Sname = chnget(“Strings”)
endin
results in an error:
INIT ERROR in instr 2 (opcode chnget.i) line 21: channel already exists
with incompatible type
#i0 chnget.i “Strings”

When not using the functional form on the chnget it works.

I also tried chnget:i(“Strings”), but no luck. What am I doing wrong?

Best wishes and many thanks,

Jeanette

Top down, on the strip
Lookin’ in the mirror
I’m checkin’ out my lipstick <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Mar 31 2021, Tarmo Johannes has written:
...

It is good practice to always add the type after opcode in functional
syntax

...

chnset:S("Hello World", "Strings")
  ...

chnget:S("Strings")

...
Thanks a lot. I somehow didn't know that S could be used with this
syntax. I always assume only a, k and i worked to signify the update
rate.

Best wishes,

Jeanette

Hi!

It is good practice to always add the type after opcode in functional
syntax - you never know what is the default type - if there are several
output types for the opcode. Thus:

chnset:S("Hello World", "Strings")

^^^ That actually throws an error ('Unexpected ":"')... Seems that only opcodes
that return a value can be typed that way.

  -- Pete --

   ...

chnget:S("Strings")

tarmo

Kontakt Pete Goodeve (<pete.goodeve@computer.org>) kirjutas kuupäeval K,
31. märts 2021 kell 05:02:

> I get this too, again essentially cutting/[pasting your code (minus the
> typo "instrt"!)
> Don't see anyting wrong with your syntax!
>
> -- Pete --
>
> > Hey hey,
> > I also have issues reading a string value from a channel.
> > instrt 1
> > chn_S("Strings", 3)
> > chnset("Hello World", "Strings")
> > ...
> > endin
> >
> > instr 2
> > ...
> > Sname = chnget("Strings")
> > endin
> > results in an error:
> > INIT ERROR in instr 2 (opcode chnget.i) line 21: channel already exists
> > with incompatible type
> > #i0 chnget.i "Strings"
> >
> > When not using the functional form on the chnget it works.
> >
> > I also tried chnget:i("Strings"), but no luck. What am I doing wrong?
> >
> > Best wishes and many thanks,
> >
> > Jeanette
> >
> > --
> > * Website: http://juliencoder.de - for summer is a state of sound
> > * Youtube: jeanette_c - YouTube
> > * Audiobombs: Jeanette C.
> > * GitHub: jeanette-c · GitHub
> >
> > Top down, on the strip
> > Lookin' in the mirror
> > I'm checkin' out my lipstick <3
> > (Britney Spears)
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE
> > Send bugs reports to
> > Issues · csound/csound · GitHub
> > Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE
> Send bugs reports to
> Issues · csound/csound · GitHub
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Hi,

Thanks, Pete, I did not check. Yes, seems that chnset needs old syntax for strings This works:

schedule 1, 0, 1

instr 1

chn_S(“Strings”, 3)

chnset “Hello World”, “Strings”

Sname = chnget:S(“Strings”)

prints Sname

endin

Kontakt Pete Goodeve (<pete.goodeve@computer.org>) kirjutas kuupäeval K, 31. märts 2021 kell 11:16:

Mar 31 2021, Tarmo Johannes has written:
...

chnset "Hello World", "Strings"

...
It also works as an untyped functional statement:
chnset(Sname, "Channel")
This does not produce warnings.

Best wishes,

Jeanette

To clarify:

* chnset:S() would mean "Use the version of chnset that outputs an
S-type variable" but there are no chnset opcodes that output values,
so the error is correct.
* chnget:S() would be appropriate as there are multiple chnget opcodes
and you are specifying the one that returns an S-type variable.