Discuss Scratch

codeman1044
Scratcher
1000+ posts

letter # of () in ()

Anybody like this? The block would look like this:
(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?

Last edited by Tallented-Code-bot (May 18, 2019 15:53:40)

Za-Chary
Scratcher
1000+ posts

letter # of () in ()

14152cool wrote:

support, if it doesn't fart itself upon an input like this:
(letter # of [c] in [scratch]::operators)
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.

Tallented-Code-bot wrote:

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?
It would just output the first instance, I think. If it did not exist, it might return 0 — what does the list version do?
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 ()

coder2045 wrote:

What would these return?
(letter # of (e) in [world]::operators)
(letter # of (e) in [NilsTheBest]::operators)
(letter # of (foo) in [abc123abc]::operators)
0
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 ()

StrangeMagic32 wrote:

0
7
if foo = a, b, c, 1, 2, or 3, then it would be 1, 2, 3, 4, or 5
You missed 6 for the c.
sorry, I had to.
StrangeMagic32
Scratcher
1000+ posts

letter # of () in ()

codeman1044 wrote:

StrangeMagic32 wrote:

0
7
if foo = a, b, c, 1, 2, or 3, then it would be 1, 2, 3, 4, or 5
You missed 6 for the c.
sorry, I had to.
oops, thanks xD
BosenChang
Scratcher
1000+ posts

letter # of () in ()

Wow, support! This would help scratch projects a lot!
Cooorupt
Scratcher
25 posts

letter # of () in ()

SpacePirate80 wrote:

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:
Set [foo2 v] to (letter # of (foo1) in (answer)::operators)
instead of
Find letter # of (foo1) in (answer)::custom
Set [foo2 v] to (location of char in string)
Not 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.
Seth_Zaw
Scratcher
100+ posts

letter # of () in ()

Vanilla2011
Scratcher
500+ posts

letter # of () in ()

Seth_Zaw wrote:

Duplicate
They 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 ()

SpacePirate80 wrote:

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.
How to make the vars purple:
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!
_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.

Last edited by _Icicle-Cube_ (Dec. 1, 2022 00:11:50)

An0therRand0mC0der
Scratcher
1000+ posts

letter # of () in ()

_Icicle-Cube_ wrote:

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.
How is this not relevant? The suggestion isn't resolved.
_Icicle-Cube_
Scratcher
500+ posts

letter # of () in ()

An0therRand0mC0der wrote:

_Icicle-Cube_ wrote:

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.
How is this not relevant? The suggestion isn't resolved.
my bad, still it feels kinda wrong to talk in a topic made 3 - 4 years ago
Eletiva_ilp_29
Scratcher
50 posts

letter # of () in ()

support ! :: reporter sensing

Powered by DjangoBB