2017년 7월 28일 금요일

Capitalizing first letters of each word


What is the command to capitalize only the first letter of each word entered into a text field?

--
possibly  (in pseudo code)       if length textbox1.text = 1 then upcase textbox1.text

that gives you the first word typed.    to get successive 'first' letters, you may have to keep track of the spaces and write a routine to capitalize the first letter after a space.

try it, it might work.  Did it work?

--
If you are expecting multiple words, separated by spaces,
run a counter  i from 2 to the length of the string, to locate each letter
for the segment block.'
Use a for loop for that.

Capitalize the letter at position i  if the letter at position i-1 is blank.
Also capitalize position1, the special case outside the loop.

Check your text block drawer for upshift or capitalization blocks,
and for the block that lets you replace text in a string.

--
I’m new to all this, and I barely know how to use the blocks that the App Inventor site provides us. Will you be able to explain in simpler terms? Or perhaps which blocks I should use?

--
I just added a post  HERE that shows blocks for accomplishing this.

--
nice example...
but if your purpose was to keep the blocks simpler, you should have chosen a local variable instead...

--
How do I create the purple command box (“call capitalize text”) that you laid out on your site? I can’t find it on AI.

--
That is a procedure
You may want to go through some of the tutorials HERE

--
Read this:  AI2 Procedures

Try some of the blocks.  Clicking the blue icon with a right click exposes additional properties.    You name the procedure by typing over the words in the where it says procedure.    ..and yes, do some of the tutorials as suggested by Hossein; this method to create special blocks is explained in one of them.

--
Could you tell me what I'm doing wrong?

--
Your result is cap and not text

--
I'll add explanation in my blog here: Tips&Tricks – Capitalizing 1st Letter of Every Word

--
See the updated post that now includes explanation of blocks: Tips&Tricks – Capitalizing 1st Letter of Every Word

Will you please explain the arrow you drew?

--
If you are trying to duplicate Hossein's code exactly ... the arrow shows where your code is different from Hossein's blocks.

The block above split at spaces is initialize local cap to   in one instance and  set global varTemp to in the other instance (your code) ..  this is where possibly you too should have the s initialize local cap to block.

Is this your mistake, or do you want to do what you did.    I do not know, just wanted to point out the difference between the code blocks in the example and your code  (ignoring the variable names you introduce.  

--
as already said, use cap instead of text

--
Thanks, everyone. You helped me find what I was doing wrong, and I figured it out.
You all are the best.

--
I read one of the items on the checklist to publish my app, and it was to have it tested out before it goes up on Google Play. Since all you gentlemen were patient and kind enough to help me build my very first app, I was wondering if you all would like to test it and to provide feedback.

--

search results for Capitalize First Letter.


This can be very simple Ivan. The above blocks will change a01234 to A01234 , place these three blocks immediately prior to executing your sign in ...
If you are expecting multiple words, separated by spaces, run a counter i from 2 to the length of the string, to locate each letter for the segment block.'
Use the upcase block from the text pallette.. This will capitalize all of the text: This will Capitalize the first letter, and then make everything else ...
Capitalizing the first word in a text box by touching the microphone on the keyboard is probably not possible with App Inventor. You could use the ...
Welcome to the App Inventor 2 Power Users FAQ. Frequently Asked Questions about programming in MIT App Inventor 2, and answers to those ...
Would there be any way to incorporate the keyboard settings for text boxes/fields as described here?
@Sander,. See my post below which shows how to capitalize first letter of every word. It may help you with what your you are trying to accomplish.
App Inventor cares about capitalization, so what you might try is using the upcase block on the result and then in your piece portion of contains ...


FAQ for text


Tips&Tricks – Capitalizing 1st Letter of Every Word


It was asked how you could capitalize 1st letter of every word in a sentence.
Below is a procedure that can take any sentence and will capitalize first letter of every word. For this, I have created a procedure-with-return called “capitalize”. The procedure accepts an argument “text”, performs some functions and then returns a result. This means we can invoke the procedure and pass it some Text data, and then expect it to return a result. When invoked, the “capitalize” procedure
1. Initializes a global variable “varTemp”
2. It then uses the “split at spaces” block to split the Text into pieces separated by spaces (i.e. splits into words). Once split, it will assign the List to “item” variable
3. Next, we use a for-each block to loop through the newly created list of words. For each word,
   1. Using “segment” we extract 1st letter of the word and convert it to upper case
   2. Using “segment” we extract rest of the word starting 2nd position
   3. We join (i.e. concatenate) varTemp (see 1)  + 3.i + 3.ii and add a blank space to the end
4.  Once the loop is completed, we use “trim” to get rid of last blank space and then return the result to the caller

image
  
Variation

Update above procedure to use local-variable instead of global. For purpose of tutorial, to keep blocks presentation simpler, global variable was used. Try to use a local-variable for the procedure.


TextUtils extension


TextUtils extension will allow you to quickly perform such functions as:
⦁ Reverse a text to read from end to start
⦁ Title Case sentence
⦁ Format number for thousand separator and to include decimal points. This will also use proper country-based formatting!
⦁ Compare 2 strings to find if they are equal – can also ignore case
⦁ Perform search using Regular Expression Search on Steroid :

Wanna split / chop / perform Regular Expressions on TEXT (String)? Then use ReplaceRegex block like shown below:


Looking for .aix? Get it from AppyBuilder community HERE  com.appybuilder.TextUtils.aix

Capitalize First Letter.


I would like to know how to capitalize the first letter in a user ID input text box.  Eg. Change a01234 to A01234 when user types in the ID.
 My understanding is that I would most likely need to place a Procedure in my When TextBox1 .Got Focus block, But not sure how to achieve it.
--
you might want to use the TextUtils extension from Appybuilder

--
There's no Submit button?
That's typically where you would put cleanup and validation.

Also, if the only alphabetic character in the user ID is the first one,
you can just set Textbox1.Tex to upshift(Textbox1.Text) (in the text blocks, maybe different name)

BTW, that's an awful name for a Textbox.
You can rename it easily in the Designer, and every reference will follow.

--
Also see post here:
--
(added to Text section of FAQ) FAQ for text

--
Celebrant_Connection is actually the submit button which which calls the URL. I have now renamed to Connect to comply with your comment. :-)  I will experiment with your comment regarding resetting TextBox1.

