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

Username:   Password: 
 RegisterRegister   
 Reading doc files!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DBZ




PostPosted: Tue Dec 30, 2003 7:05 pm   Post subject: Reading doc files!

Guyz is need to know how to get the program to read information saved in a word document, in order to execute the program. For example, if i make an airfare table in the word document, and all the fares of flying are listed in the document, i need the program to ask the user about where they r flying from and where they r flying to and then output the fare, which is in the word document!
Thanx!
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Tue Dec 30, 2003 7:39 pm   Post subject: (No subject)

to do that, you'll need specific information about the .doc file format. then you can use that to set up a data type in turing and read in the file in binary.

but my question would be why? it would be so much more practical and simple just to have it in a plain text file.
DBZ




PostPosted: Tue Dec 30, 2003 7:40 pm   Post subject: (No subject)

That is what i am asked to do!
Tony




PostPosted: Tue Dec 30, 2003 7:59 pm   Post subject: (No subject)

if you can - it might be a good idea to place flags (characters with ASCII values outside of alphanumeric range) to help you find values of data you're looking for. I have no idea how a Word table would look in ASCII, not to mention binary Rolling Eyes
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
icedesi




PostPosted: Mon Jan 05, 2004 7:43 pm   Post subject: (No subject)

Turing 4.0 has a Import Command if that helps.
DBZ




PostPosted: Mon Jan 05, 2004 9:06 pm   Post subject: (No subject)

Guyz, how bout if i use open statement and open the file! would that help? i just need the program to read the document!
Mazer




PostPosted: Mon Jan 05, 2004 9:57 pm   Post subject: (No subject)

icedesi - i don't pretend to know what i'm talking about but i'm pretty sure turing's import command is for modules, not for opening *.doc files

dbz - opening the file in turing would only be the first step. actually, i'd say it should be the second step. the first step would be to find out about the .doc file format and make your own variable type in turing for it. then you open the file (using read not get). if you want to know why you can't just open it like a text file and start reading lines, try this: open up your trusty old notepad.exe, file>open>[insert whatever your .doc file is here]. taht's what turing would see.
Kuntzy




PostPosted: Mon Jan 05, 2004 11:02 pm   Post subject: (No subject)

var fileNa : string := "test.t" %% the file you wanna open
var fileNo:int %% the file number, or adress
var count:=0
var code:array 1 .. 10000 of string %% used to read the text
var data: string %% temporary storage of the data

open : fileNo, fileNa, get %% opens the file

for i : 1 .. 1000
count+=1 %% counts the number of words read
get :fileNo, data %% gets the data from your file
code(i):= data %% stores the data in the code array
exit when eof (fileNo) %% exits the for loop, when there is nothing more to read
end for

for i : 1 .. count
put code(i)," ".. %% puts the strings with a stace in the middle
end for
close (fileNo) %% closes the file
Sponsor
Sponsor
Sponsor
sponsor
Ashkan




PostPosted: Tue Jan 06, 2004 12:48 am   Post subject: REply

i know wht ya mean, i have done somethin like that, well you got to read the file using Open: coomand and then get : and the break it up into words and letters and say like if tehe user puts Buffalo it goes and finds that word in DOC file and gets the string in front of it and shows it to user
if you get the idea then its cool but it is possible in turing and i have done somethin more complex than that i can probably put the source code heree, tell me if you need it, its a search program which i made as a subprogram for my actual program and you can search DOC, TXT withit easily even XLS but ofcourse you cannot control the colums and rows in Excel withturing
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  [ 9 Posts ]
Jump to:   


Style:  
Search: