This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-11-19 12:28:27

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Variable Punctuation

"""""""""""""""""""""""
How do i change a variable/item of a list to add punctuation, in my project Chatroom X 1.0
"""""""""""""""""""""""
eg.something like this
"""""""""""""""""""""""


//punctuation is (.) , (?) And (!) in this case 
when gf clicked
set [word v] to []
forever
ask [Type a sentence in here.] and wait
set [word v] to (answer)
if<<not<[punctuation v] contains (letter (length of (word)) of (word))>>>//if punctuation doesn't contain letter <length of word> of word .This checks if the last letter is a . , ? Or !
set [word v] to (join (word) [.])//can be any other end punctuation mark
end
//note! I've tried this and it doesn't work please help me.

Last edited by Ideas (2012-11-20 08:36:57)


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

#2 2012-11-19 13:26:29

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: Variable Punctuation

I would try:

if <not <(letter (length of (word)) of (word)) = [.]>>
set [word v] to (join (word) [.])
And put an 'or' block after it to check for [!] and [?] too.

Last edited by Prestige (2012-11-19 13:30:26)


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#3 2012-11-19 16:56:57

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Variable Punctuation

Ideas wrote:

"""""""""""""""""""""""
How do i change a variable/item of a list to add punctuation, in my project Chatroom X 1.0
"""""""""""""""""""""""
eg.something like this
"""""""""""""""""""""""


//punctuation is (.) , (?) And (!) in this case 
when gf clicked
set [word v] to []
forever
ask [Type a sentence in here.] and wait
set [word v] to (answer)
if<<not<[punctuation v] contains (letter (length of (word)) of (word))>>>
set [word v] to (join (word) [.])//can be any other end punctuation mark
end
do something with the word

Fixed. It should work, as long as the list "punctuation" actually DOES have all the punctuation you need to check.

if you gave us a project link it might help.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4 2012-11-20 08:39:07

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Variable Punctuation

Fixed and edited


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

#5 2012-11-20 10:35:35

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Variable Punctuation

How do you edit one letter in the middle of the sentence(This is how I do it.)

eg. If an I is in lower case like this-i, then change it to upper case


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

#6 2012-11-25 14:49:49

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Variable Punctuation

Bump


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

#7 2012-11-25 15:11:17

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: Variable Punctuation

Well, for the "i" turns into "I" example, or anything else involving a letter being edited, you could scan the sentence. For instance, with the "I" example:

set [words1 v] to []
set [on v] to (1)
repeat (length of (word))
if <<(letter (on) of (word)) = (i)> and <(letter ((on) + (1)) of (word)) = [ ]>> //a space
set [on1 v] to (0)
repeat (on)
change [on1 v] by (1)
set [words1 v] to (join (words1) (letter (on1) of (words)))
end
set [words1 v] to (join (words1) [i])
end
end
set [words v] to (words1)
This should work. It looks at each letter of the sentence to see if it's "i". Hope it helps!


http://i48.tinypic.com/2072ctw.gif

Offline

 

#8 2012-11-27 15:45:30

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Variable Punctuation

What is

(word)
initial value and when is it set?
Please respond


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

Board footer