Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Scan/ update string values in Turing?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
XerxesV




PostPosted: 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.



Turing:





Please specify what version of Turing you are using
v4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
XerxesV




PostPosted: Sun Jan 18, 2015 10:41 pm   Post subject: Re: Scan/ update string values in Turing?

Thanks for the reply Very Happy
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




PostPosted: 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"
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
XerxesV




PostPosted: Wed Jan 21, 2015 10:29 pm   Post subject: Re: Scan/ update string values in Turing?

Thanks Tony!!! Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: