Fun with Aliases and Strings #2
Returning to the ” Aliases and Strings” theme of the previous post, where we looked into an example of String concatenation. Just a reminder, in the previous article you created the entity model and set up a couple of relationships, before using a rule to decide if the ticker tape instance is a member of a relationship called the next ticker tapes.
So here is the continuation of the document you saw in the previous steps:
The first part should look reasonably familiar, since it builds on the example with the next ticker tapes. But is uses the second relationship, called the closest ticker tape. Note the wording closest ticker tape not ticker tapes. We are aiming for the closest one, or if you prefer, the next one in line. So for ticker tape number 3, the closest would be number 4.
We again use an alias, but things get a bit sticky in the following parts. Where did the further ticker tape come from? Well, perhaps unsurprisingly, it’s another alias. You see, we already used the other ticker tape in the conclusion so we need to use another word : in this case further was my personal choice, but it could have been another word that meant something in this context. So by now we have the following, expressed in conversational style :
Compare ticker tape A (with other tapes, let’s say B, C and D). B,C or D will be called the closest ticker tape if the following is true.
- B,C or D have an ID that is higher than the ID for A
- Using the next ticker tapes as your starting point (so, B C and D)
- Compare them (so B compared to C, B compared to D etc) to this rule
- Is B’s ID is less than or equal to C (for example)?
So we end up with the ticker tape that is in the next ticker tapes AND has an ID that is less than or equal to the other next ticker tapes. So it is the closest one.
I’m reminded of this excellent conversation from Monty Python since it can get a bit confusing at first:
The final rule concerns whichever ticker tape has the longest string. And that string is what you are about to create, for each and every instance of your entity.
We’re coming with you!
You will generate a string of text for each of the entity instances (so, for each of the ticker tape instances). And this string will be the driver of a logical loop.
Firstly, let’s set your scene and remind of the context:
- “Text 1”
- “Text 2”
- “Text 3”
Each ticker tape has a text message, for example “Text 1” . This message should be concatenated with the other text messages to form a long “final” string. Each should have a comma inserted between them, into the final string, and of course a “.” at the end. Just to make a nice tidy “final” string. It might look like “Text 1, Text 2, Text 3.”.
So each instance has a text string, and a “final text”. The “final text” will be the ticker tape text string concatenated with the closest ticker tape’s text string, plus a comma if required – for example if there are no “next ticker tapes” for a given tape, it’s because we have reached the end of the instances (number 4 , if there is no number 5).
The following attributes give us the numbers used in the table above:
And the final (final) global attribute:
In the next part of this series, there will be a chance to look back on the techniques, observe the warning message and generally investigate your logical loop.
Aliases and Strings part three will be with you in a few days, In the meantime of course you can read the online help here.