-- 
Thank you for the tip.  I have had a look at the TextUtils Extension and it has some interesting capabilities.  Is it possible to download the extension and use it in App Inventor2?

--
Yes, it works with MIT AI2. 
Extension link is at bottom of blog post: TextUtils extension

--
I have downloaded and installed the extension.  I just need to work out how to apply it to my blocks so that when the user inputs the ID with the first letter in lowercase into the text box, the extension will automatically convert it to upper case. 

--
This can be very simple Ivan.
The above blocks will change a01234 to A01234  , place these three blocks immediately prior to executing your sign in but after 
the user types all the pass code. and before he/she presses the 'execute' button or whatever it is called.

This simple code will work for you because you only have a single alphanumeric character that needs changing; upcase will leave the numerals unchanged.

--
Steve, the upcase will convert all alpha to upper. It'll work for a01234 to A01234, but not when word has multiple alpha chars. However, given @Ivan's requirement, it may be sufficient for him.

--
FYI, see attached that shows result when using TextUtils.TitleCase.



--
@ Hossein      Hi.   Correct, upcase converts what Ivan wants using native AI2 blocks.   No reason for him to deal with loading an extension. Native blocks in this 
case results in a cleaner app because all his sign in codes have the form  A1234.

--
Yes, you are correct.

--,
Sincere thanks, 
That code worked fine, I was on the right track myself but was putting the code in the wrong block.
All sorted.  Ivan :-)

-- 
Thank you for your help.  Steve's idea worked for me, as I said to Steve I had it right but in the wrong block.
I now have the Text Utils extension installed so I am going to have a play with it.

-- 

Basic Digital Compass


This project uses the OrientationSensor component's Azimuth property to display the current magnetic compass heading value  and by rotating an ImageSprite 'dial' on a Canvas.
Component blocks:
⦁ Canvas
⦁ Clock
⦁ ImageSprite (2)

Language blocks:

⦁ Math +,/,floor,=
⦁ Control if


--
I'm not sure, if I understand the purpose of your example compared to this simple solution http://puravidaapps.com/snippets.php#2compass
Nice! I had not seen that. You ought to do a video to show it off :)
Getting declination from latitude, longitude, altitude and date and time might be a bit tricky with AI blocks.
I did a crude approximation for another project with C a few years ago.
I saw that iPhone comes with a compass app that compensates for declination by default.
We have some catching-up to do....

--

Tutorial:Calibration of Background Canvas Image and Proper display


I'm sure this can be used for more than just graphs, but I wanted to make a lot of peoples lives easier.  This is the most Barney-style breakdown of how to do this.  I went through a TON of examples and could not for the life of me understand what I was doing wrong.  Course I have also been doing about 28 hrs every 2 days of work on this Aircraft Weight & Balance thing... Here is the most complete information I can provide.  Hope it helps ya'll out.

--

Ok Been a while for my Weight and Balance app


Ok, I'm back lol.  Got a mundane issue, but an issue none-the-less.  With all of my selections done (ie:personnel weights, aircraft tailnumber selection, etc.) and all data inputted, when I go to graph the information, the graph is blank.  However, when I duplicate the exact same action again, it graphs.  It only does this for the initial graphing onto a canvas.  after the single blank, I can graph any number of items without having the blank graph show up. Any suggestions?  Can't really do a screen shot of the blocks because I'm not sure which of my several thousand blocks is causing the issue.  Just wondering if anyone has had this issue and if so how they fixed it.

--
This is a stab in the dark - 

Do you draw your first graph in Screen1.Initialize?

If so, and if you are basing it on the sizes of 
Screen1 and any canvases or arrangements that inherit
screen sizes, you may need a little delay before
those sizes are available.

The fix for that is to put the first draw into a clock routine,
triggered very soon after Screen1.Initialize.

--
Well upon multiple hours of searching, I found all blocks associated with the draw and clear of said problem... Still doing it, not sure why.  here are the blocks






--
Here's another stab in the dark - 

If you are using multiple screens, you are probably passing
graph data thru TinyDB.

Is it possible you are calling the graph routine BEFORE you
are populating TinyDB?  That might lose the first graph,
but allow subsequent graphs.

Regarding your block shots,  a Designer screen shot for each
screen, with sizes of canvases and their enclosures might help.

Also, a screen shot of the emulator with and without the error
might help.

--
I'm only using one screen, I am just showing and hiding layouts.  I don't think it is calling graph before data is there, I'll check that but I have it so the graph portion is not even available until you have selected an aircraft that is already saved, and upon aircraft selection it fills in the fields for that specific aircraft so it shouldn't be, but again I thank you for taking the time to assist.  I'll let you know what I find.

--
Here's another stab in the dark, based on more info - 

If you are using multiple visible/invisible layouts,
having the canvas visible at build time might be
critical to having its dimensions available to 
blocks at startup time.

When I was building my Hidato Helper app for the
AI1 Gallery, I had that issue.

It should be easy to try.

