Page 2 of 3

Re: comDoc

Posted: Thu Apr 22, 2010 2:47 pm
by srod
SFSxOI wrote:@srod

When you say "any number of disparate 'files' " - do you mean documents only or files of any type?

Looks good and I can see the your touch of excellance in this product, thank you very much :)
A single document (in the comDoc) sense is a single object residing either in memory or within a single disc file. Into this document you can create any number of files; each of which you give a name (e.g. "file1", "image1",... etc.) and you will then typically end up with a single disc file containing this collection of files.

When you subsequently open one of these documents (with one of comDoc's document creation functions) you can then open any (or all) of the 'files' contained within and access that file just as if it was a disc file all of it's own (which it is not!)

For example, here is one of the demo programs which opens a document which I created in another demo. The document sits in a disc file with the name "test.cmp" and inside this one document I created two files; "file1" in which I wrote 1000 longs and "file2" in which I wrote a couple of utf-8 strings. See how the demo opens the document and then accesses these two files.

Code: Select all

CoInitialize_(0)

XIncludeFile "..\comDoc.pbi"

Define myDoc.comDocDocumentObject, myFile.comDocFileObject

;Open our disc-based compound document.
  myDoc = comDoc_OpenDiscDocument("test.cmp")

If myDoc
  ;Open the first file which we named "file1"
    myFile = myDoc\OpenFile("file1")
    If myfile
      Debug "'file1'..."
      ;Read all the longs we wrote to this file.
       While myfile\Eof() = 0
          Debug "    " + Str(myFile\ReadLong())
        Wend
      myFile\Close()
    EndIf
    Debug "====="
  ;The second file which we named "file2"
    myFile = myDoc\OpenFile("file2")
    If myfile
      Debug "'file2'..."
      ;Read all the strings we wrote to this file.
        While myfile\Eof() = 0
          Debug "    " + myFile\ReadString(#PB_UTF8)
        Wend
      myFile\Close()
    EndIf
  myDoc\Close()
EndIf
MS Word saves documents (.doc, not .docx) in this kind of format. A .doc file is basically a compound file and you can open one with one of my demos if you wish and take a look inside. :)

I hope that answers your question?

Re: comDoc

Posted: Thu Apr 22, 2010 2:49 pm
by srod
comDoc 1.2 - 22nd Apr 2010.

Version 1.2 fixes a memory leak.

Re: comDoc

Posted: Thu Apr 22, 2010 3:01 pm
by Perkin
Nice srod, this will be very useful.
Many Thanks.

Re: comDoc

Posted: Thu Apr 22, 2010 3:04 pm
by Perkin
On your comDoc page of your website, the link highlighted 'comDoc' in the first paragraph links to scintilla.

Re: comDoc

Posted: Thu Apr 22, 2010 3:28 pm
by srod
Perkin wrote:On your comDoc page of your website, the link highlighted 'comDoc' in the first paragraph links to scintilla.
And why not! I was going to link it to a porn site, but thought better of it in the end! :wink:

Doh!!!

Re: comDoc

Posted: Fri Apr 23, 2010 2:22 pm
by SFSxOI
srod wrote:
SFSxOI wrote:@srod

When you say "any number of disparate 'files' " - do you mean documents only or files of any type?

Looks good and I can see the your touch of excellance in this product, thank you very much :)
A single document (in the comDoc) sense is a single object residing either in memory or within a single disc file. Into this document you can create any number of files; each of which you give a name (e.g. "file1", "image1",... etc.) and you will then typically end up with a single disc file containing this collection of files.

