I think Dave’s solution is the best, and I have said many times that using the clipboard for this sort of thing should be avoided.
That said, this could be done using the clipboard, just make sure the clipboard value is converted from text to numeric using the val( function, like this:
Wait a minute – does this mean that the current field is a text field? I would think this should be a numeric (integer) field. I am really, really surprised on a couple of levels that this code ever worked in any version of Panorama.
Let me reprise (from older posts) the two major reasons why the clipboard should be avoided for calculations like this:
- First, doing this clears out whatever value was already in the clipboard. If you Command-C to copy a value into the clipboard, you expect that value to stay there until you use Command-C again (or Command-X). Using the clipboard for a calculation breaks this feature of macOS.
- Secondly, the clipboard is waaaaay slower than using a Panorama variable – like 100x slower. There’s a lot of overhead in accessing the clipboard from macOS. For this short program it doesn’t really matter, you wouldn’t notice the speed difference, but if you ever used it in a loop you would really notice. So it’s a good habit to avoid it.
The only time I would recommend using the clipboard functions is when you specifically want to interface with the Command-C, Command-X and Command-V keys.
Bottom line: Dave’s code is the way to go.