MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Ordered output
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Ordered output

 Post Reply Post Reply
Author
Message
Gali View Drop Down
Contributor
Contributor
Avatar

Joined: 28.Jun.2018
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gali Quote  Post ReplyReply Direct Link To This Post Topic: Ordered output
    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
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 641
Answer Answer
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 16.Nov.2018 at 09:36
You can use '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 :)


Edited by stevek - 16.Nov.2018 at 09:36
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.078 seconds.