Author |
Message |
XerxesV
|
Posted: Sat Jan 17, 2015 6:28 pm Post subject: 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 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Sat Jan 17, 2015 6:38 pm Post subject: RE:Scan/ update string values in Turing? |
|
|
you can read input one character at a time with getch. You can also check for individual characters inside a full string with the use of substring |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
XerxesV
|
Posted: Sun Jan 18, 2015 10:41 pm Post subject: Re: Scan/ update string values in Turing? |
|
|
Thanks for the reply
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
|
Posted: Mon Jan 19, 2015 1:44 am Post subject: 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"
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
XerxesV
|
Posted: Wed Jan 21, 2015 10:29 pm Post subject: Re: Scan/ update string values in Turing? |
|
|
Thanks Tony!!! |
|
|
|
|
|
|