Been trying to look through official and unofficial guides but the level of nesting in this code is a bit too much for a newbie like me; Have to admit that I can't figure out how to compile this one.
I have this Applescript in the making:
• Dialog box asks user for numeric value input ➜ OK
• Based on given value, 25 different arithmetic operations are made and displayed as a table.
Some of these values come out with 12 decimal places which is way beyond necessary (2 decimal places max would do), and it also messes up the layout of the table because dialog boxes can only have so much width. How do I round and truncate results before displaying, if they have the risk of turning out ugly? I found guides on rounding, but I'm not sure how to use it when a), not every value has decimals and b) the values and to-be-ugly numbers aren't known until the function gets its numeric input from the user.
I tried to define each arithmetic operation into their own variables which I'd then scatter into the table and I made the collection of calculated values into a list. Taking guesses here, should I make a loop that would check every value in the calculated value list for decimals, take the ugly values one by one for a truncation procedure and put them back, end loop when all looks nice, then display the tidied up table of values? Or does every calculating code have to have its own code for checking and truncating the number, forgetting about the whole list and loop thing?
This was a bit too much nesting for me to find relevant guidance for. Whatever I've tried to write for truncating so far only gets me stuck. Any ideas, please?
I have this Applescript in the making:
• Dialog box asks user for numeric value input ➜ OK
• Based on given value, 25 different arithmetic operations are made and displayed as a table.
Some of these values come out with 12 decimal places which is way beyond necessary (2 decimal places max would do), and it also messes up the layout of the table because dialog boxes can only have so much width. How do I round and truncate results before displaying, if they have the risk of turning out ugly? I found guides on rounding, but I'm not sure how to use it when a), not every value has decimals and b) the values and to-be-ugly numbers aren't known until the function gets its numeric input from the user.
I tried to define each arithmetic operation into their own variables which I'd then scatter into the table and I made the collection of calculated values into a list. Taking guesses here, should I make a loop that would check every value in the calculated value list for decimals, take the ugly values one by one for a truncation procedure and put them back, end loop when all looks nice, then display the tidied up table of values? Or does every calculating code have to have its own code for checking and truncating the number, forgetting about the whole list and loop thing?
This was a bit too much nesting for me to find relevant guidance for. Whatever I've tried to write for truncating so far only gets me stuck. Any ideas, please?
Last edited: