Computer Science Canada Substring error message |
Author: | Adalias [ Thu Jan 11, 2007 10:58 am ] | ||
Post subject: | Substring error message | ||
I am making a word processor program that takes in a chunk of text and justifies it left, center, right, full, and snake (like a newspaper). I haven’t gotten very far but here’s what I’ve got:
I know you're probably seeing a lot of errors and ways to make it better and whatnot, but all I need help with is this one error. Run it the way it is and it will work, asking for the type of justification (left is the only one I've got atm) and length of the lines (I use 20), but right after entering the line it crashes with the error: Left bound of substring exceeds right by more than 1. While highlighting line 18 if (length (current) + length (line (i .. j))) <= col then I'm sure there is a very simple answer to this problem but try as I might I just can't seem to find it. Any help would be appreciated |
Author: | Ultrahex [ Thu Jan 11, 2007 9:53 pm ] | ||
Post subject: | Re: Substring error message | ||
your instructions on how to use the program were not very well i was confused about what it meant by "Enter the line you would like to justify" anyhow... Ok, the problem occurs because you cant have 20 lines of text for a sentence that is only 20 long. or something like that, you are trying to justify it left???
That is how i would attempt to do, BTW i made it so it writes that last word still and when it gets to next space it goes to next line, however you could do it the otherway and backtrace. |
Author: | Clayton [ Thu Jan 11, 2007 10:14 pm ] |
Post subject: | Re: Substring error message |
Your error means that the left or lower bound of your substring (the length(current (i..j))) is greater than the upper or right bound of the substring. In other words, i becomes higher than j, and that's not good, I think you want to have it the other way around ( length(current(j..i)) ) |
Author: | [Gandalf] [ Fri Jan 12, 2007 6:11 pm ] | ||
Post subject: | RE:Substring error message | ||
Or alternatively and more flexibly:
|
Author: | Adalias [ Wed Jan 17, 2007 2:09 pm ] |
Post subject: | Re: Substring error message |
Thanks Ultrahex that helped alot. |