
-----------------------------------
uberwalla
Fri Nov 24, 2006 8:24 pm

i was wondering if...
-----------------------------------
ok so i was wondering if it is possible to kinda "clean" a sentence in turing.
like im not talking encoding//decoding but... is there a way to take out all symbols and numbers etc from writing. 

example:
u input something like "%h&i!Per^$son
and then it outputs "hiperson"

is that possible to do at all. i am interested cuz i want to make a game where the program inputs random letters, symbols, etc type thing and you have to decode type thing. it seems very lame, and yes it is but i want to do this for a start then id build on it after. 

help would be very appreciated :D! thx.

-----------------------------------
jamonathin
Fri Nov 24, 2006 8:57 pm


-----------------------------------
Very possible.  You are going to want to refer to ASCII codes.  Basically ASCII links a value to each letter.

hit F10 in turing, search for "run window character set" and it will bring up a list of each value of each symbol/letter (character).

You will notice that the capital letters range from 65-90 and lower case letters range from 97-122.

Also look up chr and ord in turing help.  You will also need string manipulation - help can be found in the Turing Walkthrough.

If you need help with it, post your code and we can help you out (without giving the answer :wink:)

-----------------------------------
uberwalla
Fri Nov 24, 2006 9:25 pm


-----------------------------------
ok thx a bunch. i already new about the letter/number thing but im kinda wondering if its possible to do like.

if char not= x-x then
...

can x be the letters designated chr number? and have it asign that way then have it somehow remove the numbers?

-----------------------------------
jamonathin
Wed Nov 29, 2006 11:42 pm


-----------------------------------
can x be the letters designated chr number? and have it asign that way then have it somehow remove the numbers?

Im not shure I fully understand what you're asking. The first question (before the and) makes me think your asking if you can reassign the value of the character to the value of 'x' - which is no.  And then i dont know what you mean by 'removing the numbers'. :?

-----------------------------------
jamonathin
Wed Nov 29, 2006 11:43 pm


-----------------------------------
Also if you could clarify what this means

if char not= x-x then 


if char not= 0?

-----------------------------------
Cervantes
Thu Nov 30, 2006 1:02 am


-----------------------------------
I think he's asking if he can do a check in that form to test whether char is within the range x to y, where x and y are his x and... x.

The answer is no.

uberwalla, you've already got a [url=http://www.compsci.ca/v2/viewtopic.php?t=14286]thread for this problem. Please explain why this extra topic was necessary, and how this topic is different (wasn't the question answered fully in your first topic?).

-----------------------------------
uberwalla
Thu Nov 30, 2006 8:28 am


-----------------------------------
o sry that was a later post when i half solved the problem then u helped meh :P thx though guys

-----------------------------------
ZeroPaladn
Thu Nov 30, 2006 9:06 am


-----------------------------------
I think he's asking if he can do a check in that form to test whether char is within the range x to y, where x and y are his x and... x.

The awnser is no.

The awnser is YES!

[code]for i : x .. y %just an example
    if letter ~= i then
        %put whatever happens here
    end if
end for

-----------------------------------
Clayton
Thu Nov 30, 2006 11:20 am


-----------------------------------
err no, if letter is a string, that code wont even run, but what Cervantes was saying that :


I think he's asking if he can do a check in that form


in which you cant.

-----------------------------------
Cervantes
Thu Nov 30, 2006 1:13 pm


-----------------------------------
I think he's asking if he can do a check in that form to test whether char is within the range x to y, where x and y are his x and... x.

The awnser is no.

The awnser is YES!

for i : x .. y %just an example
    if letter ~= i then
        %put whatever happens here
    end if
end for

The answer is no, because of the restriction on form.

Now, you need to understand something about your code. It won't work anywhere close to the way it was designed to. Try tracing it, to see why.

Here's what happens. You start with i as x. If letter not= i, then we perform our action, A. Then i = x+1. If letter not= i+1, we do A. See where this is going? We are very likely going to perform A many times, even if letter does happen to be in the range x to y.

To code this properly, we use inequalities:

if letter < x or letter > y then
    A
end if


-----------------------------------
NikG
Thu Nov 30, 2006 2:45 pm


-----------------------------------
There's an even easier solution than what everyone has talked about so far.

1. Create a string with all the letters (a-z, A-Z)
2. Create a for loop going through each character in the text where the symbols will be removed
3. Check whether each character is in the string (I believe the index function)
3. If the character is found, add it to a new string.

No need to mess with ascii tables or anything.

-----------------------------------
Clayton
Thu Nov 30, 2006 3:41 pm


-----------------------------------
yes, but then you are using up extra memory by creating that string variable to hold all of the acceptable characters, not something you want to do.

-----------------------------------
uberwalla
Thu Nov 30, 2006 3:48 pm


-----------------------------------

%The "Palindrome" Program
%By: Mike Lanthier
%Monday, November 28, 2006
function clean (x : string) : string
    var CleanedWord := ""
    for i : 1 .. length (x)
        if x (i) >= chr (97) and x (i) = chr (65) and x (i) = chr (97) and x (i) = chr (65) and x (i) = 'a' and x (i) = 'A' and x (i) = 'a' and x(i) = 'a' and x(i) = 97 but 