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

Username:   Password: 
 RegisterRegister   
 Opening Text
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
metachief




PostPosted: Fri Feb 01, 2008 8:44 am   Post subject: Opening Text

I am trying to open a text document that is a bunch of paragraphs. The problem is that I can't get to show the paragraphs with spaces in them.

What I mean is that if for example I want to open a text document containing: "Hi my name is Joe. Turing is a great program, but it is old so it is not as popular as it was."
It will output either "HimynameisJoe.Turingisagreatprogram,butitisoldsoitisnotaspopularasitwas." or it will output "Hi
my
name
is
Joe.
Turing
is
a
great
... (e.t.c.)"

This is my code:

var filenum : int
var stuff : string
open : filenum, "weapons.txt", get
loop
exit when eof (filenum)
get : filenum, stuff
put stuff ..
delay (100)
end loop
close : filenum

Any help would be great..
Sponsor
Sponsor
Sponsor
sponsor
fishtastic




PostPosted: Fri Feb 01, 2008 8:56 am   Post subject: Re: Opening Text

if you use
code:
put stuff ..

then you dont have a space in between them.
why not just put a space then?
code:
put stuff ..
put " "..

Very Happy
MichaelM




PostPosted: Fri Feb 01, 2008 10:07 am   Post subject: Re: Opening Text

Also, you can use the following
code:

open:streamNumber,"bla.txt",get
assert streamNumber>0
    get:streamNumber,line:*
close: streamNumber


Using the " :* " should get the entire line, including spaces etc.
BigBear




PostPosted: Fri Feb 01, 2008 8:38 pm   Post subject: Re: Opening Text

The output depends how you get stuff and how you put stuff. If you get stuff with a :1 then you will get the text file by character including spaces. If you get : filenum, stuff :* then you will get the text file line by line. By using get:filenum, stuff you are getting it by word then you are putting that word followed by another word without spaces. Try putting a delay in your loop to see what I mean.
ericfourfour




PostPosted: Fri Feb 01, 2008 10:31 pm   Post subject: Re: Opening Text

The : operator allows you to specify how many characters you want to get.

Ex:
Turing:
var word : string
get word : 5


From whatever is input, it will only use the first five characters.

If you leave the : operator out, it will get the next string separated by whitespace (space, tab, newline, carriage return).

Ex:
Turing:
var word : string
get word


In Turing * usually means, when not dealing with math, end. If used in conjunction with the : operator, it will get everything until the end of the line.

Ex:
Turing:
var word : string
get word : *
metachief




PostPosted: Mon Feb 04, 2008 4:49 pm   Post subject: RE:Opening Text

thank you lots
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  [ 6 Posts ]
Jump to:   


Style:  
Search: