| View previous topic :: View next topic |
| Author |
Message |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Tue Jan 10, 2006 8:52 am Post subject: |
|
|
Even a dll to convert word to html, rtf, txt ?
Nathan |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Tue Jan 10, 2006 2:05 pm Post subject: |
|
|
Requirements
Microsoft Word 97 or Microsoft Word 2000
Windows 95/98, Windows NT (with DLL Modifications+), Not tested on Win2000
+See Docs \ Dll_readme.txt for more information
Doc format reader for PalmOS device (eg SmartDoc, TealDoc, AportisDoc, etc)
Thanks for searching.... |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Jan 11, 2006 6:14 pm Post subject: |
|
|
Nathan,
After looking at this a few days. To do this with GadgetX is going to take some time so I will have to table this for now until I can get my DLL released. In the mean time take a look at this PowerBasic DLL TB_STG at http://com.it-berater.org/other_wrappers.htm which is a wrapper for the IStorage Interface. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Wed Jan 11, 2006 6:20 pm Post subject: |
|
|
I'm lost, can anyone figure out the dll that Dragonsphere has posted info about ?
Nathan |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Jan 11, 2006 7:02 pm Post subject: |
|
|
Nathan,
The Powerbasic DLL is a wrapper DLL around the Structured Storage functions and com Interfaces that are required to read and write to Structured storage files which MS Word documents are. PowerBasic uses a file with the *.inc extention to hold the definitions of the functions in the DLL. Also in the *.inc include file are the definitions of variables, structures, and constants that are required by the functions that the DLL exports.
Normally you would call these ole32.dll API functions to read a stream from a structured storage file.
1) StgIsStorageFile returns S_OK $00000000 if the file is a storage file
2) StgOpenStorageEx
3) Call the IStorage.OpenStream method with the name of the stream you want to open.
4) If you get a IStream interface from #3 then begin calling the IStream.Seek and IStream.Read methods on that interface to read data from the stream that you requested.
I am stuck at #3 I keep getting this error code STG_E_INVALIDHANDLE = $80030006 from the IStorage.OpenStream method? If anyone knows why please post some info. I believe I am passing all the correct information? Basicly I am duplicating the PowerBasic DLL with a DSU wrapper using my GadgetX.dll...
BTW Nathan it will probably be pretty hard to use the PowerBasic DLL without help from my GadgetX.dll since it requires several structures to be passed to the DLL.
Nathan I have also posted some code to my forum about this subject as well. You prob. should take a look at that. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu Jan 12, 2006 12:43 am Post subject: |
|
|
Nathan,
If you don't want to go the Structured Storage route or you just can't wait until I figure it out. I have another solution that does not require any DLL and uses only VDS code. This code will read any binary file and dump out all the Text including Tabs, Carriage returns, and Linefeed characters. You will have to figure out some way to clean the text from eroneous characters.
| Code: | #Define Function,DUMPTEXT
%%WordFile = @Path(%0)test.doc
%%FileSize = @File(Z,%%WordFile)
%%Text = @DumpText(%%WordFile)
List create,1
List Assign,1,%%Text
List SaveFile,1,@Path(%%WordFile)@Name(%%WordFile).txt
List close,1
Shell Open,@Path(%%WordFile)@Name(%%WordFile).txt
:Close
Exit
:DumpText
BINFILE OPEN,1,%1,READ
BINFILE SEEK,1,0
%C = 0
%T =
While @Not(@binfile(EOF,1))
BINFILE SEEK,1,%C
%%CharHex = $@Trim(@Binfile(Read,1,HEX,1))
%%Ch = @sum(%%CharHex,0)
If @Greater(%%Ch,31)
If @Not(@Greater(%%Ch,126))
%T = %T@Chr(%%CharHex)
End
ElsIf @Equal(%%Ch,9)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,10)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,13)
%T = %T@Chr(%%CharHex)
End
%C = @SUCC(%C)
WEND
Exit %T |
Mind you using the Structured Storage method would give you cleaner output since this is basicly the same way the MS Word reads it's own files. I just need to do more research on this.
Ok I updated the code above so now it is a VDS user defined function you can call. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Thu Jan 12, 2006 8:46 am Post subject: |
|
|
That piece of code is genius, it has given me a great starting block, thanks.
Nathan |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu Jan 12, 2006 3:18 pm Post subject: |
|
|
| Rubes_sw wrote: | That piece of code is genius, it has given me a great starting block, thanks.
Nathan |
Nathan,
I don't know about the genius part It was just a quick & dirty workaround  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Jan 13, 2006 3:58 am Post subject: |
|
|
Nathan,
Here is an update that will just dump out the text of the word document.
| Code: | #Define Function,DUMPTEXT,DumpWordDoc
%%WordFile = @Path(%0)test.doc
%%Text = @DumpWordDoc(%%WordFile)
List create,1
List Assign,1,%%Text
List SaveFile,1,@Path(%%WordFile)@Name(%%WordFile).txt
List close,1
Shell Open,@Path(%%WordFile)@Name(%%WordFile).txt
:Close
Exit
:DumpWordDoc
BINFILE OPEN,1,%1,READ
%C = 1536
BINFILE SEEK,1,%C
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
%%Match = 00 00
If @Equal(%%StartHex,%%Match)
%C = 2560
BINFILE SEEK,1,%C
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
End
%T =
While @Not(@Equal(%%StartHex,%%Match))
BINFILE SEEK,1,%C
%%CharHex = $@Trim(@Binfile(Read,1,HEX,1))
%%Ch = @sum(%%CharHex,0)
If @Greater(%%Ch,31)
If @Not(@Greater(%%Ch,126))
%T = %T@Chr(%%CharHex)
End
ElsIf @Equal(%%Ch,9)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,10)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,13)
%T = %T@Chr(%%CharHex)
End
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
%C = @SUCC(%C)
Wend
Exit %T
:DumpText
BINFILE OPEN,1,%1,READ
BINFILE SEEK,1,0
%C = 0
%T =
While @Not(@binfile(EOF,1))
BINFILE SEEK,1,%C
%%CharHex = $@Trim(@Binfile(Read,1,HEX,1))
%%Ch = @sum(%%CharHex,0)
If @Greater(%%Ch,31)
If @Not(@Greater(%%Ch,126))
%T = %T@Chr(%%CharHex)
End
ElsIf @Equal(%%Ch,9)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,10)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,13)
%T = %T@Chr(%%CharHex)
End
%C = @SUCC(%C)
WEND
Exit %T
|
Have fun _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Fri Jan 13, 2006 4:08 am Post subject: |
|
|
Your first example works for me, although I get extra info, but the second gives me nothing.
test.txt = 0 bytes. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Fri Jan 13, 2006 9:17 am Post subject: |
|
|
Works fairly good here. Any reason for leaving out extended chars? Will kill chars in many European languages. Also my Word docs
have char pos 11 for single line shift.
So perhaps something like:
| Code: | :DumpWordDoc
BINFILE OPEN,1,%1,READ
%C = 1536
BINFILE SEEK,1,%C
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
%%Match = 00 00
If @Equal(%%StartHex,%%Match)
%C = 2560
BINFILE SEEK,1,%C
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
End
%T =
While @Unequal(%%StartHex,%%Match)
BINFILE SEEK,1,%C
%%CharHex = $@Trim(@Binfile(Read,1,HEX,1))
%%Ch = @sum(%%CharHex,0)
If @Greater(%%Ch,31)
If @Not(@Greater(%%Ch,126))
%T = %T@Chr(%%CharHex)
ElsIf @Greater(%%Ch,159)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,148)
%T = %T@Chr(34)
End
ElsIf @Equal(%%Ch,9)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,10)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,11)
%T = %T@Chr(13)@Chr(10)
ElsIf @Equal(%%Ch,13)
%T = %T@Chr(%%CharHex)
End
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
%C = @SUCC(%C)
Wend
Exit %T |
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Jan 13, 2006 7:11 pm Post subject: |
|
|
| SnarlingSheep wrote: | Your first example works for me, although I get extra info, but the second gives me nothing.
test.txt = 0 bytes. |
SnarlingSheep,
What version for MS Word and what language? The above code has only been tested with MS Office 97 and Office XP in the US english language. It jumps to offsets within the Word document file so you may need to adjust the offsets. If you look at a word document within a hex editor you should be able to locate the document text fairly easy. It usually starts at the 3rd 512byte block or the 5th 512byte block. As for the reason that the first example works is because the first example search returns all ASCII characters including the carriage return @chr(13), line feed @chr(10), and Tab character @chr(9) strating from byte 0 in the file until the end of the file. This was just an example and is not the proper way to read Structured Storage files. The way that it is documented on Microsoft's Web site MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/stg/stg/structured_storage_start_page.asp is to use the Structured storage API functions in the Ole32.dll and the Structured storage COM interfaces. For some reason when I do that the individual stream names are not found in MS Word documents or MS Excel SpreadSheets. Once the IStorage interface finds the name of the stream it returns a IStream interface for the stream requested then it is just a matter of hacking out all the control and formatting characters. My example above reads the file like any Binary file and dumps the ASCII text that is inside the file so for your environment you will probably need to make addjustments. I posted this information just as a Quick & Dirty work around until I could figure out the proper method to do this. I may have to modify my GadgetX.dll to perform this task in a custom function since time is of essense I decided to table this until I could release the new version of my DLL but I did not want to leave the subject until I could somewhat satisfy Nathan's request. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Jan 13, 2006 7:43 pm Post subject: |
|
|
| Dr. Dread wrote: | Works fairly good here. Any reason for leaving out extended chars? Will kill chars in many European languages. Also my Word docs
have char pos 11 for single line shift.
|
Dr. Dread,
Your script should work just fine but as for the reason I did not include the extended characters is because to someone like myself those characters have no meaning in my language and they would look like control characters. I wanted to just present the ASCII text only. A better method would be to determine the current language and code page being used on the machine and look for those characters. As in Unicoded characters like 00 41 = ASCII A and so forth. So my examples above would not be considered language neutral nor do they have the ability to detemine the language being used Sorry next time I will spend a bit more time on this but hopefully I will be able to use the proper method for this subject and not have to deal with inspecting individual bytes. I do need more knowledge in the area of UNICODE in the relationship between VDS and other languages. Like what does VDS look like on systems that use Graphical characters to represent? Does VDS in other languages actually use UNICODE? When a function returns string data does the strings use the ASCII character set or does it return the character set (ie...code page) for the users language? I have seen scripts written for other languages and the all seem to use ASCII characters for element text but is this just because the script is being viewed and running on my machine which uses US English? _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Jan 13, 2006 8:07 pm Post subject: |
|
|
Dr. Dread,
New version has a langauge switch inside it.
| Code: |
:DumpWordDoc
%%Language = @Sysinfo(Language)
BINFILE OPEN,1,%1,READ
%C = 1536
BINFILE SEEK,1,%C
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
%%Match = 00 00
If @Equal(%%StartHex,%%Match)
%C = 2560
BINFILE SEEK,1,%C
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
End
%T =
While @Unequal(%%StartHex,%%Match)
BINFILE SEEK,1,%C
%%CharHex = $@Trim(@Binfile(Read,1,HEX,1))
%%Ch = @sum(%%CharHex,0)
If @Greater(%%Ch,31)
If @Equal(%%Language,$09)
If @Not(@Greater(%%Ch,126))
%T = %T@Chr(%%CharHex)
End
Else
If @Not(@Greater(%%Ch,126))
%T = %T@Chr(%%CharHex)
ElsIf @Greater(%%Ch,159)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,148)
%T = %T@Chr(34)
End
End
Else
If @Equal(%%Language,$09)
If @Equal(%%Ch,9)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,10)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,13)
%T = %T@Chr(%%CharHex)
End
Else
If @Equal(%%Ch,9)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,10)
%T = %T@Chr(%%CharHex)
ElsIf @Equal(%%Ch,11)
%T = %T@Chr(13)@Chr(10)
ElsIf @Equal(%%Ch,13)
%T = %T@Chr(%%CharHex)
End
End
End
%%StartHex = @Trim(@Binfile(Read,1,HEX,2))
%C = @SUCC(%C)
Wend
Exit %T
|
Have fun and let me know how it goes. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|