I am taking my data from a website by mouseclicking in the predefined region and copying the number to clipboard. Usually this works perfect, but sometimes during the site refresh doubleclicking and copying to clipboard either take no data, or take non numeral data (some kind of text near my needed number). After this my conditional formulas do not work and I receive the message like this:
After this the program stops till I press OK, but continues to work after pressing. This is no problem for me if sometimes this happens, but problem, if the program stops.
Can I check if the variable is number? I can check if the variable is assigned by "Assigned", but if my mouseclick take text data, the Assigned function give TRUE, and the script continues and stops on IF condition when comparing the variable with number.
Also, maybe there is some way to prevent from these messages to appearing and the script from stopping? There is no problem if one iteration of my script is bad, the next one will surely take good data, and the program will run correctly.
Checking if variable is number
Moderators: Dorian (MJT support), JRL
Re: Checking if variable is number
Still unable to resolve this. Maybe there are functions that force the script to restart is such an message or error appeared? It looks, by pressing OK it continues to run even if there is wrong data or no data, and on second iteration it surely get the right data.
So, can I force my script to restart if this happened? Or force not to stop and give me a message?
So, can I force my script to restart if this happened? Or force not to stop and give me a message?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Checking if variable is number
A simple %value%/%value% is a way to do it.
Code: Select all
Input>value,Type value,0
If>value=0
Let>CheckValue=1
Else>
Let>CheckValue=%value%/%value%
Endif>
If>CheckValue=1
MDL>Value is a number!
Else>
MDL>Value is NOT a number!
Endif
Last edited by Grovkillen on Tue Sep 19, 2017 6:52 am, edited 1 time in total.
Re: Checking if variable is number
Add the line:Or force not to stop and give me a message?
Let>ignoreerrors=1
Somewhere ahead of where your error occurs.
Re: Checking if variable is number
Isnumeric
or
I use regex to check the first character is a number. If not a number, then try again.
You could even invalidate the result if it is not only a number.
RegEx>\b(\d).*,0,match,res,1,$1,ResVar
PepsiHog
or
I use regex to check the first character is a number. If not a number, then try again.
You could even invalidate the result if it is not only a number.
RegEx>\b(\d).*,0,match,res,1,$1,ResVar
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!