I'm trying to write a simple AppleScript to do some text manipulation on the contents of the clipboard. The following code works only if the text in the clipboard can be converted to a number:
set CB to the clipboard
set bugNum to CB as number
But if the text in the clipboard is not a number I get an AppleScript error: "Can’t make "foo" into type number."
How do I write an if condition that I can use to check if CB (of class text) can be converted to a number (and put the "set bugNum to CB as number" inside that)? Or can I "catch" the error somehow?