When you subsequently open one of these documents (with one of comDoc's document creation functions) you can then open any (or all) of the 'files' contained within and access that file just as if it was a disc file all of it's own (which it is not!)

For example, here is one of the demo programs which opens a document which I created in another demo. The document sits in a disc file with the name "test.cmp" and inside this one document I created two files; "file1" in which I wrote 1000 longs and "file2" in which I wrote a couple of utf-8 strings. See how the demo opens the document and then accesses these two files.

Code: Select all

CoInitialize_(0)

XIncludeFile "..\comDoc.pbi"

Define myDoc.comDocDocumentObject, myFile.comDocFileObject

;Open our disc-based compound document.
  myDoc = comDoc_OpenDiscDocument("test.cmp")

If myDoc
  ;Open the first file which we named "file1"
    myFile = myDoc\OpenFile("file1")
    If myfile
      Debug "'file1'..."
      ;Read all the longs we wrote to this file.
       While myfile\Eof() = 0
          Debug "    " + Str(myFile\ReadLong())
        Wend
      myFile\Close()
    EndIf
    Debug "====="
  ;The second file which we named "file2"
    myFile = myDoc\OpenFile("file2")
    If myfile
      Debug "'file2'..."
      ;Read all the strings we wrote to this file.
        While myfile\Eof() = 0
          Debug "    " + myFile\ReadString(#PB_UTF8)
        Wend
      myFile\Close()
    EndIf
  myDoc\Close()
EndIf
MS Word saves documents (.doc, not .docx) in this kind of format. A .doc file is basically a compound file and you can open one with one of my demos if you wish and take a look inside. :)

I hope that answers your question?

Yep it does answer my question. Thank You very much :)

Re: comDoc

Posted: Fri Apr 23, 2010 4:30 pm
by srod
comDoc 1.3 - 23nd Apr 2010.

Version 1.3 fixes a \ReadString() problem (Unicode destroyed it!)

Re: comDoc

Posted: Sat Jul 03, 2010 2:08 pm
by ts-soft
If i delete some files in a document the document wasn't smaller.
Is there a way to "compress" the document? Or have i to recreate the file?

Greetings
Thomas

Re: comDoc

Posted: Sat Jul 03, 2010 2:52 pm
by Josh
try to save with a other filename

Re: comDoc

Posted: Sat Jul 03, 2010 3:23 pm
by ts-soft
Josh wrote:try to save with a other filename
look here
:D thx, i will test it

// edit
works fine!

Re: comDoc

Posted: Sat Jul 03, 2010 7:24 pm
by srod
Yes it is undoubtedly a fragmentation problem. Saving to a new file works fine here.

Re: comDoc

Posted: Sun Jul 04, 2010 11:27 pm
by Kwai chang caine
I probably put as much time to understand what is the function of your code, that you, for create it :oops:
And i have finally understand...and I do not regret having tried to find :wink:

Since all this years of hard works for this forum, you heard surely so much compliments about all your enormous codes.....
Hhuuuuummmmffff !!!! ......that what i can say more ???? :roll:

Just perhaps one thing....that this forum would be without you ???
It's the right hand on the heart, and a little tear in the eye, that i write that 8)

Thanks for this great idea who, like comate, will boost even more, our love PB, at the side of his great brothers languages.

When a day, i go in the sky.......i can say at the doorman :

"Hello....it's just a little KCC who knocking at the door.... :oops:"
I'm nothing....but when even, i'm a big personality on the earth.....
Because me....little KCC...i know, and have talking numerous time, with SROD and other gods like FRED, NETMAESTRO, SPARKIE, GNOZAL....and more and more great persons 8)
And further more...i'm the personally IDIOT of one of his GODS :mrgreen:

See the proof, this is my card :

Image

And i'm sure the portman say to me, in the same time he open the door at the maximum, and greets me :
"So, you already know as much gods :shock: :shock:,
Then welcome in the paradise..."
Image

Thank you very much to exist ......MASTER 8)
And again thanks for this usefull code

Re: comDoc

Posted: Fri Jan 20, 2012 4:06 am
by shire
Hello,

This seems good, where could I download it?

Thank you.

Re: comDoc

Posted: Sun Jan 22, 2012 11:33 pm
by Kwai chang caine
On the site of SROD, but for the time it is down :(
http://www.nxsoftware.com/

This thread talk about that
http://www.purebasic.fr/english/viewtop ... 88#p372188

Re: comDoc

Posted: Tue Jan 24, 2012 12:57 pm
by shire
@Kwaï chang caïne:

Tnx for the info.

Too bad I can't download it :(