2015년 1월 10일 토요일

How to use videoPlayer

I want to playing the video  

using the videoPlayer and The extension of the video I want to know something



Maybe you can search the forum and the documentation first. There are plenty of answers to your question. Then, if you built something and have a specific problem, come back and you will get specific advice.




Quiz Question Random logic

I make the index of question that have 5 question.then in the screen, i will make 3 question that call random from the index. And when the 3 question has correct answer, then the screen will mobe to another screen. How this logic? Plese help the built and step to make it :(



Did you do the tutorials, for example:
and:
?
If yes, show us what you tried by posting your blocks. Only then can we help you.


aiStarter not running


I have installed aiStarter (win XP) without changing anything. But when i try to run it, there is an error message that says that the application has a problem and it has to be stopped. More informations:  "AppName: aistarter.exe  AppVer: 0.0.0.0  ModName: aistarter.exe
ModVer: 0.0.0.0  Offset: 00007fee"

Can you help me with this;

--
Something appears wrong with the version number Dionisis.   Did you install/download from this link: Installing and Running the Emulator in AI2 ?

Then you should have gone, in Part 2 of the instructions gone,  to the Windows link (because you have Xp) here  Installing App Inventor 2 Setup on Windows

What version of aiStarter did you download?   It should be the one here  
  1. Download the installer.

and will be named something like AppInventor_Setup_Installer_v_2_1.exe  or 2.2 or so.  Is that the version of aistarter.exe you used?

Check if aistarter is in the correct directory...on my Win7 PC it is here, on your Xp PC it will be in a different location.
Did you install to the default location?   If you did not, do not use the uninstall.exe if you got it on a different drive (the uninstaller will, in that case, uninstall everything in the folder it is located in).  

--
Thank you Steve for your answer.

I'm sure that i've done everything right. I followed all the instructions. I' ve tried again and again but it doesn't work. I give up. I will try something else more easy for my students.

--
OK, sorry AI is not working for you....   Somewhere, you probably did NOT do something right or there is a hardware issue.

If you end up programming for Windows (instead of for Android), may I suggest something called Lazarushttp://www.lazarus.freepascal.org/  ... it is Pascal language based object oriented programming for Windows.  It is free and interesting enough it is now for Android too ....check it out. http://wiki.lazarus.freepascal.org/Portal:Android     Interesting, I did not know they added an Android capability.

--
I just got up and running and it would not work on one machine but I tried another and it worked..... you figure!

--
Great.  Could you explain "it would not work on one machine but I tried another and it worked.?"   Does this now mean that it AI2 and the emulator is successfully running on both your PC both from home and at Stanford?

What did you do to make it work on the new PC?  Thanks.

--

Wifi connectivity

can i use wifi as a connectivity resource in my application?



Wifi connects you to the internet. Therefore you can connect to anything that will act as a server to the client which is your phone. Could be a local server on your PC though.
What would you like to achieve?



This explains how App Inventor connects over WIFI :   http://appinventor.mit.edu/explore/support/explain-wifi-connection.html



Whether you will be able to control your home devices will depend or those devices. They should offer a way to connect to them via wifi and an API you can use to do the control. And if you want to control them away from your house, they should offer remote access. Study their documentation!
If there is a yes to the above questions, then yes, you can make an app with AI to control your home devices.


Re: Web form report: Receiving script errors upon signing int...

I have this exact same error.  I have used Chrome and Firefox on two different computers.  Sometimes I can work through to my app, but mostly not.  I finally finished my app last night, but now I cannot get back to it to build the app for market.  Very frustrating.


How to make a cancel button?

Hi, could somebody look at my code, because I have tried but it doesn't work and I have no clue on how to make the cancel button.Basically, if someone makes a booking, they are to able to click on the cancel button and clear their recorded that they have made. 

Could somebody help me please?





Does the other code work? Can you make a reservation OK?
 Try to get that working first. How are your listpickers initialized? It is not so nice to have the picked values in the listpicker itself. If I were you, I would add some labels to show these once picked. Then, when you cancel, you just reset the values in the labels.
Then, when you have that working, it is time to figure out what to do when the cancel button is pressed. I think that you are trying to reset a value in the tinyDB, but why are you having one?



Thanks I will try that.


Bug with two or more TinyDb and Clear all

Hello I have a bug.

In my apk i have 4 different tinyDB with 4 different name db_para; db_mc; db_jdb and db_inc

When, in my apk i want clear one of my  tiny_db, i use a call tiny_db/ ClearAll (for example Call db_mc clearAll)

but the 4 Tinydb was clear !!!!!

an idea ????



From the documentation:
There is only one data store per app. Even if you have multiple TinyDB components, they will use the same data store. To get the effect of separate stores, use different keys. Also each app has its own data store. You cannot use TinyDB to pass data between two different apps on the phone, although you can use TinyDb to shares data between the different screens of a multi-screen app.
When you are developing apps using the AI Companion, all the apps using that companion will share the same TinyDb. That sharing will disappear once the apps are packaged. But, during development, you should be careful to clear the TinyDb each time you start working on a new app.
See here: http://ai2.appinventor.mit.edu/reference/components/storage.html#TinyDB


2015년 1월 9일 금요일

Is internet necessary if the backend database is tinywebdb?

I am trying to set up a tinywebdb instance via Google App Engine for an App Inventor application. The said application will be accessed also in an offline environment. Will the google app engine hosted database still be working in such environment? If not, can the tinywebdb be imported to the local storage of the phone ? 



You can also build your database locally on the device with the TinyDB... You'd have to sync the two from time to time...


Using TextBox with Texting

I would like to add a textbox to my app that will allow users to enter information in the textbox and then submit the information in the form of a text to a pre-set phone number but can seem to make the blocks connect to accomplish this.



As often happens, what I could not find before my request I found immediately after.  Please disregard.



Well, that's a good thing ;)!  Don't forget to use the search function and read my tips!  Glad you got it working...

For my App Inventor Tips, visit TwoDogApps.com by clicking here!


2015년 1월 7일 수요일

Reading amount of files by the File component.

    I need to read an amount of text files representating graphic data (just numbers) for draw them on canvas. 
    Problem comes when I'm trying to read files in "for each item in list" loop from a list where are stored a names of files. Each time when file is readed, a readded data are stored in other list in pairs - a file name and data by "File.GotText" block. Here, since in GotText blog is missing argument which contains name of readed file so I added global variable where im storing the file name after it is readed. But, When i view full list containing the file names and their data I get in whole list of same name of files (that one last one in list) but data are stored right. (Example in an attachment).
    I really dont understand why It doesn't work. I'm sure, that global variable containing actual reading file is rewrited each loop right. (look at attachment containing a printout of debug info - Screenshot)
    Also I don't understand why I have to click 2-times on refresh button for view list with stored data, if It shoud do at first time already.

    Could anyone tell me where I'm doing mistake or how the File component actually works?






you are trying to read all files the same time...
the file component works asynchronously, which means, you should 
1. read the first file, in the FileGotEvent do something with the text you received from the first file, then 
2. read the second file, in the FileGotEvent do something with the text you received from the second file, then 
3. read the 3rd file, in the FileGotEvent do something with the text you received from the 3rd file
4. ready

see also this similar example (well, there the web component is used, but the logic is the same) https://puravidaapps.com/filebyfile.php



I reworked it and it works already! Thank you for your help Taifun!
Adding solution in attachment:



Writing A List In A Label

I'm looking to write all the values in a basic list(with values like 10,22,34,46) and want to write it in a label like so

Building 1: 1
Building 2: 22
Building 3: 34
Building 4: 46

I'm looking to do it in a little code as possible.



You'll want to use a for-loop or a while-loop to iterate over the list. You can look up the documentation for these on the app inventor site.

Please post a screenshot of the blocks you have written. Then we will be able to help you make it more efficient (use less code).

Thanks and happy apping!


Webviewstring to Javascript Array

Ok. I don't kno how, but I messed up my original html file somehow, and I can't revert it back. I don't know what I changed. and I can't transfer my list to an array of arrays in Javascript. I did that once, it worked to perfection, but I can't re-do it now. I haven't changed the source, just messed up some code in my blocks or my HTML. Whatever happened, I decided to get this sample into my computer and try to play with it to learn: PuravidaApps: Table

 Firs I run it as it is, it works. next, I added a web1 and called for my data. It gets the data and I changed it so it will send my data, which comes as a csv table, to webviewer. It shows everything correctly, in the table. as you can see in picture 1. 

but WHen, I try to access a single item from the array, it treats the array like a string and gives me just one character. Here is what I wrote as a script:
<script>
document.write(urlArray + "<br>");
document.write("first item " + urlArray[0][1] + "<br>");
document.write("second item " + urlArray[1][4] + "<br>");
document.write("third item " + urlArray[2][3] + "<br>");
</script>

In picture 2, you can see what it brings out. I've been trying to solve for a day now, and about to go nuts! Please show me what I'm doing wrong. And also, I don't understant how the table is actually filled with items all sorted when I can't access them with code. Thanks..





urlArray is not a 2 dimensional array, see the relevant parts of the code below
Taifun

    var urlArray = window.AppInventor.getWebViewString().split("\n");

    for(i=0;i<urlArray.length;i++){
      // split at comma
      var rowArray = urlArray[i].split(",");
    }




any idea how I was able to do that before? I wish I hadn't changed any part of this. Whatever, Is there a way to change it into a two dimensional array?




one method is to pass the data as JavaScript array to the html file, see this example https://groups.google.com/d/msg/mitappinventortest/pVA3VUMN5W8/pZLttKYl3-8J



if anyone searches for a similar information, I want to write the solution I figured.. The "list to csv table" is NOT allowed to become a 2d array. What you need to do, is to code the entire message with the block style you can find at Taifun's web page here. In my example, I got the data from my db, then converted it to a list using "list from csv table". Then, I added every item together like this:

item1,item2,item3\nitem4,item5,item6\nitem7,item8,item9

you do this by joining them together as text strings. Then you transfer this to your webviewer, and define it an array. Then, define another array an make it equal to "your first array[0]". thisway, you don't still get a 2d array, but you just get arrays, which can later be merged into a single 2d array. 

Taifun, your examples make us better rookies. Thanks.


Where is TinyDB file stored?

I am getting a new phone and would like to transfer the existing information in a TinyDB to it.  Where is the database located in the phone?  I've looked in many directories, but can't find it.



see here https://groups.google.com/d/msg/programming-with-app-inventor/r20fH5D0dBY/hX-qFrR6LfsJ


Highlighting text in a text box

One of my students is creating a note taking app and would like the user to be able to highlight the text entered into the text box. I don't see an option for that, but I'm wondering if anyone else has a more definitive answer.



you are correct, there is no such option



AI can not do that but the user can double touch the textbox to highlight

like this:





On the emulator, you do it with a double left mouse click; on a device you do it by a rapid double touch.

This this work for the student?


2015년 1월 6일 화요일

Server connection problem - if 40 students try to connect at the same time....

Hello. I'm an informatics teacher in Korea and now I run some teacher training course with AI2.

There are 38 teachers who want to learn AI and they are all in one classroom.

Today, I told them to connect to AI2 website (http://ai2.appinventor.mit.edu) with Chrome, only half of them succeeded to reach the AI server.

Teachers who could not reach the server tried again and again, but some of them (maybe 6 or 7) could not connect to the server.

And some teachers who connected to server said that their session had expired and they had to reload the page. And some said the server did not answer their command.

Obviously, it is not the problem of network of the classroom. It is built for computer training so it has a broadband network for learning. When they tried to connect other server, it went well.

I think there is a connection issue when many computer access simultaniously.

I want to know what's the problem because I want to use AI in my programming class with students. Generally, there are 20 to 35 students in one class. If there is a connection problem, I have to change the tool, even though I like AI.

Please notice me how to solve this connection problem. 

  • Chrome said "connection time out"
  • When I tried to connect another computer outside the classroom, it worked well.
  • Some teacher close the web browser, other teachers can connect the server. 



1) you said you have a fast connection.  Perhaps this is a firewall issue.   Here is an experiment:   have everyone use their browser to go to a different Web page; can they do that successfully?   If they can not ALL go to that same Web page, have 1/3 of the class navigate to one Web page, 1/3 to another and 1/3 to yet another.  Can ALL of them load the web pages they were assigned to visit?

If the students can not ALL visit a different web page successfully the problem is probably with the school network...some limitation..see your IT department for help.
If the students can not ALL visit 1/3, 1/3, 1/3 you are probably dealing with a limitation on the number of users.

You comments "Some teacher close the web browser, other teachers can connect the server" seem to indicate there is a limitation on your network to how many individuals can be logged in from that particular network.   It might be something else.  We do know that instructors handle a class size of 40 students with no serious issues so we are interested in what might be the problem too.


Please answer the questions, read the documents and let us know the results.   If you still can not get ALL your class logged on, tell us more please.



Help! I'm stuck with this formula

I want to make an app so you can quickly see how much you need to produce something else through recycling. But I cannot seem to get the formula right.

I want to make something like this:

Textbox.1 (number of recyclable objects) Listpicker 1 (objects itself like old cars, cans etc.)

Textbox.2 (number of produced objects)   Listpicker 2 (new products cars, bins, cans etc.)

Calculate button

so you can calculate al sorts of things to get kids interested in recycling.

the formula is supposed to be something like this:

textbox 2 = textbox 1 x 20.000 (listpicker 1 + and listpicker 2 are choosing this value (1 car makes 20.000 cans for example) how do i make this?)

like a sort of converter i tried to make something like this but i can't make it work can anyone tell me what i should do? because i dont know what i am doing wrong. I watched the tutorials and i have a know what i am doing but it is not working for me.



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.




simple example i am trying to get it when i have 1000mm and i want to know how many meters it is how can i tell my computer it has to convert it to :1000 when mm to m is true?


Store data in other screen

I'm doing a botanical App has stored a number of plants where each one has different fields such as weight, height, temperature and relative humidity.

For example ListPicker I select a plant of interest:

Plant: Sunflower
This is me visualize the specific fields of this plant:
Weight: 110 g
Height: 75 Cm
Temperature: 25 ° C
Humidity: 90%

As I need to make new measurements then the previous values will be overwritten by new readings. But how do I use a button that says "new reading" then I open another screen so you do not have to reselect the plant of interest but when the screen is opened recover from automatic way the plant previously selected and there already you can record the new readings for later storage.

Any suggestions as might happen?



first do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.htmlto learn the basics of App Inventor, then try something and follow the

Data gets updatet wrong from the TinyDB

I'm programming an app in which you mine some coal, sell it in a shop and buy stuff with the new money (At the moment only a worker). I wanted to tel the app that it should update the text telling you how much money and coal you have every second to a value in TinyDB. Sadly, if you sell some coals you get the money, and lose some coals though after the clock ticks it's reset to the amount aou had before. I've tried to set the timer updating to 5 seconds but the same happens every 5 seconds after that. I've looked through the code but can't see why this would happen.

I appreciate that you've read to this point,

PS: I've added the .apk of my app as attachment.




Please post your screenshots directly here on the forum.  Most of us don't want to go to some unknown link...



Open for every action a new TinyDB 
TinyDB1 for Coal
TinyDB2 for Money
TinyDB for Work Amount



@kristijan: there is only one TinyDB in your app
@Vladis: It would really help if you provided a screenshot of yourrelevant blocks, so we can see what you are trying to do, and where the problem may be.


How to install MIT App Inventor on my own server?

I was looking arround, but I didn't found another topic answering for my question.

I downloaded the source code (http://appinventor.mit.edu/appinventor-sources/) and extracted the files, but there are a lot of folders and files and I don't know how to set it.



Cross Screen Interaction(Shop screen and Play screen)?

Hi. Im making my first game currently and i have 2 screens, Shop screen and Play screen. In the Shop screen you buy upgrades which should for example make the speed of a bullet larger by +4.
Buying an upgrade is in my shop screen, and the bullet is in the Play screen. How do i make the upgrade on one screen make a change on the other?
BTW for upgrades i am using Buttons with images on them and when you click on it it shoud take 10 of your credits which you  earn by playing the game, and in return incrase the speed of your bullet.
Thanks in advance. Please help me.



use TinyDB



Thanks man ill give it a go :)


TinyDB

I need to create an app where i can select the date, or it selects today's automatically and then
display a code associated to that date. We have an access code for each day and i would like to
pre-program the tinydb with the codes for each day. Is there a way to import the codes as i have 265 codes
to associate with each day of the year.



yes, you can use the file component, see this answer for a similar problem



One way to do what you want to do does not involve a TinyDB at all.

1) Create a csv file with 365 or 366 codes:   xyz, abc2, w5ad3 ....    and use File to load it in a List called    MyCodes.     An easy way to do this is to put all your codes into an editor like Notepad, then select the entire list and drag and drop it into a Text block.       set MyCodes to  ...that Text block.

Then use the Clock component to figure the day of the year (day number).     Use the day number to associate with the items in the list.


xbmc/kody json post, please help

Hi, i have two llinux. The first one, as a homeserver and a second with XBMC/Kodi. If i execute this on the first one:
curl --request POST --data '{"jsonrpc":"2.0","method":"Input.Left","id":1}' -"Content-type:application/json" http://xbmc:xbmc@192.168.1.54:8081/jsonrpc

Works right. But if i try this:
it doesn't works, allways respond with a 401 error :( I think that i need the header "Content-type:application/json" ... or something ... please help me.



i have somthing working

send me a mail on richard6360@gmail.com and i wil help you further.



and what prevents you to use a header?

RequestHeaders
The request headers, as a list of two-element sublists. The first element of each sublist represents the request header field name. The second element of each sublist represents the request header field values, either a single value or a list containing multiple values.

and an example see here https://puravidaapps.com/spreadsheet.php

@Richard: why don't you just answer the question in the forum? Also other users might be interested in your answer. This is how a forum works.




Try it without the first and last '

and without any password parameters
this is working in kodi

{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 1 }, "id": 1}



@richardvansoest  thanks!!!!! it works


coding

trying to code a morse code app for a high school project, but cant figure out how to get a string of text to be translated. I got individual letters to work, but anymore than one letter wont work. is there a way to split the text into individual characters and go from there? keep in mind i am new to app inventor.



Hi Brian.   What are you attempting to do?

Convert a string of text     like a b c d     to dots and dashes   . -   _ . . .   -.-.     or play the sounds of morse code.
What you want to do probably can be done several ways.

1) Using  the text  length block.   Check the entire length of the text.  That tells you how many characters in the screen, then use the length to identify the first character 1, the second character 2  and so on.    If you want dots and dashes,   write out the code in a list, with each character of the alphabet   A, B, C, D ....   then write a second list  with  . -, -...,-.-.,-..    for example, then when you cycle through the length of the screen   use the look up in pairs blocks to associate the two lists, the actual characters and the dot dash character representation.   When list item 1 is  Q  have the App print --.-     and so on.   You could print these to a string by using the Text blocks and a join    or directly to a label.     Remember, you will have to handle spaces between words.

2) Create 26 sound files with the Morse character tones plus punctuation?    Instead of having list 1 point to a dot dash sequence, have it point to a sound file and use the sound file to play it?


The AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page, will help you to learn to use the blocks.

Try some stuff.   If you have issues, return and post a screen capture of your blocks and describe the problem.  Someone will provide advice.

73 and have fun


Please enter a vaild order

I have the table id, keyfile and service account email

I have tried to combine the party pizza app with the how to use the serviceaccount. 

on the emulator which has been updated the submit button doesnt work if i add a name and a comment.  If i leave these two out and press submit i get "Please enter a valid order'

i have attached screen shoots








in the initialize event you still assign the keyfile to the webviewer.HomeUrl, that obviously will not work...compare again with the example here

 the submit button doesnt work if i add a name and a comment.  

check your if statement in the ButtonSubmit.click event




I have checked over the if statement in the ButtonSubmit.click event.

It is exactly as the example in the party pizza tutorial



use Do it to debug your blocks, in your case the values in your if statement...



hi  I can not figure it out, how to make this statement with the button submit

Do It

You can perform the action for a block with Do It . In debugging a program like MoleMash, you could select Do It for MoveMole and see if the mole moves on the phone.
Do It not only does the block's action, but also puts up a balloon that shows the value returned. The figure below shows the use of Do It on an addition block to show the result of addding two numbers called this and that .

Result balloons are attached to blocks at a point indicated by a small equals sign. You can click on the equals sign to hide and show the result. Moving the mouse away from the block makes the result balloon go away.  



see tip 4 here

Top 5 Tips: How to learn  App Inventor




I did manage to find the function on a mac. it didnt change. please see attach im still getting the error sign.... Secondly, is it possible to Re-name the Screen1





Please see attachment with DO IT string

Will app work... it seems to work with just one screen when i add another it does not function




as already said earlier, in the initialize event you still assign the keyfile to the webviewer.HomeUrl, that obviously will not work...



do you remember: you already mentioned the same problem in your other thread https://groups.google.com/d/msg/mitappinventortest/t7tOrtMOPYE/M9Id0OqpWcMJ
do it step by step and fix that issue first before continuing

this is wrong


this is correct



please see attach 

it just not working




I already asked this in your other thread but probably I misunderstood your answer?
did the example (see link) work for you?

How to use the Service account option to connect to a Fusion TablesFusiontable




the problem in the end was 
1. you forgot the space after INSERT INTO
2. you wrote "Tyre Width" without underscore instead of Tyre_Width for that column name

unfortunately the error message does not help at all in this case for the service account method... remember the error message is just "Error" (see screenshot)...

for the API key method, the error message would be something like this "400 Bad Request Invalid query: Parse error near 'INTO..." @MIT: could you change that and provide a better error message for the service account method, too?




If possible, could you generate a and send a simple example that exhibits  this problem?    All App Inventor is doing here is passing along an error message that came back from a lower level module, so it would be good to have a clear repeatable error before I ask someone to dig into this.



you can use the attached simple example, just modify the select statement to get an invalid query and remove for example the space after FROM to get the "Error" result
Taifun