Customized Calculator To Return Value To Field In A Form

Good morning, after much searching, I am asking for some advice.

I have a simple, single record form designed to capture stock (inventory) counts. Some materials require custom calculators to assist user in determining the counted quantity.

I would like to have a button or link next to the quantity field on the form, that when clicked will display a modal customized calculator that will accept 3 numeric inputs and when an accept button is clicked, return the calculated value to the calling form and update the quantity field on the form with the calculated value.

My first approach was to add a linked field to the form (From a label field located next to quantity) that links to a control application and displays modal, then have the control application accept the inputs, make the calculation and then place the calculated value in a global variable and then exit. However, upon close of the control application, there seems to be no event that fires on the form application that will allow me to update the field with the value in the global.

Does anyone know of an example of a solution here?

Is there perhaps a more elegant way to implement a custom calculator similar to the numeric calculator that can be enabled for scriptcase numeric fields?

Thank you in advance for any assistance.