
-----------------------------------
XerxesV
Sat Jan 17, 2015 6:28 pm

Scan/ update string values in Turing?
-----------------------------------
What is it you are trying to achieve?
I am trying to create a program in Turing which gets a string value from the user
and updates itself to another string value. For example if the user inputs "qwerty", 
then the program shows "xfando". I know how to do this using if statements and assigning variables,
I can't do this is the value the user inputs is more than one letter.

What is the problem you are having?
I know you can scan and update string values in java, but I was wondering if there is any 
simmilar command that I can use to scan and update strings in Turing. 








Please specify what version of Turing you are using
v4.1.1

-----------------------------------
Tony
Sat Jan 17, 2015 6:38 pm

RE:Scan/ update string values in Turing?
-----------------------------------
you can read input one character at a time with [tdoc]getch[/tdoc]. You can also check for individual characters inside a full string with the use of [tdoc]substring[/tdoc]

-----------------------------------
XerxesV
Sun Jan 18, 2015 10:41 pm

Re: Scan/ update string values in Turing?
-----------------------------------
Thanks for the reply  :D 
Can you give be a basic description of how I would use substring to change string values?

For example if the user enters "rammu", how would I make the program reorganize it to "hello"?

-----------------------------------
Tony
Mon Jan 19, 2015 1:44 am

RE:Scan/ update string values in Turing?
-----------------------------------
You said that you know how to do this for one letter, so do it one letter at a time.

[code]
var word : string := "rammu"
put word(1) # letter 'r'
put word(2) # letter 'a'

var left_idx : int : = 3
var right_idx : int := 5
put word(left_idx .. right_idx) # "mmu"
[/code]

-----------------------------------
XerxesV
Wed Jan 21, 2015 10:29 pm

Re: Scan/ update string values in Turing?
-----------------------------------
Thanks Tony!!!   :D
