Turing word highlighter only highlights the first occurrence of the word
Author |
Message |
Danyn
|
Posted: Sun Dec 15, 2013 12:34 am Post subject: Turing word highlighter only highlights the first occurrence of the word |
|
|
What is it you are trying to achieve?
Highlight all the occurrences of the word.
What is the problem you are having?
It only highlights the first occurrence of the word.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
var sent, word : string
var firstPart, secondPart : int
word := "is"
sent := "This is a test to highlight a word!"
put sent
loop
color (black)
firstPart := index (sent, word )
put sent (1 .. firstPart - 1) ..
secondPart := index (sent, word ) + length (word )
color (red)
put sent (firstPart .. secondPart - 1) ..
color (black)
put sent (secondPart .. *)
end loop
|
Please specify what version of Turing you are using
4.11 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Sun Dec 15, 2013 2:44 am Post subject: RE:Turing word highlighter only highlights the first occurrence of the word |
|
|
Because that's what you told it to do. Index only finds the first occurrence of a pattern for you. Somehow you have to find a way to make it ignore or forget the portion of the word it's already looked at. |
|
|
|
|
![](images/spacer.gif) |
evildaddy911
|
Posted: Sun Dec 15, 2013 11:06 am Post subject: RE:Turing word highlighter only highlights the first occurrence of the word |
|
|
heres a hint: try to figure out the code for index(). then use that code to make your own slightly modified version. the one i use returns an integer array instead of a single int, but you dont have to make it a function at all, just replace the result statements with other code |
|
|
|
|
![](images/spacer.gif) |
|
|