Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / reading strings from a .doc file

Author
Message
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 14th Apr 2003 12:56
Hi,

How could I read all of the strings in a .doc file without me having to write it in myself and giving it a variable through DBPro.

What I mean is a file that already exists, read all of it's contents and then be able to print it to the screen.

Can anyone help? Please?

Thanx.
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 14th Apr 2003 13:45
anyone?

The admiral
23
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 14th Apr 2003 14:30
Id like to know as well someone please tell.

[href]www.vapournet.com/~flyer[/href]
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Apr 2003 14:45
in the code section of this post is a simple word97 document with the test inside reading "Hello this the word format"

In order for you to use it effectively you would have to read in the file structure the same way it is represented with the file format and also the correct version of that format.

www.whatsit.org I think is one place to look for file format specifications but i think it will be hard to cover so many format changes of word and its obscure access to the format specifications.



here is a couple of quotes whether they are accuarte or not im not sure

Quote: "
Most computer users use Microsoft Word. That is unfortunate for them, since Word is proprietary software, denying its users the freedom to study, change, copy, and redistribute it. And because Microsoft changes the Word file format with each release, its users are locked into a system that compels them to buy each upgrade whether they want a change or not. They may even find, several years from now, that the Word documents they are writing this year can no longer be read with the version of Word they use then.
"


Quote: "
Free software today can read some Word documents, but not all--the format is secret and has not been entirely decoded. Even worse, Microsoft can change it at any time
"



source:

http://www.gnu.org/philosophy/no-word-attachments.html



It would be easier to just create a textfile and use this to populate textual data.


If your current document is in word u can always export to a txt document.

a small step up from text if u wanted a format to tackle conversion on might .rtf or rich text format.




compare this line in a txt file

Hello this the word format

to the source button belwo and keep inmind how many different versions there are.


Ill post a small string txt write / read sample next

indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Apr 2003 14:58
ok so here is the smallest amount of code u could get by with to make a string reader.

this simply uses one variable to print the data per line
of the textfile and automatically knows how many lines to work with
but doesnt consult handing the data to another variable for use in your game.

It doesnt count for text size or overlapping of data off the screen


when ever u begin to work with projects that involved external files just make a folder for it so u can collate the data with the project and if using DBP then u will need to have your project folder in there also so it knows where the data or txt file is.







and now this is a sample of data which u can save into a .txt file and call it mydata.txt and place it in this folder.



Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 14th Apr 2003 15:44
ok, that helps me with everything else but what i need to know.(your help is greatly appreciated but it didn't answer my problem)

I really need to know how to read all of the contents of aword file.

Please!

Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 14th Apr 2003 15:47
and that source code is just a load of squares and gobbledeegook.

indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Apr 2003 15:53
I think you missed the whole point mate to the excercise.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 14th Apr 2003 16:10
To re-interate : You can't take a .DOC file (unless it is plain text), and print it on the screen, as only Microsoft knows the layout of it, hence the reason you only get junk on the screen.

Convert the .DOC file to either .TXT or ASCII .DOC, and then you'll be able to read it.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 14th Apr 2003 16:12
well as indi noted, Word is a closed format which is only useable on the Windows Operating System within a Microsoft Licenced document product.

however there is the full source for reading .doc 6.0 over at wotsitformat.org, but to be quite honest ... its easier figuring out 128bit Japanese Encryption than the .doc format - it is the most overly complex format there is.

if you REALLY need to load it, make a DLL using MFC's cRichText editing feature to read in the data you require, won't bypass the real problem with reading these files, but will get you what you want.

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Xoid
23
Years of Service
User Offline
Joined: 8th Mar 2003
Location:
Posted: 14th Apr 2003 16:21
actually, the website address is http://www.wotsit.org/
LOL, get it right people!!!!!

Do not anticipate the outcome of the engagement, let nature take it's course, and your tools will strike at the right moment - from "Tao of Jeet Kune Do" by Bruce Lee
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 14th Apr 2003 20:16
ok then, could someone send a bit of code on how to convert a .doc file into a .txt file and then save it in memory.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 14th Apr 2003 20:39
Nope, sorry.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Apr 2003 20:52
It's not that easy I'm afraid, and can't be done directly from DBPro. You'd need to put together a DLL to access Word via a COM interface.

If you knew VC++ and COM, then I could point you in the right direction, but then again, if you did, you wouldn't need to ask
Ratty Rat
23
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 14th Apr 2003 21:04
Shady - can you give more info on what exactly you are trying to do IE :-

1) Why are you using a .doc file? is there some reason you can`t just use a .txt file?
2) Once you have the text what do you want to do with it? Because if you just want the text to appear on the screen your much better off with a .txt.
3) Is it different fonts/styles you want? This would be tricky, and you would have to write code to interpret the complex .doc file, not impossible, just very difficult.

It is unlikely that anyone has written code for what you want already because, for most projects , its easier to use a standard text file and write code to read it in (and change fonts/styles if needed) than to try and de-code an existing format.

Unless, of course, you are writing a .doc file reader or converter, in which case I`m not sure Dark Basic is the place to start (as its geared towards writing games, not windows apps).

"Don`t try to engage my enthusiasm, I don`t have one"
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Apr 2003 21:35
from word save as .txt then u can start to program with a text file of the data u might have had in word.

if u dont have word theres star office which is a larger download than possibly a .doc to txt converter on the net or mini converter to do so.

write the program higher than word can open some doc files and can save to txt


thats the only way at the moment I would suggest so u can start with a txt

indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Apr 2003 21:37
oops

"write" the program higher than "notepad" can open some doc files and can save to txt

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 14th Apr 2003 23:43
don't forget Wordpad which can open any .Doc upto the release of the OS its on (XP can open all of them, but not display picture from higher than 6.0 god knows why)

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 17th Apr 2003 12:35
Aw crap!

so it's basically impossible to do this in DBPro?

Thanx Everyone who tried to help,

to the questions that Ratty sent:

1) I'm trying (I STRESS TRYING) to make a file converter for my mam because she sometimes brings her work home and can't open it because it was made by a higher version or something. So I was thinking I could just gather all the text in the file, and then paste into our version. But as you said it's probably impossible with DBPro.

2) I think the above answers that question.

3) I don't neccessarily need the fonts to be the same because you could change in word couldn't you?

Thanx again.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 17th Apr 2003 13:27
To be honest, it might be worth just getting the latest Microsoft Works, as (I think) that should be able to cope with all .DOC version

It'll be very hard doing your own converter (unless you can find a free one)

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Apr 2003 14:22
well you could do what Toad suggest, or hand her a postit that says "Save as Word 95/6.0 .Doc!!"

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2026-07-11 12:01:16
Your offset time is: 2026-07-11 12:01:16