| I get an init error in both cases when there is no p4 (for example). No difference.
opcode setget,k,i
pfield:i xin
chnidx:S = sprintf("%.02f_p%d", p1, pfield)
fieldvalue:i = pindex(pfield)
print(pfield)
chnset(fieldvalue,chnidx)
value@global:k = chnget(chnidx)
xout(value)
puts(chnidx, 1)
endop
opcode setget2(pfield:i):(k)
chnidx:S = sprintf("%.02f_p%d", p1, pfield)
fieldvalue:i = pindex(pfield)
print(pfield)
chnset(fieldvalue,chnidx)
value@global:k = chnget(chnidx)
xout(value)
puts(chnidx, 1)
endop
instr 1
k1 = setget(4)
endin
instr 2
k1 = setget2(4)
endin
====
SECTION 1:
new alloc for instr 1:
INIT ERROR in instr 1 (opcode setget) line 12: invalid p field index
from file test.csd (1)
fieldvalue:i pindex pfield:i
B 0.000
INIT ERROR in instr 1: note deleted (1 init errors)
new alloc for instr 2:
INIT ERROR in instr 2 (opcode setget2) line 22: invalid p field index
from file test.csd (1)
fieldvalue:i pindex pfield:i
B 0.000
INIT ERROR in instr 2: note deleted (1 init errors)
end of Performance
> On 25 Apr 2026, at 15:25, Jean Basile Sosa wrote:
>
> Indeed the pindex argument is not valid, but only when I use the new syntax then I'm returning to my misunderstanding.
>
> Add a print for the pindex argument into the setget UDO (old syntax) = both chnidx and pfield seems set correctly evenf if I get a warning message ("warning: instr 1 uses 3 p-fields but is given n")
>
> After check setget2 (new syntax) first I've to comment some lines so that the code runs without errors.
>
> opcode setget2(pfield:i):(k)
> chnidx:S = sprintf("%.02f_p%d", p1, pfield)
> //fieldvalue:i = pindex(pfield)
> print(pfield)
> //chnset(fieldvalue,chnidx)
> value@global:k = chnget(chnidx)
> xout(value)
> puts(chnidx, 1)
> endop
>
> Then I notice that the inargs (pfield:i) which is the pindex argument too, print 0 and is not at all init. Of course same thing to the chnidx:S = sprintf("%.02f_p%d", p1, pfield): the end of the string is set at 0.
>
> In fact, I'm trying to init the chnset before the chnget like that: chnset(pfield, Sname).
>
> So, setget(4) should do for example: chnset(p4, sname) — and snSnameme here is done by the sprintf.
>
> I've already declared chnset like that in a very old udo, using directly the pfield in place of the efficient value, for exemple: chnset p4, Sname
>
> After your response, I've tried to write a secondary sprintf just to pass the first argument of chnset, then something like that: chnval:S = sprintf("p%d", pfield), but this causes an error that I can understand (first argument of chnset is interpredted as a string)...
>
>
>
>
> 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
The information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.
Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.
Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig dataprotection@mu.ie agus scrios an ríomhphost seo ó do chóras.
Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.
Registered charity number 20037130
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
|