2016년 12월 2일 금요일

2 DIM ARRAYS - REALLY LOST, pls help


I love this app, for someone like me its so great I can join in the "new world".

So, Im trying to create 2 dim arrays so i can use them as look up table,

How do i create string and integer 2 dimension variables?

How do I assign values to them?

pls help.

Many many thanks in advance.

-- 

How do i create string and integer 2 dimension variables?
How do I assign values to them?

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of AppInventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

-- 

SSN App HELP!!!


Once the user clicks the button, the contents of the text box should be validated and formatted using the following rules:

1. If the text box contains exactly 9 digits, a valid but unformatted number has been entered
a) Format the 9 digit social security number adding dashes so the format is 999-99-9999
b) Display the now formatted social security number in the text box
c) Do not display a message

2. If the text box contains only digits but not 9 digits, an invalid number has been entered
a) Display the message "A social security number must have 9 digits"

3. If the text box is not strictly numeric, check if the number was entered in 999-99-9999 format
a) The entry must contain exactly 11 characters
b) Characters 1-3 must be digits
c) Character 4 must be a dash (-)
d) Characters 5-6 must be digits
e) Character 7 must be a dash (-)
f) Characters 8-11 must be digits
g) If these rules are met do not display a message

4. If the above rules are not met
a) Display the message "A social security number must be in the format 999-99-9999"

-- 
A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of AppInventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

-- 
Pay particular attention to the builtin text blocks.

-- 


Add all items in a list


I was wondering how to add all items of a list. In my case I need to add together all items of a listview or tiny db.
Every item in the list is numeric and i need a result of them

-- 
One way is to use a for each item in list block and a variable to hold the total initialized to zero.
inside the for each block add the item to the total.
When the block exits the total will contain the sum of all item values.

-- 
Thank you for posting.

Because  I am a rookie I don't understand your definitions completely. 
Would you have the kindness to illustrate it with an image of the code?

-- 


Screen size issues


Hi ive just started using App Inventor and i have an issue with the screen size of my app. On my title page I have a label with the text being the name of my game which being size 22 font it fits perfectly along the width of the screen (im using portrait only for the app) on 1 line. Now when i view it on my JXD 7800b android tablet device - portrait way, up the text extends to a 2nd line as if the screen width of the JXD 7800b im using is much smaller then what is showing on the viewer. is this common that some devices are not correctly set up for App Inventor.

I have a background image for the title page and this image is 320x420 and seems to fit perfect so why is the text so way off?

Thanks for any help

-- 
Try scaling FontSize to a percentage of screen Width or Height.
A font size of 22 on a phone will look tiny on a tablet.
First, set the screen Sizing to Responsive.
Then set the font size to a percent of the screen height:

set MyText.FontSize to 0.05 * Screen1.Height

The text will now scale to the same proportional size on different screens.

Also, the Designer layout is a very rough approximation of what the screen on the device will look like. 
You must use the device and the Companion app to see what it will actually look like.

-- 
Ok tried that but there was no difference, the text was the same as it was before and when i set screen sizing to responsive then the text was the same but all my buttons i have on the screen shrunk massively and moved to the left hand side of the screen (with use of the table arrangement i had them centered both from left to right and from the label i have trouble with to the bottom of the screen). When you say size 22 font will be tiny on a tablet well thats the thing, its not tiny, the text is only a total of 21 characters including spaces and it does not fit cause its too big, bigger then it shows on the viewer yet the buttons dont seem bigger on my JXD tablet then it does on the viewer.

-- 
I guess what i need to do generally is ensure all text is set to a percentage of screen size to ensure it fits correctly to all screens and also dont use the viewer as a guide to how it will look but to connect to my mobile device when creating a screen to see how it will look.

-- 
Yes. Most visible components have a PercentWidth and PercentHeight property.
I recommend using those rather than Width and Height properties.

-- 
I believe that fully responsive text sizing (that uses dp instead of pixels or %) is yet implemented in AI2. One way I have used is to select a size that will not overflow on small devices but is still readable on tablets - something between 15-21 for text or 25-30 for headings. Since devices have pixel different densities setting text to percentage of screen can tricky.

-- 

how to make the user go back and next between screens


I have 6 background in the same screen. and 2 buttons (next and back) 
how can i make the user go back and next between these screens with only these 2 buttons  (next and back)

-- 
If your virtual screens are inside VerticalArrangements, for example, then have the components for each vertical arrangment in a list.
Then, using the Any Component tab and advanced VerticalArrangment Visible block, make the current vertical arrangment Visible false then select the next component from the list and make that visible inside your Next button.
Do the opposite inside the Back button.

-- 
thank you so much. i don't know how to make that praticlay.but i'll try. thanks

-- 

Clicking or touching table cell for editing


My objective is to make a table (3 columns x n rows) in which each cell is pickable for editing of text. The table code is HTML/JavaScript which is called from AI2 code when the screen initializes. Everything (including clicking and editing a cell) works with an implementation adapted for testing on my Win7 laptop. Everything except the cell touch for editing also works fine on my Android phone. I cannot get the app to respond to a touch from a listener (again, this does work on my laptop). To test, I included an alert() in my listener code but it never fires.

I have seen a lot of comments about click and/or touchend not being implemented or not working on Android. Does anyone know if what I am trying to do can be done in Android?

My listener code is:

// listen for a click
//listTable.addEventListener('click', function(ev){
// listen for a tap
listTable.addEventListener('touchend', function(ev){
    // get the event targets ID
ev.preventDefault()
    clickedTr = ev.target.parentNode.rowIndex;
    clickedTd = ev.target.cellIndex;
    selectedCell = listTable.rows[clickedTr].cells[clickedTd];
    selectedCell.setAttribute('bgColor', '#D3D3D3'); //LightGray, White is #FFFFFF
selectedCell.focus();
    if(priorClickedTd != undefined) {
         listTable.rows[priorClickedTr].cells[priorClickedTd].setAttribute('bgColor', '#FFFFFF');
    }
    priorClickedTr = clickedTr;
    priorClickedTd = clickedTd;
    selectedCell.setAttribute('contentEditable', 'true');
alert('cell tapped');
    },false);
// End listen for a click

-- 
Does anyone know if what I am trying to do can be done in Android?

I don't know...

but sometimes it's easier to use libraries...
I used the jEditable.js library  in my Editable example, see also my working example here https://puravidaapps.com/editable.php

-- 
Thanks 

-- 

Location Sensor - Grid references rather than Lat Long


Does anyone know how to go about converting the Lat/Long that the Location Sensor returns to a grid reference?  I'm specifically looking for British National Grid for use with OSGB maps.

-- 
I did a Google search for OSGB converter.
The first link on that page may work for you.
Is this question in relation to an App Inventor project?
If so, you might mention that next time.
If not, then your question is off topic.

-- 
Find an algorithm and we should be able to convert it to MITAI Math blocks.

-- 


How do filter a fusion table search?


Hi, I'm wondering if I could do this:
I want to have a search page where I would pull information from a fusion table. I have already done this, following Hossein Amerkashi's blog.
But I also want to have a filter button where users would pick from a list of states and once a selection had been made, the list would change so that there would only be entries with that particular type of state (e.g. User picks State A, so the list is: 'Apples ((State A) but the state is not displayed along with the item name)', Oranges', 'Workbooks'.).
If anyone could help it would be amazing!
Thanks...

-- 
send a SELECT statement to the table like this (assuming, there is a column named state and fruit)
SELECT fruit FROM <tableid> WHERE state = <listpicker.selection>

then in the fusiontable control got result event convert the received 1 column csv table into a list using the split block, just split at n (new line) and assign the list to the listpicker.elements

-- 
Thank you!


-- 

Undo Trashbox


Is there an Undo for the trash box? If not, is there one on the MIT list of ToDos?

--
there is no Undo, this is on the list

--
...and export your aia project to the pc as often as you think you have enough changes that you don't want to lose.

-- 

Shooting Game Problem


hello,

i am trying to develop a basic shooting game of android with app inventor2 ...i am facing problem to shoot multiple bullets please insist me.
thank you

-- 
This tutorial from Scott will help you https://groups.google.com/forum/#!searchin/app-inventor-developers-library/multiple/app-inventor-developers-library/78GQM2gXvnU/5_HatuHA6FUJ

I found it using the search box on top of this forum page, so we encourage everybody to search before asking, there's a lot of common questions/problems that has been answered/solved already (and you get your answer faster!)

-- 
i'll keep that in mind. thank you

-- 

list within a list within a list


I have a CSV file as follows:


 list.png



I'm trying to get into One of the Items inside the cell (e.g. B1 item 2  = 3) but the blocks do not read the list in the cell as a list. I tried enclosing them with paren and brackets but it didn't work. Is there a way for me to read item in the cells from the CSV file without having to manually create the list in AI2? My blocks below.

 error.png
-- 
after selecting the second item of the first row you get the text [1,3,5], which is not a list
you could now remove the brackets and use the list from csv row to get another list and the select the second item to get 2

Taifun

-- 
got it. As always, Thanks Taifun!

-- 
You can also use the Web component's JsonTextDecode block to convert that json array to a list:

 Capture.png
-- 

In Exchange Calculator App: Any way to raise an event upon text entry?


The idea is to eliminate the "calculate" button from my app, and instead the calculation is done upon number entry. 

The app is a currency exchange calculator, so a typical use would be "how many Euros would you get for 10 USD". I've already worked out how to pull in the current exchange rate for USD to EUR (ie. around 0.88), so I can check & store that 0.88 value in tinydb when the applaunches. What I want is instead of having a text entry field then a "Calculate" button, is just a text field, and every time I enter a digit, the "result" label will change. So using the 0.88 example, if I were to type in a "1" in the text field, the result label would display "0.88", and subsequently typed a "0" after the 1 the result label would change to "8.80".

All of the blocks for the text fields, result label & math for doing the calculation are already set up. I just can't figure out if I can raise an event upon every entry of a new digit in the text field.

-- 
Please check my unit conversion app. It calculates the conversion as you type, using a clock, which reads every time it's triggered what you have in your textbox and do the math.


-- 
New to this. Is there a way to see the blocks from that link?

-- 
Thank you very much,  I think this will work!

-- 

WebViewer


Hi!

I own a IP Camera, and i want to make an application through app inventor too see her video stream. The problem is that if i put her html page she doesnt play, and so on with her ip page, online stream platforms... Yesterday i knew that is possible to embbed html pages to your app using WebviewString. Im asking is its possible i can use this to stream my camera through my html page too app inventor with this function?

Regards, 

-- 
If you have an mjpg link to your camera, do this:
In your html, use  <img id="stream" src="http://000.000.000.000:port/mjpg/1/video.mjpg" width="350" height="239" border="0">

Replace 000.000.000.000:port with your IP and port numbers.

It worked for me in the past.

-- 
Hi
The link i have to my camera is not mjpeg or jpeg, is actually H.264 and i have to use a plugin to read the rstp link.
Do you know anyway to change your camera stream to mjpeg or anyway app inventor can stream H.264 based video?

-- 
What is the link to the camera? I made it work before using the webviewer, and the mjpg link to it. Do you have an mjpg link?
Create an html file with this in it:

<img id="stream" src="http://xxx.xxx.xxx.xxx:port/mjpg/1/video.mjpg" width="350" height="239" border="0">

Replace xxx.xxx.xxx.xxx:port with your actual IP and port.

Upload it to App Inventor 2 assets and open it with the webviewer.

Let us know if it worked.

-- 

I've been searching information about your camera, but like you said, it's very hard to find something useful.
Do you have a sample html page of a working stream for your camera?
Anyway, we are falling apart from the purpose of this forum. Maybe you will find more help in some IP camera forum, and when/if you find a link to the stream, all you have to do is what I posted in my previous reply.

-- 

on-screen map, Can I center the map on a scanned position by a qr code?


if I have an on-screen map, I can center the map on a scanned position by a qr code? I wish that when I enter the map to focus on my current location (using GPS) but can define my current position by scanning a QR code that has saved a google maps URL, you can do this with AppInventor?

-- 
If you can get the qr code to return either an address or the lat,lon then you should be able to feed that to either the activity starter or parameters in a url.
I found this barcode scanner app in the Gallery.
There are others.
hello,
thanks for response, the link in "I found this barcode scanner app in the Gallery." not works for me, is a link to a source code of an app?

where you find all these source codes and apps?

Regards

-- 
Click the Gallery menu option at the top of the App Inventor window.
Then type in barcode in the search box to see related barcode projects made by other users.
You can download the project and use it as is or modify it for your needs.

-- 
ok, thank you very much, and another question (I'm new in appinventor), how i can test the projects of gallery in a test device? have any tester appinventor?

Thanks

-- 
See option  2 here.

-- 

Cannot parse text argument to "list from csv row" as CSV-formatted row (sequel)


Taifun and ABG, the other post closed due to inactivity.
I'm very busy with school etc..

But as an answer on Taifun's post:

you can't use Do it together with local variables
as you can see, package $text does not help very much
this is, why ABG mentioned, what you can do to display the value of a local variable (for example in your File.GotText event)
"Add an extra global variable called TaskListText, initially blank.In the File TextGotten block, when the text arrives,capture it in the new TaskListText variable,and feed the new variable contents into the csv conversion block."See also Scott's tip How to use 'Do It' to view procedure results, event arguments and local variables.
and instead of providing 4 similar(?) confusing screenshots, what about providing only 1 screenshot with the relevant information?
Taifun 
I don't know what I'm doing, so I don't know if I'm doing something right or wrong...

The only result I'm getting is: Do It Result: (package $text)
As you can see with the attached image.

And if I'm using DoIt with the call.ReadFrom I get the error: "Cannot parse text argument to "list from csv row" as CSV-formatted row"

Is it me? Am I doing something wrong? Because I don't understand you guys precisely.. I'm sorry for that..

test4.png 표시 중

-- 
 Capture.png

You have it set up correctly. I think that the problem may be that you have not run the File_Tasks.ReadFrom block before testing the value of TaskListText.
Try right-clicking on the File_Tasks.ReadFrom block and choosing Do it. then go back to the get global TaskListText block and 'Do it' there. 
You should see a value returned then.

-- 
If I do that the value is: *empty string*

Also, when I click DoIt on the File_Tasks.ReadFrom block I get the error message.

-- 
It looks like the File_Tasks.GotText block is not executing.
Are you sure that your text file name //TL350.txt is correct and that the file is in fact a text file and not a binary file?

-- 
Yeah, I'm sure.

I made it with Notepad. Don't know how it made a binary file, if that is the problem? And how can I see if it that is true?

-- 
If you made it with Notepad, it will be a text file as that is the only format supported.
So this is another dead end...
Maybe send me the aia file or attach it here and I will test some scenarios?

-- 
It's gives me a headache :D

Thanks for your help anyways!
It is in scr_gekozen

Don't mind the names etc. I'm Dutch haha

Thanks in advance!


-- 
Maybe you should try the attached?
ABG
2016-04-03 19_00_39-MIT App Inventor 2.png 표시 중

-- 
Here is the debugged version...
I massaged your data file to remove any double quotes and substituted the ` character for apostrophes.
I also treat the file as a csv table rather than a csv row which will give an error when the data is on separate rows.
So you must use list from csv table.
So now each activity the player must perform is a single field value on each row in the list.
Use select list item to get the row in the list then select list item again to get the actual value from that row.


-- 
@Abraham
list from csv table throws an error also with his original text file.
There was a character or characters in his data file that was tripping up the conversion.
I removed any possible problem punctuation like " and ' characters inside the text of each row and surrounded each data row with double quotes to force each row to contain one field.
That seems to work.

-- 
Yes it works!

You have found the solution! I know now the problem... It was so simple..
As you said, the ' and " tripped the conversion. That was the only problem.

With your solution the tasks would display like this: (task).
That would be ugly. (but thanks for your help!)

I have edited the .txt file and changed ' and " into `. I also threat it like a row seperated with commas. It works! (I've also placed them as a row)

Thank you so freaking much! The app was almost finished, but this was the only problem..

So much thanks!!!!

-- 
To get rid of the parentheses around ( task ) use another select list item (listname, 1)


Happy Inventing!

--