
WayneA
USA
Asked
— Edited
Good Afternoon,
I am looking to create a numeric keypad within EZ-Builder. 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
When i have some time i will see if i could come up with a similar interface and share the project with you.
Another thought that I had was to to just setup a string value, lets say $N. Create my 10 buttons and each press of the button would make the string value of $N = "1". Every time the $N value changed store that into another string separated by commas. Depending the amount of commas and the amount of numbers contained in the string, the output would equal to for example "444".
Then, another thought I had was to shift the string value down. (I am taking an online course to help me get the basics of code - Covering Left Shift Bits and Right Shift Bits.)
Then another thought was to re write my project to just press a button and CC("444", scriptstart )
For each button have a script like this one (this example is for number 4)
Code:
To change for other numbers simply replace the 4000, 400, 40 and 4 for whichever number you are writing the script for. I.E. For number 2 use 2000, 200, 20 and 2. For 1 use 1000, 100, 10 and 1.
After each button press the sequence is increased so the scripts will know what value to add to the keycode.
You also need the script running that will trigger the requested scripts or actions when the code is sent to it. That's the other script I posted. You could have up to 10,000 different scripts or actions triggered which would require 10,000 IF statements. Obviously I haven't included all 10,000!
This is the script.
Code:
When the sequence in the number scripts is complete it resets the $sequence variable to 0. The above code waits for that to become 0 and then checks the sequence and runs the code between that sequences ELSEIF and the next ELSEIF. If the code doesn't match it runs the ELSE code so you needn't do all 10,000 statements.
At the end of the above code it resets the sequence to 1 again so the keypad code number scripts know the digit position. It then loops back to the start and waits for the sequence to be set as 0 again before it moves past the WaitFor line.
Most of the work is done for you above you just need to change the script for each number for the keypad code and fill in the ControlCommands in the second script above.
The cancel button code would be
Code:
Calculator - Mobile Interface
The only thing wrong with it is that there is no decimal point and that you have to hit equal after each operation excluding the initial number input.
Code:
This code is called when a button is pressed and the value of currentnum is changed to the number on the button you press. To run the calculator you would need to declare the variables first by starting the script "Variables".
Code:
What if you wanted to shift or move down the input data to another string variable? Would that depend on the $order string variable right?
Code:
$order++ means you are adding the number one to it right
Code:
you don't need the power function... but what this does is when you press a key it will move the first number entered to a new column and then add the new number pressed.
so if you press 1 the entered number is 1
if you press 2 the entered number is now 10+2=12
if you press 3 the entered number is now 120+3=123
that way it is just like a calculator when entering numbers on the keypad.
the entered number is stored in $number you can store this value in a different variable if you wish but it would be an integer to start not a string.
and order++ increases the amount of digits stored in $number... so by resetting order to 0 you enter a new number into the $number variable.
a script to look at the count?
Code:
So...
Code: