Grouping by Name Not Grouping Correctly
Author |
Message |
hamid14
![](http://compsci.ca/v3/uploads/user_avatars/12047066924bcf67a12efdb.png)
|
Posted: Wed Jan 20, 2010 7:48 pm Post subject: Grouping by Name Not Grouping Correctly |
|
|
I have turing version 4.1. My problem is that my grouping code is not working. I am still not sure how the index command works. If someone can explain it to me better it would be great.
i did something like this, every name ends up in group 1
var name : string
get name
if index ("a".name) not=0 then
put "You are in group 1
end if
Thanks in advance. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: Wed Jan 20, 2010 8:17 pm Post subject: Re: Grouping by Name Not Grouping Correctly |
|
|
That program (well, that program with the typos fixed) does not put everyone into group 1... In fact, it won't put anybody in group 1 unless they enter "a" as their name.
the index (sourceString, searchString) command works by looking for the first occurrence of searchString in sourceString, and then returning the index of the first character that string occurred at (or 0 if it wasn't found at all).
For example, index("this is a string","a") would return 9, since "a" is first found in "this is a string" at character 9. index("string goes here", "a") would return 0, since "a" is not found in "string goes here".
In case you don't have it, the documentation can be found here: index |
|
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Wed Jan 20, 2010 8:29 pm Post subject: RE:Grouping by Name Not Grouping Correctly |
|
|
You have to use something like:
Turing: | get name : *
if index (name, "a") not = 0 then
put "You are in group 1"
end if |
|
|
|
|
|
![](images/spacer.gif) |
|
|