Results 1 to 2 of 2
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Oh No! Not CLASSES again! (Word97/SR2)

    I went through this a year or two ago, Classes, and maybe this time I have a good use for them.

    I want/need to build a tree-structure of text. In essence a complete document is to be re-constructed as a tree, with the root being called, say "ALL".

    From the root, the first level nodes will be all the first words of the paragraphs. If a paragraph starts with a word (and it does), then that word will be found exactly once at level 1, together with a count of its occurrences as a first word of the paragraph.

    <pre>Bolt Trimmers, See Trimmers, Bolt
    Boring Bars, See Tooling & Accessories
    Boring Machines, Horizontal And/Or Way Type
    Boring Machines, Precision, Double End
    Boring Machines, Precision, Single End
    Boring Mills, Horizontal, Cnc & N/C, See Cnc & N/C Machinery & Equipment
    Boring Mills, Horizontal, Floor Type, (Also See Planer And Table Types)
    Boring Mills, Horizontal, Planer Type (Also See Floor And Table Types)
    Boring Mills, Horizontal, Table Type (Also See Floor And Planer Types)
    Boring Mills, Vertical, Includes V.T.Lathes, (Also See Cnc & N/C Section)
    Boring Spindles (Also See Spindles)
    Brakes, Apron, (Also See Sheet Metal Machinery)
    </pre>


    In the example above, the root will contain pointers to three level-1 nodes "Bolt", "Boring" and "Brakes", and the node "Boring" will have a count of 10 (if I can see straight).

    From the node "Boring" will spring four level-2 nodes, to wit "Bars", "Machines", "Mills" and "Spindles"; The 2nd-level node "Mills" will have a count of 5.

    Each atom (node, leaf) will consist of the string itself, the count of occurrences, and three pointers (1) pointer backwards through the other nodes at this level in this subtree (2) pointer forwards through the other nodes at this level in this subtree and (3) pointer downwards to the first node at the next level.

    Thus, the node "Mills" should point downwards to the 3rd-level node "Horizontal", which will point forwards to 'vertical" and downwards to "CNC".

    I visualise each atom as five elements - a string, a count, and three pointers:
    <pre>------------------------------------------------------------------------------------
    Boring | 10 | NULL ptr | ptr to "Brakes" | ptr to "Bars" |
    ------------------------------------------------------------------------------------
    </pre>



    If I were coding this at the machine level, I'd used one-byte memory locations for string characters, and possibly 4-byte memory locations for pointers and counts, and I'd write a memory-management module to allocate blocks of bytes.


    I suspect that in VBA I am to develop a class, a structure, consisting of a string element, an integer element, and three pointer elements.

    If so, I'm not sure what the pointer elements are.

    My procedure "Make New Atom" will want to increase the number of these structures by one. I'd like to think that I'll be dealing with an array of these "atoms", so that the next atom in sequence will have a pointer that is suspciciously like the UBound of the array.



    How am I doing so far? I know that VBA ought to be easier than machine-level. I'm not sure that I'm heading in the right direction.


    (as an aside, earlier "languages" such as Poole&Waite's Stage2 were built for this kind of problem; I'm sold on the universal availability of Word/VBA; I'm not always sure whether it really is the best vehicle for string/list processing).

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Oh No! Not CLASSES again! (Word97/SR2)

    (later) attached please find a class module and a simple test module for use in Word97/SR2.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •