2017년 6월 30일 금요일

search results for An internal error has occured


I think the reason the internal error occur because I was using the Sogou Browser which is based on Webkit but no so compatible with Chrome.
When I go to: http://beta.appinventor.mit.edu/ I get the following message from webpage: 'An internal error has occured. Go look in the Debugging view ...
Subject: Re: An Internal Error has Occured. App Inventor does not support IE. If you are on Wondows,you should use Chrome or Firefox, On Tuesday ...
An internal error has occured. with Blocks not appear correctly. Comments: notes = Browser: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2;
Upon entering my AI project two errors appear saying "An internal error has occured. ¿Report a bug?" In both messages press 'Cancel', allowing me ...
I have my project almost finished. When I try to add a new element like a label or a button, I get the error "An internal error has occurred. Report a bug?
Since last night, after integration of a ninth screen, impossible to open the project without getting the error message "An internal error has occured."
I keep getting the following error whenever i try to upload, open, save, and sometimes switch between screens. "Internal error has occured. Report Bug ...
Internal error has occurred. Dialog box appears. I also noticed that a duplicate of all my screens appear with a ._ in front eg. ._screen1.
... the phone to the computer with the QRcode, before pressing "connect with code", appears on the computer screen "an internal error has occured.
... then I click on stop the script to remove the message and find my screen dark with many screen's messages saying:"Internal error has occured.
sometimes, these need to be fixed because they trip an internal warning and not filling puzzle. piece sockets .... internal error has occured. How the ...
But as soon as I open the copied screen, it gives me an internal error has occured report and guides me to a report a bug. I have reported the bug.


Parse Json string to value


I have a long json string as below. I can Parse one Json. But I don't know parse the long string
How can I add each string to a list and then using for each item in list?

[{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2001","BIG_DEFECT":"Clean","VN_DEFECT":"Do Keo"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2002","BIG_DEFECT":"Clean","VN_DEFECT":"Loi Bu"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2003","BIG_DEFECT":"Clean","VN_DEFECT":"Dau Chi"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2004","BIG_DEFECT":"Clean","VN_DEFECT":"In hinh"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2005","BIG_DEFECT":"Clean","VN_DEFECT":"Long,short hair"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2006","BIG_DEFECT":"Clean","VN_DEFECT":"Color bleeding"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2007","BIG_DEFECT":"Clean","VN_DEFECT":"Khac mau"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2008","BIG_DEFECT":"Straight","VN_DEFECT":"Nhan"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2009","BIG_DEFECT":"Straight","VN_DEFECT":"May khong dung dinh vi va in hinh"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2010","BIG_DEFECT":"Straight","VN_DEFECT":"Se so khong tron deu"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2011","BIG_DEFECT":"Straight","VN_DEFECT":"Meo den"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2012","BIG_DEFECT":"Straight","VN_DEFECT":"Meo mui"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2013","BIG_DEFECT":"Straight","VN_DEFECT":"Meo got"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2014","BIG_DEFECT":"Straight","VN_DEFECT":"Chan ben chi khong dong nhat"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2015","BIG_DEFECT":"Straight","VN_DEFECT":"May lon size"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2016","BIG_DEFECT":"Straight","VN_DEFECT":"Bao bien to nho"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2017","BIG_DEFECT":"Straight","VN_DEFECT":"Day chu tai dai ngan"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2018","BIG_DEFECT":"Straight","VN_DEFECT":"Duong may khong chong mui"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2019","BIG_DEFECT":"Strong","VN_DEFECT":"Xu chi"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2020","BIG_DEFECT":"Strong","VN_DEFECT":"Lo kim"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2021","BIG_DEFECT":"Strong","VN_DEFECT":"Rach"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2022","BIG_DEFECT":"Strong","VN_DEFECT":"Long chi, noi chi"},{"DEPARTMENT_BELONG":"20000","DEFECT_CODE":"2023","BIG_DEFECT":"Strong","VN_DEFECT":"Dut chi"}]

--
Using a combination of the Web component's JsonTextDecode block and list blocks you can access any entry data record and tag value:


JsonToList.aia

--
Nice example.   Added it to the FAQ

--
I make this block as you show me. Now, My problem is solved.


--
Nicely done!
Thanks for letting us know that it is working for you.

--

Web Component – JSON Response On App Inventor


App Inventor has a component called Web which gives you the functionality to send and fetch data from a server or a website through GET and POST  requests. This component can decode both JSON and HTML formatted data. We will be writing an app called iRead that will ask a user to type in a full or partial book name and query Google’s database of books using Books API and retrieve the most relevant book info. We will parse the Title and Author of the book, we will get the image URL of the book cover, and finally the book URL which can be launched through a browser. This is how our app would look like-

Before we start, I advise you to read on anything that is unfamiliar to you but mentioned in the paragraph above like Books API, JSON, HTML, GET, POST, etc.

First thing first, build your user interface (UI) in the Designer window. Mine looks like this-

As you can see I renamed default names of components App Inventor provides. It’s upto you what you want to name the components you use. If you are having hard time designing the UI, download the source file iRead and take a look. What matters is that you have all the essential components as shown in the UI screenshot above.
Have you tried executing a Book API query request yet? Click on the link below to see the API response.

This gives you a response that looks similar to this-

Our concern is not the actual book info (Over time you might not get the same book info using the same query), our concerns are the tokens that we’ll need to identify and parse specific data. Take a look at the tokens like “title”: that ends with a comma and a new line, “authors”: that ends with ], etc.
Now let’s start defining actions and interactions in the blocks editor.

We have three global variables defined-
googleBookSearchURL – That’s where we store the API URL address for book search.
tempData – We will use that for saving temporary data.
bookURL – That’s where we will parse and store the URL (“infoLink” token) of the book info returned by the API.
When a user enters a book name and hits Search button, we call GetBookInfo procedure where we simply construct our URL with user inputted text and encode it for using it as a URL, and finally feed it to Webcomponent’s Url property. We want to get only one book info (API may return many); so we used maxResults=1. If we didn’t use projection=lite, we would get a lot of other info that we are not going to use in this tutorial app. At the end we call Web.get to execute our query.
How do we know when the server returns a response to our query? Well, we use GotText block of Web component for this. Whenever our app receives something, GotText block will automatically wake up for us to validate and process the data. Let’s parse the JSONresponse from the API that we receive.

We only can proceed if responseCode is 200 which means our query didn’t fail along the way. We have another procedure called ParseBookResult that actually parses the response. Let’s take a look at it-

In the ParseBookResult procedure, we split the response content using the start tag and end tag. For an example, to parse title of the book, we need to know the beginning and the ending tags of a title. If you have noticed in the query, it returns-
"title": "Harry Potter and the chamber of secrets",
"authors": [
"J. K. Rowling"
],
So we know, it begins with “title”: and ends with a comma followed by a new line. That is why we used those tags when we called ParseBookResult from GotText procedure above. In our example raw data, the value is “Harry potter and the chamber of secrets”. Then we decode the JSON value by calling Web’s JsonTextDecode. And finally decode the HTML characters by calling HtmlTextDecode. We call HtmlTextDecode to replace unreadable HTML characters with readable characters. For instance, & is actually & and we want to show & instead of &.
When a user taps on the Read button, we simply launch the browser with the book URL.

For launching a browser, we use ActivityStartercomponent. We set the action first. You can see a list of actions in this page. We also set the URL we retrieved. Then we just call the StartActivity of ActivityStarter component to launch the browser with the specified URL.
If our bookURL doesn’t contain a valid URL, we simply inform the users.
Download the source file of this app iRead.

Parsing Multiple Results

What if you want to parse multiple results? Well, in that case you define a higher maxResults when you query like this-

As you can see in the screenshot above, we defined maxResults to be three meaning we want three results. If Google cannot find three matches for our book query, in that case we wouldn’t be receiving three results obviously. But if it does find three or more matches for our query, we will receive three.
For demonstration purpose, we will only parse the titles. Maybe you already guessed, we would need for each block to do the job. If you are not familiar with for each, read this tutorial first.

We created a procedure called GetAllTitles that has three arguments –apiResponsestart, and end. We call this procedure with data like this-

As you can see, we passed the responseContentstartand end tags like we did before for parsing a single title. GetAllTitles uses a for each loop and go through all the titles and do the same for parsing, exactly the way we did before. Before we didn’t have the for each loop as we had only one title to parse and now we have a loop because we have many to parse. Note that GetAllTitles procedure stores the result after parsing each title to a global variable named allTitles and returns it.
We used a Label component named OtherTitlesLabel to display the result that is returned by the GetAllTitlesprocedure. Our app now looks like this-

We created two apps. iRead for single result and iRead2 for multiple. You can download both apps – iRead and iRead2.

FAQ for JSON


Can Firebase DB ProjectBucket be an empty string


I just want to check that I've done this correct.

For FirebaseURL I have entered my URL as per the URL give in firebase (databaseURL). Now if I choose a child node as my ProjectBucket everything works fine. However I want to look at my root folder, so when I set the ProjectBucket as an empty string, I then have problems with reading values from my tags. Now trying to work out best approach.

My example is as follows:

FirebaseURL= https://myprojectname.firebaseio.com

Root structure

myprojectname
 - child1
   -- tagName1
   -- tagName2
   -- etc.
 - child2
   -- tagName1
   -- tagName3
   -- tagName4
   -- etc.
 - child3
   -- tagName1
   -- tagName5
   -- etc.

As you can see within my structure I have used the same tagName (i.e. tagName1) in each of my child nodes. 

So in this case, if I then set my ProjectBucket as "child1" and apply the "GetValue" function with tag set as "tagName1", then change the ProjectBucket to "child2" and apply "GetValue" with tag set as "tagName1" I have problems with the async call "when FirebaseDB.gotValue" as the tag names are the same.

This is why I tried to get around this by setting ProjectBucket as "" and then setting my tags as "child1/tagName1" and "child2/tagName2", but for some reason I don't get values back.

Am I doing something wrong.

--
Apologies. I've found that my error is unrelated to the firebase component.

I've now done some more tests and ProjectBucket as empty string does work. I also tested having my tag as empty string with ProjectBucket pointing to the same tag name. This worked too.

What I did notice is that for complex nested structures your returned value can be in a json formatted string. Hence this is what caused me my problems.

--
Just to expand on your follow up: If you only send data from App Inventor to Firebase, we will encode it in such a way that it should always be interpreted correctly by App Inventor apps. However, if you provide the data through the Firebase web interface or another app using Firebase, then you can end up with JSON-encoded content that App Inventor doesn't understand. I hope that helps explain the difference in behavior you are experiencing.

--
Thanks for the explanation. Yes it pays to test as sometimes the returned values are seen as a list and other times as json formatted text.

Also tag names are case sensitive so be sure to check... this also caught me out.

--

FirebaseDB GetValue / GotValue method not reading returned Value correctly


I've noticed an error with FirebaseDB GetValue function or more likely the "when FirebaseDB GotValue" function.

If I structure my firebase database table as follows

root
 - child1
   -- 0: "Hello World"
   -- 1: "Hello World"
   -- 2: "Hello World"

Then ask FirebaseDB to GetValue for tag "child1", the FirebaseDB GotValue then returns a list with all my "Hello World" text string elements

Now if I structure my firebase database table as follows

root
 - child1: "Hello World"

and similarly ask Firebase to GetValue for tag "child1", the FirebaseDB GotValue only returns a Value, which is not interpreted as a list in this case, as "Hello". I also noticed that if I make my child1: "Hello,World" this too just returns "Hello".

--
You probably read Evan's post to your previous question  Can Firebase DB ProjectBucket be an empty string  

How this works probably depends on how you created your table.  Did you use AppInventor or did you create the table and then link it?    What may be happening is your table is providing a JSON and you are attempting to interpret it as a List because you provided the data using the Firebase Console?


If that is not what you are experiencing, then it would be helpful for posting your blocks and providing an 'example'     

Did you create the table using the Firebase Console or using AI2?   How the table is created might explain the problem.  If you create the table using Blocks, does the same thing happen?

--
This is a known issue. As I mentioned previously the content of a field needs to be JSON-encoded for it to be correctly handled by App Inventor. The Firebase UI presents the "" characters but that is just a visual feature for human consumption, App Inventor does not receive the quotes. Therefore, string values you want AppInventor to treat as strings need to be wrapped in quotes. For example, write a string using the Firebase component and then look at the data. You will see something on the web interface like "\"Hello World\"".

When App Inventor attempts to parse the text without quotes from Firebase, it will go as far as it can until it encounters something it doesn't understand. It treats Hello as a token parsed from the JSON stream, but then cannot proceed past the space and gives up, which is why you get the "Hello" but not "World". This is equally true of your inclusion of a comma, since these characters (among many others) terminate JavaScript tokens.

-- 
Ok wasn't sure if this is a known issue. In my opinion, the point of Firebase is to allow collaboration / real time data sharing no matter if data coming from MITdeveloped app or web app or directly from console. So the workaround is not really practical. What you're saying is that the parsing code you've developed so far is not really working as intended and will be fixed sometime soon. Still not sure why an array of strings which are not wrapped in quotes works though. Anyway I'll it up to you guys. Otherwise the firebase extension is working very well and it's a great addition to the suite of components / extensions provided. Well done.

-- 
To solve my problem, I created a json style parser (see attached for procedure) which seems to work on simple firebase structures (not nested trees).

So if firebase structure as follows
root
 - child1
   -- IsAbaby: no I'm not
   -- DoB: Mon 12-Dec-2000 12:00
   -- No: 1232

and then ask to getValue for child1, the GotValue method will return a string like this {IsAbaby=no I'm not,DoB=Mon 12-Dec-2000 12:00,No=1232}

Push this to the procedure and this will return a list with key value pairings.


-- 
Are you aware of the Web component's JSON decoder block?


-- 
Thanks for the tip Abraham. 

Yes I am aware of it, but assumed it was only possible to use if using the web component to retrieve information from web service api's etc. It did not dawn on me to try and use for parsing firebase data. Will look into it.

-- 
I tested the suggested use of web component JsonTextDecode and in my case it returns an error 1105 "unable to decode the JSON text..."

-- 
The spec for JSON is at JSON.org
(for what it's worth).

-- 
Thanks for the spec, but unfortunately I cannot change what the firebase component gives me.

-- 
We'll do some investigation into improving the Firebase component. If I recall correctly the original intent was not necessarily to support arbitrary interaction between App Inventor apps and others via Firebase, but rather app to appinteraction for apps built with App Inventor. That being said, I can see how it would be useful to enable data sharing between arbitrary apps. My immediate guess based on your posts is that the Firebase library is actually returning a JSON object rather than a string (which is what App Inventor currently expects) and so it's just serializing this into whatever default String representation Firebase provides. This is why it is JSON-like, but not really JSON.

-- 

It is not just about sharing data between apps and web-browsers etc. but also allowing data of sharing with IOT sensors though other apis. This experimental component now opens up so many new options for App Inventor application development. 

Then add in the fact that you also can now use Firebase Functions too (just tested my first "hello world" example with App Inventor using the web connectivity component and it works!!!), which then provides you with a very powerful backend for App Inventors. I seriously hope you too can see value in enhancing the existing firebase component functionality as soon as possible. 

The most urgent thing to address for the firebase component is allowing for authentication of users with firebase.

Then as you correctly identified, the firebase output provided as I described is JSON-like. Which is fine for me as can still parse myself. Mind you I'm now looking at Firebase functions to do this for me using a http get request, especially if I have complex tree structures. I then use firebase functions to format the response correctly as a proper JSON object for the App Inventor's web JSON parser to deal with. So we have ways round the problem.

-- 

Lock Tablet Down to Single App?


I have been asked to create a solution for one of the students at our school. (Our kids have autisim and severe learning difficulties, and can get a bit carried away on PC devices).

Hi parents want to Skype with him from home.

We need a setup whereby only Skype is accessible on the device, no other apps or functions available.

First thoughts are to create an appinventor app with webviewer and run Skype inside that (haven't tried it) and make it so the only way out of the app is to turn off the device. This is all the device would be used for and it could be prepared in advance (switched on/setup) of handing to the student.

Welcome any thoughts or other ideas on how to do this? ( I could look at other face to face video chats, e.g. talky.io, if integration is better)

--
I don't know if that can be made with ai. I think not. What you want is use kiosk mode in the tablet. There a several apps for that available on Google Play. Maybe some of them are usefull.

For instance:
--
Thanks, kiosk mode looks the way to go :)

--
For info

We are trying out the Surelock app from 42gears, seemed the most comprehensive. 
SureLock - Kiosk Lockdown Solution

It is only a trial version, so default password is shown on screen, but you have to know the number of taps required to be able to see it. Will see if our autistic but computer geek of a student can figure it out :)

--

gathering screens dimensions into global variables


Well, I think that the title is clear enough !

Because the shape that is displayed on my tablet is a bit far what I planned to set, I just think that all is matter of designing in term of % of width & height. therefore my question
Is it possible to capture the screen dims
Tried global(XMAX)=screen1.width
assuming that XMAX is my global variable.
It fails with a warning....
any help ?

--
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.
Also it would help to tell us, which warning you got...

--
For some reason I didn't get an alert about your answer therefore my late reply. Sorry about that.

I'm working to create specific apps for Autistic kids within a charity action. 
The requirements are set by the teachers & professionals.
I put some screenshots to show how I'm progressing. It's about allowing kids to move cards (for the moment they're only icons, in the real word they will be real pictures of family members) according to a temporal axis (see the red arrow). In practice, if the kid put a Grand ma picture somewhere, he/she will not be able to move another card (but Grand pa) on the left.
The issue I had is getting a playboard that works with all kind of devices (in term of size). How to capture that information ?
To do so I requested help from the community. Meanwhile I tried an option that looks ok.
I captured the width & Height from the screen attributes and put them in global variables. The dimensions of all the items in the screen are tentaively percentage of those dimensions.

It looks naive therefore if my approach is not that correct, please advise. Especially because it requires me to compute the relative position of a sprite of the 6 members. 



--
there is a timing issue, because of that you can't get the screen width and height in the Screen Initialize event. Instead use a clock component, start the clock in the Screen Initialize event to get the width and height a few milliseconds later in the Clock.Timer event

--

Comms Board - autism Canvas/Image Grid inside an Arrangement with Resizing!


Following on from this topic I raised a while ago


I have realised the fruits of my labours and now present a sample app on the Gallery


Note: designed only for use on 7" tablets and above

Of special interest is the use of a single canvas with a single imagesprite image set out in a grid, within a vertical arrangement. This app demonstrates that by clicking on part of an image, co-ordinates are returned, converted to a number, then the canvas, image and vertical arrangement are resized to show just one tile of that one image. I am somewhat at the behest of the quality of many of the original images, will work on improving this for the future. Text to Speech recogniser used to speak the image. It doesn't have to be any more complicated that this for our students, in fact for some it can be a bit of a stretch having to choose from so many options!
EDIT
Now a relative sizing version that should work on most devices:
--
Tim, you didn't share the Gallery url.



How to get it:
--
Was fixing while you were writing Italo :)

--
I tried it. Unfortunately you are using absolute dimensions on your canvas (pixels) instead of relative (percentage) The canvas in my phone looks too big and is mostly out of the screen.
When I touched the canvas, the app force closed.
I suggest you to use relative sizing instead, so it will show the right way in any device.

--
Yup, should only be run on 7" + tablets, have amended description

Will have to see if it will work with relative sizing, due to the need for getting the co-ordinates etc.

Alternative would be to create a second image and blocks for smaller screens.

--
If you would like to run it in any device, you can use FILL PARENT on width and height.
Then knowing how many squares your image has, you can determine which square was touched by dividing the canvas width and height, that will give you a set of coordinates.
Just an idea.

--
Sorry Tim, this interesting app crashes my Samsung Tab II ... whenever I 

1) attempt to change the volume with the tablet's hard keys
2) immediately after selecting an icon..it speaks then crashes..indicating Companion has stopped.

