Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Prompter Question or Design Change
- This topic has 7 replies, 3 voices, and was last updated 5 years, 1 month ago by Daniel Leu.
-
AuthorPosts
-
November 6, 2019 at 10:04 AM #37859
Rocky MachadoParticipantHi – I am currently putting together a trading app to manage all the trades I do. I currently have an Import form where I download transaction, run calculations, review the results and then copy it over to the Historical form. I’m running into an issue in the import form. I’m trying to identify if I have multiple stocks. If I do, then I want the system to prompt me a list of options (based on the same transaction date). Once, I select the option then I will update the stock key. This will give me historical tracking of a trade. I currently, have everything working, but I notice when I show the prompter within a for loop, the prompter shows, but the code in the back ground continue to process. Is there a way to pause the code (didn’t find it in the api) when the prompter is launched? Also, if you have any design recommendation that would be great. Here it what I am trying to achieve: 1) Identify all multiple stocks 2) Identify all options that are within the same date as the stocks, 3) loop through the stocks and prompt trader to pick the correct options (it’s in a dropdown list). 4) Update stock key with option that was chosen from the prompter. 5) continue to the next stock until finished.
Any help or recommendation or design change would be greatly appreciated,
rockyNovember 6, 2019 at 2:09 PM #37874
BrendanKeymasterHi Rocky,
I have a script here which continues execution after the results of the prompter are determined. Perhaps this will help you with what you want to do:
var second_prompt; var output2 = function printOut2() { console.log('second prompt: ' + second_prompt); } var output = function printOut(continueClicked) { console.log(username + ", " + password + ", " + email_address + ", " + other_field + ", " + genre); if (continueClicked == true) { let prompter2 = Prompter.new(); prompter2.addParameter('Did it work?: ', 'second_prompt') .show('A second prompt', output2); } } var username; var password; var email_address; var other_field; var genre; var genres = ['Action & Adventure', 'Comedy', 'Drama', 'Horror', 'Science Fiction']; let prompter = Prompter.new(); prompter.addParameter('Username: ', 'username') .addParameter('Password: ', 'password', 'secure') .addParameter('Email Address: ', 'email_address') .addParameter('Other: ', 'other_field') .addParameter('Genre: ', 'genre', 'popup', genres) .show('Enter a Username and Password and Stuff', output);
Basically when the first prompter is run, the output of that is the execution of the
output
function which creates another prompter. Then that prompter is displayed. And the output of that isoutput2
. So that’s how you can chain things together using the prompter.November 6, 2019 at 4:24 PM #37882
Rocky MachadoParticipantThanks for the code, but that does not work for me (not really sure thou). Basically, I am able to identify multiple stocks. Where I’m having trouble is when I’m in my FOR loop processing the stocks, and when the code launches the prompter. I notice that I get the prompt, but in the background it’s processing the rest of the for loop (like an asynchronous process). It works great when I only have one stock in my import form. However, when I have more than one is when it doesn’t work well.
thanks!
November 6, 2019 at 5:17 PM #37883
Daniel LeuParticipantYeah, the Prompter() is asynchronous…
Maybe there is a better way, but I would first create an array where you identify the multiple stocks. Then you can process those with the prompter loop.
Here is a small proof of concept. I just us an array that contains all records of my form. In your case, this would be the result of your filtered stock. Then I call my processing function. And as callback, I use the same processing function. So now the prompter loops over all entries of my list.var recs = form.getRecords(); var loop_count = recs.length; var xyzFunc = function() { if (loop_count == 0) { return "done"; } else { loop_count -= 1; } let prompter = Prompter.new(); prompter.show('Message prompt. Loop Count ' + loop_count, xyzFunc); }; xyzFunc();
Maybe this gives you a hint how you can approach your problem. Personally, I would love if the Prompter() is blocking, but I got to use what we have available.
November 6, 2019 at 11:09 PM #37891
BrendanKeymasterI couldn’t make the Prompter block unfortunately. I could only get it to display asynchronously.
November 6, 2019 at 11:27 PM #37892
Daniel LeuParticipantI couldn’t make the Prompter block unfortunately. I could only get it to display asynchronously.
Better to have a non-blocking Prompter than no Prompter at all :)
November 8, 2019 at 6:44 AM #37916
Rocky MachadoParticipantDaniel – Thank you for the idea. I was able to get it to fit my needs. I’m all set. Thanks!
November 8, 2019 at 1:04 PM #37922
Daniel LeuParticipantPerfect!
-
AuthorPosts
You must be logged in to reply to this topic.