SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Mar 2001
    Location
    Copenhagen, Denmark
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Use of the @ operator in multi-level arrays

    I guess my problem centers on use of the @ operator in multi-level arrays, but to make it all more understandable I'd better start from the beginning...

    I am currently testing a pretty complex tree structure, and to this end I have made a record like this:

    type TREESTRUCTURE is record
    [ ] STRING sName
    [ ] LIST OF TREESTRUCTURE lrSub

    The point is that I can refer to the "Grandchild1" node in the tree below like this: rTree.lrSub[1].lrSub[1]

    Root
    [ ] Child1
    [ ] [ ] Grandchild1
    [ ] Child2

    My end goal is to write a set of methods that can verify generic moving and copying of nodes in the tree structure. For this to work, I need a way of referencing to individual nodes regardless of the level they reside in. For example, I need a Delete method that can delete a branch no matter where it is located in the structure. To delete "Grandchild1" in the tree above, I would need to execute the following code:

    [ ]ListDelete (rTree.lrSub[1].lrSub, 1)

    To delete a node located deeper down in the tree, a statement like this would work:

    [ ]ListDelete (rTree.lrSub[1].lrSub[2].lrSub, 1)

    My problems arise when I try to write some code that will work regardless of the number of lrSub[x] references.

    I have tried using the @ operator like this:

    [ ] sTreeTag = "rTree.lrSub[1].lrSub[2]"
    [ ] ListDelete (@(sTreeTag), 2)

    ... But this only generates error codes like this:
    *** Error: Variable rTree.lrSub[1].lrSub[2] is not defined
    Does anyone have any ideas about how to solve or work around my problem? Any ideas appreciated.

    Thanks in advance,

    Jakob Sloth

    [This message has been edited by Sloth (edited 01-15-2002).]

  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Use of the @ operator in multi-level arrays

    From your code, my guess is that simply passing it in without the @ operator should work (assuming that the TREESTRUCTURE you are referring to is in fact defined). But, even if you get that bit to work, you have a more significant problem.

    Once you've given your function a TREESTRUCTURE, it doesn't know how where in the hierarchy this node is (even if you could get it to accept your parameter).
    One way to get round this problem is to replace your use of a record variable with a real object. Define a window (let's call it oTreeStructure) which has member variables String sName and list of oTreeStructure, in the same pattern as your record definition.
    Then ,using the techniques described in articles http://customers.segue.com/protected...emsley_toc.htm and http://customers.segue.com/protected/bronze/s_newsletter/0002/john_sefler/s_1sefle r_toc.htm, declare instances of this class to represent your hierarchy.

    Then, you can submit the relevant oTreeStructure as a parameter to your function, and the function can find out where it is in the hierarchy by using methods GetParent() and suchlike.

    Hope this helps.

    ------------------


    [This message has been edited by vincebowdren (edited 01-15-2002).]

    [This message has been edited by vincebowdren (edited 01-15-2002).]

  3. #3
    Junior Member
    Join Date
    Mar 2001
    Location
    Copenhagen, Denmark
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Use of the @ operator in multi-level arrays

    Thanks for your tips and opinions. Using a real object seems like a good idea, and the articles you linked to were a very interesting read indeed.

    However, this morning I managed to write a method that let me work around my problems (2 nested "for each" statements), so I won't be switching from record to winclass just now.

    You have a good point about my needing methods for traversing the tree structure, but I already have these methods in place for the tree that I am actually testing. (I lift the information from the application and use it to perform operations on my records.)


    ------------------

  4. #4
    Member
    Join Date
    Jun 2002
    Location
    california
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Use of the @ operator in multi-level arrays

    jack, i don't know if you're still active in the forum. anyway, i am working on an application with a similar tree structure, is there a way you can post how you got around the problem.

    thanks in advance.

    ------------------


    [This message has been edited by mbt011 (edited 06-24-2002).]

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:42 AM.

Copyright BetaSoft Inc.