Discuss Scratch
- Discussion Forums
- » Suggestions
- » letter # of () in ()
- codeman1044
-
Scratcher
1000+ posts
letter # of () in ()
Anybody like this? The block would look like this:
Support?
(letter # of () in ()::operators)And it would function kind of like this:
(item # of () in [list v]::list)Where it would return a number based on the position of the letter in a string. For example:
(letter # of [a] in [scratch]::operators)would return 4.
Support?
- 14152cool
-
Scratcher
100+ posts
letter # of () in ()
support, if it doesn't fart itself upon an input like this:
(letter # of [c] in [scratch]::operators)
- Tallented-Code-bot
-
Scratcher
100+ posts
letter # of () in ()
What would happen if either the letter you were asking about did not exist, or if it happened more than once. if the letter happened more than once,ll
would it output something like this: 1,3,5, or would it return an error? If the letter did not exist, would it output 0?
would it output something like this: 1,3,5, or would it return an error? If the letter did not exist, would it output 0?
Last edited by Tallented-Code-bot (May 18, 2019 15:53:40)
- Za-Chary
-
Scratcher
1000+ posts
letter # of () in ()
support, if it doesn't fart itself upon an input like this:If it works anything like the list version does, this block would return “2” because it's the first instance of “c” that is used in that string.(letter # of [c] in [scratch]::operators)
What would happen if either the letter you were asking about did not exist, or if it happened more than once. if the letter happened more than once,llIt would just output the first instance, I think. If it did not exist, it might return 0 — what does the list version do?
would it output something like this: 1,3,5, or would it return an error? If the letter did not exist, would it output 0?
- codeman1044
-
Scratcher
1000+ posts
letter # of () in ()
The list version returns 0, which really helpful sometimes when you're using code that waits until the item # of something isn't 0.
- coder2045
-
Scratcher
1000+ posts
letter # of () in ()
What would these return?
(letter # of (e) in [world]::operators)
(letter # of (e) in [NilsTheBest]::operators)
(letter # of (foo) in [abc123abc]::operators)
- StrangeMagic32
-
Scratcher
1000+ posts
letter # of () in ()
What would these return?0(letter # of (e) in [world]::operators)
(letter # of (e) in [NilsTheBest]::operators)
(letter # of (foo) in [abc123abc]::operators)
7
if foo = a, b, c, 1, 2, or 3, then it would be 1, 2, 3, 4, 5, or 6
Last edited by StrangeMagic32 (May 23, 2019 22:36:25)
- codeman1044
-
Scratcher
1000+ posts
letter # of () in ()
0You missed 6 for the c.
7
if foo = a, b, c, 1, 2, or 3, then it would be 1, 2, 3, 4, or 5
sorry, I had to.
- StrangeMagic32
-
Scratcher
1000+ posts
letter # of () in ()
oops, thanks xD0You missed 6 for the c.
7
if foo = a, b, c, 1, 2, or 3, then it would be 1, 2, 3, 4, or 5
sorry, I had to.
- BosenChang
-
Scratcher
1000+ posts
letter # of () in ()
Wow, support! This would help scratch projects a lot!
- Cooorupt
-
Scratcher
25 posts
letter # of () in ()
This is pretty cool. It would be helpful but it's fairly easy to work around.define Find letter # of (char) in (string)set [ i] to [1]repeat (length of (string))
if <(letter (i) of (string)) = (char)> then
set [location of char in string] to (i)
stop [ this script]
end
change [i] by (1)
end
I tested it and it works perfectly everytime. It only works if you only put in one character. (I couldn't get(char)and(string)to become purple so just pretend they are)
Although, it would be pretty nice just to have a block to do that for us.
Thanks for the workaround!
- codeman1044
-
Scratcher
1000+ posts
letter # of () in ()
I completely forgot I had made this post. This is over a year old!
The workaround works fine, but it isn't directly a reporter. When I made this, I was thinking of something like this:
The workaround works fine, but it isn't directly a reporter. When I made this, I was thinking of something like this:
Set [foo2 v] to (letter # of (foo1) in (answer)::operators)instead of
Find letter # of (foo1) in (answer)::customNot much of an inconvinience, but it would be like having the (item # of () in ()) reporter compared to not having it, so it would still be nice.
Set [foo2 v] to (location of char in string)
- Vanilla2011
-
Scratcher
500+ posts
letter # of () in ()
DuplicateThey didn't duplicate ur post. U duplicated their post. This thread's URL number is smaller, therefore, u should redirect ur thread to this thread and close it.
Last edited by Vanilla2011 (Sept. 5, 2020 03:29:47)
- Vanilla2011
-
Scratcher
500+ posts
letter # of () in ()
This is pretty cool. It would be helpful but it's fairly easy to work around.How to make the vars purple:define Find letter # of (char) in (string)set [ i] to [1]repeat (length of (string))
if <(letter (i) of (string)) = (char)> then
set [location of char in string] to (i)
stop [ this script]
end
change [i] by (1)
end
I tested it and it works perfectly everytime. It only works if you only put in one character. (I couldn't get(char)and(string)to become purple so just pretend they are)
Although, it would be pretty nice just to have a block to do that for us.
define Find letter # of (char) in (string)
set [ i] to [1]//Don't put a pause in the blocks here.
repeat (length of (string))
if <(letter (i) of (string)) = (char)> then
set [location of char in string v] to (i)
stop [this script v]
end
change [i] by (1)
end
- Knightbot63
-
Scratcher
1000+ posts
letter # of () in ()
removed the python code
Bump, or Bring Up This Post!
Bump, or Bring Up This Post!
- _Icicle-Cube_
-
Scratcher
500+ posts
letter # of () in ()
erm guys, don't you think we're necroposting?
we're bumping a topic from *2019 that isn't that relevant
edit, I meant 2019, not 2020.
we're bumping a topic from *2019 that isn't that relevant
edit, I meant 2019, not 2020.
Last edited by _Icicle-Cube_ (Dec. 1, 2022 00:11:50)
- An0therRand0mC0der
-
Scratcher
1000+ posts
letter # of () in ()
erm guys, don't you think we're necroposting?How is this not relevant? The suggestion isn't resolved.
we're bumping a topic from *2019 that isn't that relevant
edit, I meant 2019, not 2020.
- _Icicle-Cube_
-
Scratcher
500+ posts
letter # of () in ()
my bad, still it feels kinda wrong to talk in a topic made 3 - 4 years agoerm guys, don't you think we're necroposting?How is this not relevant? The suggestion isn't resolved.
we're bumping a topic from *2019 that isn't that relevant
edit, I meant 2019, not 2020.
- Discussion Forums
- » Suggestions
-
» letter # of () in ()