New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text is not a function #1314

Closed
SaintPepsi opened this Issue Mar 22, 2016 · 8 comments

Comments

Projects
None yet
6 participants
@SaintPepsi

SaintPepsi commented Mar 22, 2016

I might not be a pro at coding but i do know that i've used this function yesterday and i think around 14^14 times and nothing changed since yesterday. is it my fault or is this something that's wrong in p5?

full details:

draw @ sketch.js:71
p5.redraw @ p5.js:16412
(anonymous function) @ p5.js:11813
(anonymous function) @ p5.js:11714
p5 @ p5.js:11976
_globalInit @ p5.js:8482

the p5.js editor gives a different error:
72: Uncaught TypeError: string is not a function

The line of code that's being the problem:
text("test",100,200);

@dhowe

This comment has been minimized.

Show comment
Hide comment
@dhowe

dhowe Mar 22, 2016

Contributor

can you include the simplest bit of code that demonstrates the problem, and also list the version of p5.js you're using? thanks

Contributor

dhowe commented Mar 22, 2016

can you include the simplest bit of code that demonstrates the problem, and also list the version of p5.js you're using? thanks

@SaintPepsi

This comment has been minimized.

Show comment
Hide comment
@SaintPepsi

SaintPepsi Mar 22, 2016

p5 version : 0.4.23
This is where the text function is:

function draw() {
    background(210,210,210);
    fill(0,0,0,100);
    textSize(15);
    for (var i = 0; i < population.length; i++) {
       text("test",100,200);
    }
}

SaintPepsi commented Mar 22, 2016

p5 version : 0.4.23
This is where the text function is:

function draw() {
    background(210,210,210);
    fill(0,0,0,100);
    textSize(15);
    for (var i = 0; i < population.length; i++) {
       text("test",100,200);
    }
}
@pete-rai

This comment has been minimized.

Show comment
Hide comment
@pete-rai

pete-rai Mar 22, 2016

Do you perhaps have a name clash between a variable in global scope and a p5 method? This will generate the very error you see.

pete-rai commented Mar 22, 2016

Do you perhaps have a name clash between a variable in global scope and a p5 method? This will generate the very error you see.

@tafsiri

This comment has been minimized.

Show comment
Hide comment
@tafsiri

tafsiri Mar 22, 2016

Contributor

I think @pete-rai is correct, a line like text += possible.charAt(Math.floor(Math.random() * possible.length)); would effectively overwrite the text function by converting it to a string (and appending some stuff to it).

Contributor

tafsiri commented Mar 22, 2016

I think @pete-rai is correct, a line like text += possible.charAt(Math.floor(Math.random() * possible.length)); would effectively overwrite the text function by converting it to a string (and appending some stuff to it).

@SaintPepsi

This comment has been minimized.

Show comment
Hide comment
@SaintPepsi

SaintPepsi Mar 22, 2016

What @tafsiri says is right. I think I have something like that in my code I didn't realise that would break it.

SaintPepsi commented Mar 22, 2016

What @tafsiri says is right. I think I have something like that in my code I didn't realise that would break it.

@lmccart

This comment has been minimized.

Show comment
Hide comment
@lmccart

lmccart Mar 22, 2016

Member

thanks all for your help debugging. maybe there is some warning we could raise if a user tries to overwrite a p5 function? or maybe we just need more documentation making it clear this will break things. cc @toolness

Member

lmccart commented Mar 22, 2016

thanks all for your help debugging. maybe there is some warning we could raise if a user tries to overwrite a p5 function? or maybe we just need more documentation making it clear this will break things. cc @toolness

@SaintPepsi

This comment has been minimized.

Show comment
Hide comment
@SaintPepsi

SaintPepsi Mar 22, 2016

Wow this community is really awesome :o,
I guess what I did is good then in a way? Because finding bugs or problems is really nice
(My first time on github)

SaintPepsi commented Mar 22, 2016

Wow this community is really awesome :o,
I guess what I did is good then in a way? Because finding bugs or problems is really nice
(My first time on github)

@toolness

This comment has been minimized.

Show comment
Hide comment
@toolness

toolness Mar 22, 2016

Member

I guess what I did is good then in a way?

Absolutely!! I really like it when problems like this are reported b/c it makes us brainstorm ways we can help ensure that users of p5 don't get frustrated in the future 😁

P.S. - Welcome to Github and p5!

Member

toolness commented Mar 22, 2016

I guess what I did is good then in a way?

Absolutely!! I really like it when problems like this are reported b/c it makes us brainstorm ways we can help ensure that users of p5 don't get frustrated in the future 😁

P.S. - Welcome to Github and p5!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment