Csound Csound-dev Csound-tekno Search About

[Csnd] tell if p-parameter is string or number?

Date2019-03-12 14:24
FromRory Walsh
Subject[Csnd] tell if p-parameter is string or number?
Anyone know if there is an easy way to tell if a p-field argument is a string or a number? 
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

Date2019-03-12 14:39
Fromjoachim heintz
SubjectRe: [Csnd] tell if p-parameter is string or number?
i just tried this which seems to work except for an empty string:

instr test
  if(strlen(strget(p4))==0) then
   puts "p4 is a number", 1
  else
   puts "p4 is a string", 1
  endif
endin
schedule("test",0,0,1)
schedule("test",0,0,"1")

can't you require a string and in case convert it to a number via strtod?

	joachim



On 12/03/19 15:24, Rory Walsh wrote:
> Anyone know if there is an easy way to tell if a p-field argument is a
> string or a number?
> 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

Date2019-03-12 14:43
FromGuillermo Senna
SubjectRe: [Csnd] tell if p-parameter is string or number?
An easy way to tell... feed it to printf. If it segfaults, then it's the
other one. :-D

On 12/3/19 11:24, Rory Walsh wrote:
> Anyone know if there is an easy way to tell if a p-field argument is a
> string or a number?
>
> 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

Date2019-03-12 15:05
FromRory Walsh
SubjectRe: [Csnd] tell if p-parameter is string or number?
Thanks Joachim. Both solutions you suggest will work fine ;) And thanks to you Guillermo for causing me to erupt in spontaneous laughter! 

On Tue, 12 Mar 2019 at 14:39, joachim heintz <jh@joachimheintz.de> wrote:
i just tried this which seems to work except for an empty string:

instr test
  if(strlen(strget(p4))==0) then
   puts "p4 is a number", 1
  else
   puts "p4 is a string", 1
  endif
endin
schedule("test",0,0,1)
schedule("test",0,0,"1")

can't you require a string and in case convert it to a number via strtod?

        joachim



On 12/03/19 15:24, Rory Walsh wrote:
> Anyone know if there is an easy way to tell if a p-field argument is a
> string or a number?
> Csound mailing list Csound@listserv.heanet.ie
> <mailto: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

Date2019-03-15 09:30
FromEnrico Francioni <00000005323c8739-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] tell if p-parameter is string or number?
hi Rory,
I know well that it is not good to ask you here ... but, if it is possible,
I would like to be contacted by you at my e-mail address
[francioni61021@libero.it] to ask you about things regarding the next
ICSC2019 that will take place in Italy.

Thank you, see you soon,
Enrico Francioni
francioni61021@libero.it



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-03-15 09:31
FromRory Walsh
SubjectRe: [Csnd] tell if p-parameter is string or number?
Of course. Contract me any time.

On Fri 15 Mar 2019, 09:31 Enrico Francioni, <00000005323c8739-dmarc-request@listserv.heanet.ie> wrote:
hi Rory,
I know well that it is not good to ask you here ... but, if it is possible,
I would like to be contacted by you at my e-mail address
[francioni61021@libero.it] to ask you about things regarding the next
ICSC2019 that will take place in Italy.

Thank you, see you soon,
Enrico Francioni
francioni61021@libero.it



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-03-15 10:05
FromEnrico Francioni <00000005323c8739-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] tell if p-parameter is string or number?
Thanks Rory,
but should I write here ..., or can I have your own private e-mail address?

Thanks bye!
Enrico



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-03-15 10:07
FromRory Walsh
SubjectRe: [Csnd] tell if p-parameter is string or number?
I just wrote you a mail now..I hope I have the correct address...

On Fri, 15 Mar 2019 at 10:05, Enrico Francioni <00000005323c8739-dmarc-request@listserv.heanet.ie> wrote:
Thanks Rory,
but should I write here ..., or can I have your own private e-mail address?

Thanks bye!
Enrico



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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