|
Post by megamushroom on Mar 17, 2005 17:38:02 GMT -5
Im feeling stupid think this should go through each line, splitting it up, but it only goes through the first line, and thats it. for (r=0;r<=3;r+=1){ if string_char_at(text,text_length) = " "{ text_line[r]= string_copy(text,1,text_length) text =string_delete(text,1,text_length) }else{ for(t=text_length;t>=1;t-=1){ if string_char_at(text,t) = " "{ text_line[r]= string_copy(text,1,t) text = string_delete(text,1,t) } break;} } }
I cant figure it out, lol Todd
|
|
|
Post by IsmAvatar on Mar 17, 2005 18:21:19 GMT -5
could you show us an example or two of ideal input/output? If we can better understand what you want this thing to do, we can better understand where it's going wrong. At first glance, i'd assume it may be something having to do with the fact that you do string_delete for text (which seems to be the key string here), but never change text_length (which seems to signify the length of 'text') Gonna take a stab at tabbing in these forums for (r = 0; r <= 3; r += 1) { if string_char_at(text,text_length) = " "{ text_line[r]= string_copy(text,1,text_length) text = string_delete(text,1,text_length) } else { for (t = text_length; t >= 1; t -= 1) { if string_char_at(text,t) = " " { text_line[r]= string_copy(text,1,t) text = string_delete(text,1,t) } break } } } ok, use the [ pre ] and [ /pre ] tags for tabbing.
|
|
|
Post by megamushroom on Mar 18, 2005 12:58:07 GMT -5
ok, i tried re setting the variable text_length to 10, but still no luck.
ideal input and output:
Input:
"Hello, this is a text demo"
Output:
Line1: Hello, Line 2: this is a Line 3 : text demo Line 4:
Hope that helps!
Todd
Ps, ive just realised, that i have to delete the space once I have found it, lol.
|
|
|
Post by IsmAvatar on Mar 18, 2005 14:58:08 GMT -5
what I was hinting at with the string_length wasn't that you should change the initial value, but you should perhaps have the code change it if you're going to change the size of the string. I mean, it does represent the length of the string, right? Or is it something else?
|
|
|
Post by megamushroom on Mar 18, 2005 20:39:27 GMT -5
it does represent the length of the string aye.
But i dont understand you. The length of the string shouldnt change, unless the space is posotionioned diferently.
Or am I misunderstanding you?
|
|
|
Post by IsmAvatar on Mar 18, 2005 21:18:38 GMT -5
how can you tell me the length of the string doesn't change?
text = string_delete(text,1,text_length) text = string_delete(text,1,t)
|
|
|
Post by megamushroom on Mar 19, 2005 14:14:08 GMT -5
i think we are both getting our wires crossed here The text_length variable determines the length of the current line. at current, it is set to ten, althought a larger number will be used in the actual game. If there is a space present at the 10th position in the string text, then deletes the part of text just used, and goes onto a different line. If there isnt a space at the 10th posistion, then it cycles downwards until it finds one, this is when text_length changes. I hope that clears it up. If it hasnt, I can always post the gmd. Todd Ps, sorry for the confusion IA: present, not resent
|
|
|
Post by IsmAvatar on Mar 20, 2005 14:48:02 GMT -5
i've located most the problem.
if the [remaining] string is shorter than 10 (text_length) it will just drop it. This is because you check for the character at a position beyond the length of the string. To cache this, i'd probably try something boolean or max() or something to check string_length, capped text_length
|
|