Print Page | Close Window

Ordered output

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: http://www.metacase.com/forums/forum_posts.asp?TID=904
Printed Date: 19.Apr.2024 at 00:54
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Ordered output
Posted By: Gali
Subject: Ordered output
Date Posted: 16.Nov.2018 at 07:52
Hello,
 
I defined two objects(object1 and object2) and the relationship between them, as shown.

      The following figure shows an example. '1','2' and'3'are instances of Object1.
'a','b','c'...are instances of Object2. 

Now I want to output the contents from left to right (as the code shows, traverse object1 first, then traverse object2 associated with each object1). the result i want to obtain is '1abc2d3fe' but when i ran the program i get the result '1cab2d3fe'. 
I want to output from left to right by location, what should I do?
foreach .Object1 
        { 
 :context
 newline 
 do >relationship
        { 
  do .Object2
    { 
:context
        newline 
    } 
                }
         } 

Yours,
Gali



Replies:
Posted By: stevek
Date Posted: 16.Nov.2018 at 09:36
You can use ' http://www.metacase.com/support/55/manuals/mwb/Mw.html#Mw-6_3_4.html" rel="nofollow - orderby x num' to sort the loop by x co-ordinates. Note 'num' to sort as numbers: with the normal string sorting, '11' comes before '5'.
foreach .Object1; orderby x num
{  :context; newline
   do .Object2; orderby x num
   {  :context; newline
   }
}

Note that I've removed the intermediate "do >relationship" loop. That's not necessary, unless you have more than one type of relationship between object types Object1 and Object2. If you do, you'll want to include that as part of the second loop, "do >relationship.Object2" rather than as an extra intermediate loop, which might defeat your ordering e.g. if the user drew relationships that weren't straight.

I've also assumed that you actually want the order 1abc2d3ef, not ...fe :)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net