Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › List and choose Calendar names in prompter
March 12, 2021 at 1:37 AM #43808
i’m using the new JS API function
Utils.getCalendarNames()(Big thanks to Brendan for this!) in the prompter dialog to list/choose and use for my scripts:
... arr = Utils.getCalendarNames(); var calname; let prompter = Prompter.new(); prompter.addParameter('Kalender: ', 'calname', 'popup', [arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr, arr]) .show('Bitte Kalender auswählen:', callbackFunction); ...
1. In my case i have 30 items from the array in my list. If i have less than 30 calendars, the “missing” items in the prompter are empty. Is it possible to limit the list according to the length of the array so that only the calendars that actually exist are displayed?
2. Is it possible to sort the calendar list alphabetically?
ChrisMarch 12, 2021 at 8:50 PM #43812
Why don’t you just do the following:
prompter.addParameter('Kalender: ', 'calname', 'popup', arr) .show('Bitte Kalender auswählen:', callbackFunction);
And sorting should just be
arr.sort()instead of just
prompter.addParameter('Kalender: ', 'calname', 'popup', arr.sort()) .show('Bitte Kalender auswählen:', callbackFunction);
arris already an array, you don’t need to extract it back out to be an array.
prompter.addParameter('Kalender: ', 'calname', 'popup', [...arr]) .show('Bitte Kalender auswählen:', callbackFunction);
You can also do a
[...arr].sort()as well because the
syntax is returning an array object you can operate on directly.
It’s possible I miss understood something but I think this solves the problem for you.March 13, 2021 at 12:02 AM #43817
Oh my goodness, so simple. I definitely have to take a programming course.
Thank you very much, Sam!March 13, 2021 at 5:22 PM #43826
In any case you’ve got your own use cases with Tap Forms which I feel is the best way to learn. Have a problem you care about that you want to solve and search for how to solve it. It’s a great way to learn how to program :)March 14, 2021 at 1:45 AM #43833
;-) … Since i began coding with JS in TF (greatest App ever :)), I’ve been puzzling my code from snippets of the web and this forum, but there are natural limits for a beginner :-/. But I agree with you that there is no better way to learn to code … Thanks again for your great posts in this forum!
You must be logged in to reply to this topic.