Text Permutations on iOS/macOS
Friday, 8 April, 2022
⨳ 2 minute read ⨳ 406 words ⨳ SwiftUI ⨳ app ⨳ iOS ⨳ iPad ⨳ macOS ⨳ sas ⨳TLDR; I released my first iOS/macOS App.
In prior jobs, I wrote a lot of SAS code; some even made its way here.
One of the gems I came across was the %do_over
macro created by Ted Clay and shared with the SAS community back in 2006local copy of Ted Clay’s paper.
The macros Ted shared streamlined lengthy scripts and made code maintenance considerably easier.
Outside of SAS environment, I frequently found myself wanting to replicate the %do_over
behavior.
But because such integration wasn’t possible at runtime, so I turned to being able to at least replicate the functionality to generate the desired code.
I turned to one off shell scripts. As one does.
For example, I’d switch over to CodeRunner and build out something like this:
#!/bin/bash
for m in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
echo ", ROUND(SUM(${m}), 2) AS ${m}"
done
And then copy the results:
, ROUND(SUM(Jan), 2) AS Jan
, ROUND(SUM(Feb), 2) AS Feb
, ROUND(SUM(Mar), 2) AS Mar
, ROUND(SUM(Apr), 2) AS Apr
, ROUND(SUM(May), 2) AS May
, ROUND(SUM(Jun), 2) AS Jun
, ROUND(SUM(Jul), 2) AS Jul
, ROUND(SUM(Aug), 2) AS Aug
, ROUND(SUM(Sep), 2) AS Sep
, ROUND(SUM(Oct), 2) AS Oct
, ROUND(SUM(Nov), 2) AS Nov
, ROUND(SUM(Dec), 2) AS Dec
Each time I wanted to change something, I spent time going back into CodeRunner, adjusting and tweaking things, rather than actually doing what I needed to get done.
I also wanted to get into app development as it looked interesting. I had tried with Objective C back in the heyday of the AppStore, I even bought a book in 2008/2009, but that never clicked with me. Then Apple announced Swift in June 2014, but that also didn’t click. Then Apple released Swift Playgrounds in September 2016, but the tutorials were…meh. Then Apple announced SwiftUI in June 2019, but that also didn’t click (yet). Eventually, I was able to cobble together a functioning SwiftUI app built entirely in Swift Playgrounds on iPad. If I recall, I submitted the app to App Review directly from my iPad. What a time to be alive.