Re: A way to continue script execution while awaiting user input

1489 0
Showing results for 
Search instead for 
Did you mean: 


i’ve implemented Levenstein function in my script to compare 2 tables of names from different sources. For some matches where match ratio is not very high, I added step, where user can choose from several options with maximum ratio (using await input.buttonsAsync). Since tables contain thousands records, one match operation lasts for some seconds.
Is there a way to continue script execution (at least for records, that doesn’t require to interact with user) while user thinks which option to choose?

upd: I read thread with function again and understand how to accomplish my task - use links instead of async input and gather them in some table where user selects while script runs in other tab.
but still I’m curious - is the subj doable with “advanced” part of js? generators/iterators? or promises/async? I read these topics long time ago when my JS knowledge was not enough to understand.
if you can point me in the rigth direction, thanks in advance.

2 Replies 2

Generators are one way to solve this, but since we’re talking about simple scripts here, you don’t need to commit to anything so fancy.

If I’m understanding you correctly, all you have to do is not await the performance-heavy load while continuing to perform whatever other prepwork you still can without the pending data. In my experience, the Promise.all() method can be useful for managing such scenarios. But it’s really hard to give you specific implementation advice without seeing any of your actual code.


my code is something like this:
for loop {
evaluate Lev.distance(3-5 seconds);
if x>0.7 do autoselect, else ask user to choose
write value

to be honest, I don’t understand well this part of JS (I mean async functions, promises etc.), so I decided to try.

it really worked well without await, I did some changes to be able to resolve answers after main loop and in the end I’ve set last input, after the loop

let ask = await input.buttonsAsync('Press Done after you complete all choices',['DONE'])


it awaited for ‘Done’ to be pressed, then, before starting my procedure I received this error

j: userInputStartTime
    at main on line 73

73 is the line with await input.buttonsAsync
first search result guided me to the old topic

I guess that means it won’t work in Airtable?
As I said before, I can do workaround - instead of read/write some value, script will link matched records, and if I need to select, I just link the record to all five records in the ‘choises’, ordered by the match probability descending, so the choice can be easily done later or even during script execution in other tab.

Thanks for the clue, It helped me to define my next JS topic for learning.