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

Username:   Password: 
 RegisterRegister   
 REALLY LONG TEXT "Formatting"
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nate




PostPosted: Mon Apr 14, 2003 5:45 pm   Post subject: REALLY LONG TEXT "Formatting"

I am wondering what how you would use a procedure and make a 3 - 5 not have anywords cut off when they reached the end of the run window. I want the text to wrap after the 40th character?
How do I do that?
What is the code?

Any help would be greatly apreciated

-Nate
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Mon Apr 14, 2003 5:48 pm   Post subject: (No subject)

it auto-wraps for me.... like if i went
code:
put "mumbo jumbo blah blah blah blah choclolate milk with sweet bunnies and carried on like this for hundreds and hundreds of characters damn i cant think of anything to ramble on about ok i'm done"

if that isnt what you mean, then please specify
nate




PostPosted: Mon Apr 14, 2003 5:51 pm   Post subject: (No subject)

No becuase when you type something very long it will cut off some of the words if they are near the end. I wan't it to cut off after 40 characters. Do you know how 2 do that?

-Nate
LOOK BELOW FOR REAL QUESTION!!!!
nate




PostPosted: Mon Apr 14, 2003 5:53 pm   Post subject: MY MISTAKE

How do you make sure that text (words) is not cut off at the end off each line?

ex.
Hello this is just an example becuase you might not understand me but thi
s has been cut off like what would happen in turing I want to make sure that is does not happen.


"THIS" WAS CUT off how do u make that not happen?
using a procedure

SRY
-Nate
Blade




PostPosted: Mon Apr 14, 2003 6:55 pm   Post subject: (No subject)

ooh i understand hahah.... use multiple puts
Tony




PostPosted: Mon Apr 14, 2003 7:07 pm   Post subject: (No subject)

ahh... I suppose you use a counter for each line and see if there's enough space left for the next word. If not you use
code:
put ""
which moves cursor onto the next line and you reset the counter.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mephi




PostPosted: Mon Apr 14, 2003 7:55 pm   Post subject: Wrap

how do you put a counter? cuz i wanna do the same thing....tony i added you to my msn, chann23@hotmail.com thats me...plz explain, i really need to know!!
Ancalagon The Black




PostPosted: Mon Apr 14, 2003 8:19 pm   Post subject: (No subject)

Or you could use locate statements just befor the put statement to centre it or watever.
Sponsor
Sponsor
Sponsor
sponsor
DarkHelmet




PostPosted: Mon Apr 14, 2003 8:28 pm   Post subject: (No subject)

The following coding will wrap text at the fortieth character. This is just in case the program isn't supposed to know what text it is outputting before it is run. The only problem is that if you somehow give it a word with more than 40 characters, it will never finish.


var strtext : string
var intwords : int
var intcounter : int
get strtext : *
var intcount : int
var strline : string
var intline : int
intwords := 0
for i : 1 .. length (strtext)
if i > 1 then
if strtext (i - 1) not= " " then
if strtext (i) = " " then
intwords += 1
end if
end if
end if
if i = length (strtext) then
if strtext (i) not= " " then
intwords += 1
end if
end if
end for
var strwords : array 1 .. intwords of string
for i : 1 .. intwords
strwords (i) := ""
end for
intcounter := 1
for i : 1 .. length (strtext)
if i > 1 then
if strtext (i - 1) not= " " then
if strtext (i) = " " then
intcounter += 1
end if
end if
end if
if strtext (i) not= " " then
strwords (intcounter) += strtext (i)
end if
end for
intcounter := 0
intcount := 0
intline := 1
cls
strline := ""
loop
intcount += 1
if intcounter + length (strwords (intcount)) <= 40 then
intcounter += length (strwords (intcount)) + 1
strline += strwords (intcount) + " "
else
put strline
if intline = maxrow then
Input.Pause
intline := 0
cls
end if
intline += 1
intcounter := length (strwords (intcount)) + 1
strline := strwords (intcounter) + " "
end if
exit when intcount = intwords
end loop
Prince




PostPosted: Mon Apr 14, 2003 8:29 pm   Post subject: (No subject)

yea but then if u had like a full out paragraph (y u would hav this in turing i dont kno but...) ud fill up the source code with locates
nate




PostPosted: Mon Apr 14, 2003 8:33 pm   Post subject: Rest of Text

How do you make it so that the rest of the text shows up below it?


What you have done is awsome but I still need to know this
I will donate 15 bits if you can tell me

-Nate
DarkHelmet




PostPosted: Mon Apr 14, 2003 8:33 pm   Post subject: (No subject)

That still has bugs in it. still fixing it.
nate




PostPosted: Mon Apr 14, 2003 8:35 pm   Post subject: thanks

thanks

could you sort of explain a little what you have done?
It is sort of confusing!Smile

-Nate
Mephi




PostPosted: Mon Apr 14, 2003 8:38 pm   Post subject: Text Wrap

yea i need to kno too! i only got 2 bits cuz this is a new account but im willin to give those up! Very Happy btw, thx...i really appreciate this!
DarkHelmet




PostPosted: Mon Apr 14, 2003 8:49 pm   Post subject: (No subject)

var strtext : string
var intwords : int
var intcounter : int
get strtext : *
var intcount : int
var strline : string
var intline : int
intwords := 0
for i : 1 .. length (strtext)
if i > 1 then
if strtext (i - 1) not= " " then
if strtext (i) = " " then
intwords += 1
end if
end if
end if
if i = length (strtext) then
if strtext (i) not= " " then
intwords += 1
end if
end if
end for
var strwords : array 1 .. intwords of string
for i : 1 .. intwords
strwords (i) := ""
end for
intcounter := 1
for i : 1 .. length (strtext)
if i > 1 then
if strtext (i - 1) not= " " then
if strtext (i) = " " then
intcounter += 1
end if
end if
end if
if strtext (i) not= " " then
strwords (intcounter) += strtext (i)
end if
end for
intcounter := 0
intcount := 0
intline := 1
cls
strline := ""
loop
intcount += 1
if intcount > intwords then
put strline
exit
end if
if intcounter + length (strwords (intcount)) <= 40 then
intcounter += length (strwords (intcount)) + 1
strline += strwords (intcount) + " "
else
put strline
if intline = maxrow then
Input.Pause
intline := 0
cls
end if
intline += 1
intcounter := length (strwords (intcount)) + 1
strline := strwords (intcount) + " "
end if
end loop

this works a bit better

the first loop it has runs through the coding counting the number of words by looking for spaces. When it finds a space, it knows to add 1 to the number of words.
The next loop separates each word, so they can be rearranged later.
The last loop has a variable for how long the line of text is, and to store the lines of text. It adds the individual words to the line of text, until it knows that line of text will be over 40 digits with the next word. When that happens, it outputs the current line of text to the screen, clears the variable with the line of text in it, and then starts over at the next word.
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 2  [ 25 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: