Aware IM Hidden Gems - While Loop

Contains tips for configurators working with Aware IM
Post Reply
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Aware IM Hidden Gems - While Loop

Post by customaware »

Aware IM is an amazing tool in so many ways as you all know.
But, what many don't know is that there are some gems tucked away out of sight that can really go a long way to solving some of the most complex challenges.

One of those little Gems is the While Loop.

Here is a small example of not only the While Loop but also how to leverage it's power by using it in conjunction with a Non Persistent Business Object.

This example arose out a real world problem that we needed to solve.

Imagine this....

We have two Stacks. We have 20 (or any amount) of Tiles.
Initially, all 20 Tiles are on Stack 1

We need the following functionality.
1. Click on a Tile and automatically move That Tile and all Tiles above it to Stack 2. In doing so, resequence the remaining Tiles in Stack 1 and esure the tiles in Stack 2 are sequence properly.
2. Be able to automatically move the tiles that are now in Stack 2 back to their original place at the top of Stack 1 and resequence all the Tiles now back in Stack 1
3. Alternatively, be able to automatically move the tiles that are now in Stack 2 back to Stack 1 but have them places at the bottom of Stack 1 but in the same order they were in while on Stack 2

Here is the Diagram
StacksAndTiles.jpg
StacksAndTiles.jpg (126.39 KiB) Viewed 23168 times
Here is a recording of the sample in action..... https://www.loom.com/share/9b4e562c4433 ... 0a83c0ada8
Here is the sample BSV for you try....
TileStacks.bsv.zip
Sample BSV
(42.67 KiB) Downloaded 1293 times
The heart of the magic is located in the Non Persisted Business Object NP_StackTileRenumber. Have a look at the two BO Rules on that BO. One Rule is for ASC scans and one is for DESC scan. NOTICE HOW THEY ARE BOTH HAVE THE While Loop option Checked.

Depending on what parameters you CREATE this BO with.... It will immediately execute the appropriate BO Rule AND IT WILL CONTINUE TO EXECUTE IT WHILE THE CONDITION IS TRUE. And, here is the elegance of the solution.... Once it is finished, the instance of the BO disappears.

You can check out all of the Processes that are being called... Some to set up the parameters for the CREATE and some that are called by the NP BO.

We are finding places in our app where this has been extremely useful (5 instances now in a single app). Most of these tasks are just way to complex to solve using normal Aware IM Processes and without this While Loop functionality, we would have no option other than to build a Stored Procedure or a Plugin.

Happy to hear comments or questions.

Enjoy.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Aware IM Hidden Gems - While Loop

Post by tford »

Thanks for sharing another example of your genius with us, Mark!
Tom - V8.8 build 3137 - MySql / PostGres
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Aware IM Hidden Gems - While Loop

Post by customaware »

Thanx Tom.....

At least someone "get's it"! ;-)
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
mohd.documents
Posts: 58
Joined: Thu Sep 13, 2012 7:06 pm

Re: Aware IM Hidden Gems - While Loop

Post by mohd.documents »

Absolutely amazing, thank you 'Mark' for sharing your knowledge with us, this is top quality stuff.

Mohd.
ACDC
Posts: 1138
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Aware IM Hidden Gems - While Loop

Post by ACDC »

This is a real Gem, never used the while loop before. Thank You

Just wondering if I can use this concept to maintain an accumulating balance in a grid based on its sort order, either by ID or Timestamp?

Imagine a Bank Statement with Debit and Credit Columns and then a Balance Column that keeps a running(Accumulating) total of each line item. So when a new line item is added the debit or credit entry value is added to the previous line item balance and inserted in its Balance column.

If you have any ideas please let me know

something like this:
Attachments
running total.jpg
running total.jpg (23.79 KiB) Viewed 19724 times
Post Reply