--
tried switching all the plots around, didn't fix it :( ah well I'll just live with that for now I guess.  When I'm finished with everything else I'll get one of my java coder friends to tweak it for me in the final APK.  From the look of it, when I expand it out to a GPS flight path tool also that will have to be external coding :( can't find any info on getting the links to aircraft sectionals...

--

search results for Aircraft Weight & Balance


You MUST have some recursion going on there... Just look for anything that triggers a listpicker or a choice of some sort and that should lead you to ...
Ok, I'm back lol. Got a mundane issue, but an issue none-the-less. With all of my selections done (ie:personnel weights, aircraft tailnumber selection, ...
I'm sure this can be used for more than just graphs, but I wanted to make a lot of peoples lives easier. This is the most Barney-style breakdown of how ...



search results for intranet app


Hi,. my company will change our Black Berry phone with Android smartphone and I want create one app like a dashboard of my activity. Is possible ...
See the announcement for more information and read the App Inventor Extensions Document about how to use an App Inventor Extension. You have to use the extension ... app should work fine. If yes, access it via intranet. If not, via ...
I am trying to build a simple app that pulls up a product number on my intranet. I have the code blocks built to open the page, ...
I would to create a table or send some data or update the data of my big database, in something on internet where my app can connect and download fresh entry. Unfortunately my intranet access in internet only at port 80. Can you ...


Ordered Search and Lookup


Abe Getzler
Sep 2016

Purpose
This doc shows how to present a sorted lookup table to a user in ten step wide (customizable) zooms, for logarithmic speed lookups.  The original data used for this sample was taken from a two way translation app, so a choice of translation table is offered at app startup.  The two languages I will call French and Shinimare (I haven’t heard from the table author what the second language is called, so I am guessing here.)


Sample screens



This is a pretty simple screen layout.  A List Picker chooses which conversion table to load, by user-friendly name.  A second List Picker presents the table’s first column at successive zoom levels until the lowest detail level where a single element is chosen and its translation (column 2) is shown in the label.  Notice in this sample that half our ranges have only a single item in them.


Designer



Besides the two List Pickers and the Label, I have two File components, one for the friendly directory of translation files, and another for the actual translation file.  Both files are in csv table format.  A Notifier is included,to show the Progress Dialog during the slow tale load process and reassure the user that his app has not gone dead during the file load.

Screen1.Initialize


At startup time, we need to load the directory of translation tables.

Lists.csv


French to Shinimare,db2.csv
Shinimare to French,db2inv.csv


Column 1 contains the friendly name, and column 2 contains the file name to be loaded (independent of path).


When File_Lists.GotText
When the very small lists.csv file arrives, it is loaded into global fileMap as a table, then the first column is split out into the global fileTitles, for presentation in the first List Picker.


First
This is for convenience, to keep my blocks small and simple.


When lpkFile.AfterPicking
After a translation file is chosen, we build a file name from ‘//’ (for Media File access) and the lookup result in our newly loaded global fileMap.  We initiate the file read using the FileData control, and announce what we are doing, in a Notifier Show Progress Dialog, the lpkFile.Text , and in the lpkView Text.


When FileData GotText
This section receives the huge text from loading a translation table.  Some people like to send their text directly into a csv to table block for simplicity.  Because I am not sure my input table is robustly formatted, and because I have to make a second pass through it to load just column 1 into another list, I am attempting to do this in one pass.  Feel free to change this if you can get it to run faster.


When we are finished loading, we should have two important global variables loaded:

⦁ Pairs contains the complete table (selected word, its translation) and
⦁ Words contains the contents of column 1 of the table Pairs, for use in a List Picker.


After the global lookup table is loaded, the Progress Dialog can be dismissed.


The global Stack is initialized with the furthest possible zoom out of our pairs table, from line 1 to the last line.  The SectionName value procedure is used to build a text string expressing the range, as First Word [...] Last Word. The List Picker lpkView Elements are loaded from the Stack.


sectionNamesectionName.png
This routine receives two parameters, fromLine and toLine, specifying the starting and ending line numbers in the lookup table pairs, looks up the words at those two locations, and expresses the range as those two words separated by a fixed string “[...]”, which will be used later to split the two values after selection.  The separator had better be unique, and not in the lookup table, or it will mess up the split.


If the range only has one line in it, then just the one line from words is returned.


when lpkView AfterPicking
when lpkView AfterPicking.png
The List Picker lpkView does the work of presenting search range options to the user and zooming in on each successive Selection he makes.


Two local variables, from and to, are loaded with the line numbers in the pairs table holding the front and back parts of the Selection, splitting the Selection at the “[...]” string.  This reverse the effect of the sectionname procedure.


If from equals to, we have zoomed in all the way down to a single word.  We show the word and the translation result on the screen.


Otherwise, we have to apply Divide and Conquer to the selected range, dividing it up into smaller ranges to be presented at the top (location 1) of our Stack.  This is like branching out from a branch to smaller branches, so I call the smaller branches leaves.


From
From.png
To
To.png
The From and To value procedures take a sectionName selection string and try to split it at the separator string ([...]).  A list of one or two items results.  The first (From) or second (To) item is looked up in the words list, and its position is returned.  The max function is used for bulletproofing so we don’t fall off an end of a list.


Leaves
leaves.png
This procedure returns a list of sectionNames to be added to the Stack and presented to the user as he zooms in from his current step.  The from and to  parameters define the starting range to be divided into subranges.  (The stack parameter is defunct, oops).


A local value step is calculated by dividing the length of the current range (to-front) by our zoom factor, from global maxChoices (currently 7, change it to 10 for faster wider zoom, for example.)
We avoid fractional line numbers.
For each n from to down to from by step (at least 1), we add to our result the sectionName of the range (n-step) to n


The resulting leaves are inserted at the front of our Stack, and presented to the user in the list  picker lstView, which is re-opened for convenience.


The old section names at the bottom of the Stack are there to act as bread crumbs, to allow the user to back out of an undesired selection.


Stack
Stack.png
Source code


Sample file
sample file.png


More Projects