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

Username:   Password: 
 RegisterRegister   
 I can't seem to substring properly.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Helkain




PostPosted: Mon May 06, 2013 10:29 am   Post subject: I can't seem to substring properly.

What is it you are trying to achieve?
I am trying to break an inputted string down into individual words, by taking the index of the word for a space, and creating a new word from the previous index ( + 1) to the new index (- 1).

What is the problem you are having?
No matter how I look at this, I can't see how "The left bound of substring exceeds right bound by more than 1" -_-

Describe what you have tried to solve this problem
This has been a reocurring issue I've had for a while now. I have tried recreating the relevant code multiple times, from the ground up, using different variable configurations, and the result is always the same.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


var word : string
var seperateWords : flexible array 1 ..0 of string
var ind := 0
 loop
        exit when index (word (ind + 1 .. *), " ") = 0
        new seperateWords, upper (seperateWords) + 1
        seperateWords (upper (seperateWords)) := word (ind .. index (word (ind + 1 .. *), " ") - 1)
        ind := index (word (ind .. *), " ") + 1
    end loop





Please specify what version of Turing you are using
Good ol' buggy 4.11


Thanks in advance oh benevolent code monkeys who inhabit this forum!
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Mon May 06, 2013 11:04 am   Post subject: RE:I can\'t seem to substring properly.

Try adding some debug output to figure out the values of your function calls. Eg:

Turing:

var word : string := "glsadf afsg fdsg dsf gdsfg "
var seperateWords : flexible array 1 .. 0 of string
var ind := 0
loop
    exit when index (word (ind + 1 .. *), " ") = 0
    put "ind + 1 = ", ind + 1
    put "word (ind + 1 .. *) = ", word (ind + 1 .. *)
    put "index (word (ind + 1 .. *), \" \") = ", index (word (ind + 1 .. *), " ")
    new seperateWords, upper (seperateWords) + 1
    seperateWords (upper (seperateWords)) := word (ind .. index (word (ind + 1 .. *), " ") - 1)
    ind := index (word (ind .. *), " ") + 1
end loop
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  [ 2 Posts ]
Jump to:   


Style:  
Search: