
WayneA
USA
Asked
— Edited
Good Afternoon,
I am looking to create a numeric keypad within ARC. I want to pre-program a script for example 133. How do you combine the numbers into a string value, and that value is a number?
Thanks WayneA
One method would be to use simple math.
First digit is hundreds Second is tens Third is units
So, take the script, when the first number is used multiply it by 100 and add it to the register. Second, multiply by 10 and add to the register and finally add the third to the register.
Something like (this is just the math part, receiving the number data is a different matter):
Thank You Rich,
To go one step further, my keypad would be 0-9. My thought was to make it easy by using just one string value and combining that, but looking at your script above, that wont work.
So, how would you get the data into the string values?
I presumed it would be 0 to 9. You end up with a 3 digit code which varies between 000 and 999, it's a numeric value at the end of the day which can be used. Failing that, use quotes to associate the number with a string rather than a value. "1" + "2" + "3" = "123" whereas 1 + 2 + 3 = 6.
Getting the data to the string will totally depend on the keypad and how it works, how it's connected, how ARC is aware of the activity on the keypad etc.
What is the best way to configure the buttons?
I need more information on the keypad to be able to even think about how to answer that. How does it work? How does it connect to the EZ-B or the PC? Is it just 10 push switches or does it have it's own PIC? etc. etc. etc.
where would the entered number go? is it for calculations?
No, I would use the button from the Mobile Interface. When you press the button, my first thought was to create a string value. Imagine a your tablet with buttons in a layout of a simply keypad. The button press would make $Button1 = "1" . In my main script I would declare that $Button1 = "". Then somehow recognize that change into an if then statement. Then use that if then statement to ControlCommand the numbered script. No hardware keypad all use from software.
Hope that clears things up.
Sorry I misunderstood, I thought you had an actual keypad.
In that case it's easy. It's a lot of scripts which are pretty much the same but it's easy.
For instance, button 4 script would be;
Button 0 would be;
However the $keycode = $keycode + 0 lines are redundant.
Your keycode script would also need to be running;
Each button script will check the position in the code and add the correct number to the position. The other script will loop, wait for the sequence to be finished and then check the number, run the required code, reset the sequence to 1 and wait for a completed code again.