Discuss Scratch

Bfoot
Scratcher
11 posts

How to split up a variable??

So I'm making a project where I use a piece of code that pretty much does this:

set [(variable)] to [ (join (variable) [1234] 

My problem now is that I can't UNDO this.How do I take

[ (join (variable) [1234] 

and take the 1234 back OUT of the
 (variable) 
?

I don't know if this makes sense but I need help!

P.S.: The value of
 (variable) 
is a number, not a string, if there's some sort of mathematical solution that helps.

Last edited by Bfoot (Oct. 21, 2014 01:30:58)


“I am not a robot. I am a unicorn.” -Cleverbot

Talk to Cleverbot at http://www.cleverbot.com/

See my chatbot at http://scratch.mit.edu/projects/25683479/
drmcw
Scratcher
1000+ posts

How to split up a variable??

You should be able to find what you need in here http://scratch.mit.edu/projects/18838153/

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
MiniWoofGaming
Scratcher
81 posts

How to split up a variable??

so do you want to take the 1234 out of the variable? if you do then this code might help
set [letter v] to [0 ]
repeat until <[letter] = [ 1]>

if <not<(letter (letter) of [variable])>> = [ 1] then

change [letter v] by (1)
end
set [letter2 v] to [0 ]
repeat (letter)

set [variable2 v] to (join (variable2) (letter (letter2) of (variable))
change [letter2 v] by (1)
end

end

Last edited by MiniWoofGaming (Oct. 6, 2014 10:27:06)




theonlygusti
Scratcher
1000+ posts

How to split up a variable??

If the 1234 is definitely at the end of the variable, then this is a really easy way to do it:

set [c v] to (1)
repeat ((length of (variable)) - (4))
set [var v] to (letter (c) of (variable))
change [c v] by (1)
end
set [variable v] to (var)

Bfoot
Scratcher
11 posts

How to split up a variable??

@theonlygusti:

Thank you so much! After a bit of tweaking this was exactly what I needed. This took me so long!



I hope you'll check out my chatbot when I'm done with it!

“I am not a robot. I am a unicorn.” -Cleverbot

Talk to Cleverbot at http://www.cleverbot.com/

See my chatbot at http://scratch.mit.edu/projects/25683479/

Powered by DjangoBB