This is using Companion.  I expected to get a different result on compiling but no it still has issues.

Edit:  the problem is the BigPicture routine...disabled it and no more crashes.

--
Thanks for trying it out. Wasn't meant to cause all these problems!

Quite possibly timing issues between devices,as you will see I have had to add clocks to allow the arrangement, the canvas and the image time to reshape themselves.

This app runs faultlessly on my Google Nexus 7 2013 (what it was designed for).

Have been working on a responsive sizing but this just seems to introduce more timing issues, and the co-ordinates are not coming through correctly, not sure why? All sizes are based upon the screen width. Testing on my Nexus 7 emulator where I know the screen width is 960 (well 961 actually), should render things the same as the fixed size app, which it appears to, but the co-ordinates are returning the wrong tile number. Seems somewhere along the line the tile size is being rotated (instead of 100 w x 125 h it swaps to 125 h x 100 w !!). The x/y number procedure is working correctly, something to do with the canvas....  I'll have a bit more of a play. 

--
I hope this can help:
I simplified your coding a little bit by using a list of lists.
Then calculation that returns which column was touched depending on the canvas width and the amount of columns your picture has.
I duplicated that formula to do the same vertically.
Also I used the canvas to detect the touch without needing a sprite.
Then you can make the TextToSpeech component to say what's in the top label. It works in my phone, but I can't use TextToSpeech in my emulator to show it here.

Please watch the video:


--
Got my responsive version working on my tablet and my phone (HTC One M8s) through the Companion. Might still be a bit crashy, but how many timers can I put in?

Possible it won't pick up the screen orientation on first run ?

Images look worse on the phone ;)

Give it a go.











--
What do you need timers for?

--
When resizing the vertical arrangement, the canvas inside that, and then the imagesprite inside the canvas. Won't work without a small delay (50-100 ms) on each action.

--
OP updated to include gallery link to relative sizing app

--
Just curious: In what event the screen needs to be resized? And why you use a sprite instead of just using the canvas background to show the image?
Not trying to be annoying, believe me, but I think you are doing it too complicated (not the interface, but the coding). Have you seen how easy it is in the video I posted yesterday? I attached the aia if you want to give it a try.
Maybe the app has more functions that I didn't see, but if it only needs to detect what square was touched on the screen, I strongly advice you to simplify your coding, it will be way easier to maintain in the future, in case you need to add, change or remove words.


--
Oh, I see now. I tested your dynamic one now.
It works perfectly.
Although the board looks a little too small. Is that how you want it?

--
And I just made you a video to help explain!

It is a bit more complicated as you can see, and a bit of proof of concept at the same time, developing on from Scott and Steve JG's work on the 36 grid.

Not had a chance to test compiled yet, but seems I need to add a bit of code to stop the app picking up the screen width in portrait mode.

If you start the app with the device in landscape, it should fill the screen better

Also changed the image to one of higher resolution so "zoomed" images should look better.

--
That is a very smart way to crop the images, Tim. Really good.
Have you tried Taifun's extension to separate images in chunks? https://puravidaapps.com/image.php
--