As you may know, I love games. I subscribe to Games magazine and do their 2 cryptic crosswords religiously. And I also like to enter the contests of various kinds (with nominal prizes of $100 or free subscriptions).
In the latest issue of Games magazine, there was this contest (note that the deadline is Oct. 31, so there is still plenty of time for you to enter):
What you have to do is quite simple:
If you are not interested in solving the puzzle but want to learn helpful SAP Build Apps tips, you can skip to the SAP Build Apps Tips section for 3 helpful tips for SAP Build Apps developers.
I have made the 2 projects available:
If you need help importing, just add a note to this blog. Here is the app in action.
I wanted the app to keep track of the cypher as I was determining which letters were represented by what other letters. For example, you see that some words have at the end 'W, meaning that probably W = S, and the app needed to store this substitution.
When I got all the clues and the answers, I need to store which answers to pair up, so I needed a place to store this, too. So I created a backend project with 2 entities in my Visual Cloud Functions project.
I set up my app page into 3 parts section.
Here's where I have a simple text box which represents the letter that appears in the encrypted words, and next to it is a dropdown box where I can select the real letter this letter represents. Everytime I change the letter I do the following:
SET_ITEM(appVars.Code, item.source == repeated.current.source, {id: repeated.current.id, source: repeated.current.source, target: self.value} )
FIND(appVars.Code, item.source == repeated.current.source).id:
Here, I simply display the encrypted clues, then displayed the clues with dashes instead and any letters I've found. I used the following formula to display the unencrypted words:
JOIN(MAP<mapitem>(SPLIT(repeated.current.Word,""),IF(NOT(CONTAINS(appVars.Letters,mapitem)),mapitem,IF(IS_EMPTY(FIND(appVars.Code, mapitem == item.source).target),"-",FIND(appVars.Code, mapitem == item.source).target))),"")
For example, if I change A to represent T, then the list of words automatically update like so:
Essentially this displays the data from the other entity, Pairs.
I click on the 2 clues I would like to pair up – say 2 and 3 – and type in "Step" for the answer.
Then I click Add. The pair is added to backend entity, I display a list of pairs (included a delete button to remove them), and I shade the clues that have already been selected.
You can see in the backend the record was added:
And finally, the app automatically checks if the pair add up to 33 (and is across) and if it is, it tries to decrypt the word based on the existed cypher.
I could make the following improvements, which would be pretty easy:
OK, it was a fun project, but I still learned some really cool things about SAP Build Apps that I wanted to pass on to you.
The function I used to take the cypher and decrypt the words involved nested functions, that both used the built-in "item" object, so I at first had trouble getting the function to work.
JOIN(MAP<mapitem>(SPLIT(repeated.current.Word,""),
IF(NOT(CONTAINS(appVars.Letters,mapitem)),mapitem,
IF(IS_EMPTY(FIND(appVars.Code, mapitem == item.source).target),"-",FIND(appVars.Code, mapitem == item.source).target))),"")
The function does the following:
But we had a problem in the FIND function, because it uses a built-in item object to determine the field to check, but we want to check that against the item object we got from the MAP function. So we used the prefix <mapitem> to set the name of the object in the MAP function to something different, and now we could compare the 2 values.
I wanted to highlight the clues when they were used in one of the pairs. So I edited the style, and created a new "Local Palette" color for the Background color property.
For the color, I made it the following formula:
IF(IS_IN_ARRAY(CONCAT(PLUCK(appVars.Pairs,"firstClue"),
PLUCK(appVars.Pairs,"secondClue")), repeated.current.Number),"#777777","#FFFFFF")
The formula does the following:
I worked quite a bit on spacing of the app, especially padding. IN a container, there are 2 places for managing spacing, especially with Container components:
This may be obvious, but I still get confused how to manage spacing, since there are many places to manage it, and there are additional properties (e.g., alignment, rows, cells, width, position) that will affect how the whole application lines up.
Also, in the project, note the use of containers to enable greater flexible in controlling spacing.
Happy building 🏗️ 😺
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.