2017년 7월 11일 화요일

custom keyboard


Today I made a custom keyboard! It works really good.
But there one problem. When I tab in any number, it stands in brackets. In the result of this problem is that the entered number cannot be compared or used.
 As you can see in the picture of my "code", I use a list to be able writing numbers over 9.  

I already searched for a solution in the web but i couldn´t find anything.
--
Cool.  
The problem is you're setting the .Text of the label to the value of Eingabe which is a list.  AI does the type conversion for you and represents the List type as text (String type).  Instead of getting 123 you get (1 2 3).
You need to either convert the list into a string by using a loop block and parsing out the brackets and spaces, or use the Text Join block in your click events to store the input as text rather than a list.

--
Thank you!
The "text Join Block" was the solution.
Do you have an idea how just the last number of the complete number could be deleted?

--
Use 

segment text
and
length
Remember you're actually dealing with text. Other languages call it 'string data' as in a string of characters. That the characters are numeric characters is inconsequential until you start to do math on the values represented. AI converts automatically so "9" + "9" = "18" and not "99" If you're new to programminghere's some reading about data types. AI has very weak Typing.

--
How is such a lenght block defined? -1 doesn´t matches.

--
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

--
So in the marked part of the picture you can see a summary of my bad tryings. 
In this case I don´t know how a lenght block is defined.
I tried to say, cut the lenght to one number.

--
All your answers are here
:)
Also in the Blocks editor just hover over the language block in question to get the quick version of how it works.

In the segment block:
 'text' is the text you're segmenting. In your case that's your global Eingabe.
'start' is the starting point in the text string for the piece you want to pull out.  In your case that's 1
'length' is how many characters your want to pull out.  Here come's the fun part...

The length block returns the number of characters in the text string you give it. Snap your global Eingabe to the 'length' block and it becomes number of characters in the string of text it contains. You want one less than that so add your math block. 
--
Thank you again! (:
Be honest with you, did you know that yust from the explaination in the Blocks Editor? Or is my english knowledge just to bad. :D

Here the Result of the Back Button!
--
Perfect. 

--
I would like to make the keyboard input look more pretty, by doing blanks between every thausender step. (1000000 ----> 1 000 000) 
How could i do this? 

--
Since numbers will not display with formatting and you can't do math on space characters, You'll have to create a pair of procedures, I'd use ones that produce a result, to insert/remove the thousand separator.  Hint - Use text blocks Segment and Join in a loop. There may be someone here that has already done this and has sample code (Taifun?)

Note: In Canada, US, ..?.. the separator is a comma not a space so you might want to use a variable and, in the screen initialize block, load the correct character based on the device's region.

--
Here's a Thousandizer routine, with test examples.
See attachments.

To have this happen dynamically while you type,
you would need a fast clock routine that checks for
changes to your input, then if it changed,
run the text thru a routine that strips the separators,
then again thru the Thousandizer for a fresh format.

It's simpler to just take all the digits, and wait for
a Okay button click to reformat the entire input.




--
Whoops -

I just realized my Thousandizer is buggy.
If presented with 1024 it would lose the zero.

I should have used string functions instead of
remainder functions for my front/back split.

You get the general idea.

--
Here's the corrected version of my Thousandizer, with an extra
routine "nnn" to format numbers less than 1000 with leading zeroes.
See attachments.



--

댓글 없음:

댓글 쓰기