2017년 7월 12일 수요일

search results for App Inventor Index too large?


Your problem might come from the parse procedure. Unfortunately, App Inventor can't show local procedure arguments with the DoIt right-click ...
you currently have a space as column delimiter and a new line character (\n) as row delimiter. however the list from csv table block expects a comma ...
I you are asking for help, I recommend you to make it as easy for others to be able to help you ... You probably will get more feedback then.
I have tried to add println(); in my Arduino code but in Android threre are blank line between 2 value, error still display. the labe to show name of ...
"Select list Item: List Index too large. Select list item: attempt to get item number to of a list of length 1: (1)". I know my php code is right because it works ...
But this is a new error that just says my index is too large. On Saturday, January 11, 2014 10:34:34 PM UTC-6, josmasflores wrote: It sounds like a ...
However when I get the value , error occur as "List index too large". Is that means there is limit of the list index? If it is true , what is the max limit?
What does it mean? What am I doing wrong?
Select list item: List index too large. Select list item: attempt to get item number 1 of a list of length 0:(). please can you help me to solve this problem.
The message is "Select list item: List index too large. Select list item: Attempt to get item number 3 of a list of length 1: (d Invalid Credential)"
I'm trying to replace an item in a list with another list item replace but something is wrong in the right direction, the error I get is: list index too large
I try really. Taifun, I have tried to correct as you made me do, but I always error: Error: Select list item: List index too large. Select list item: Attempt to get ...
use Do it to debug your blocks, see also tip 4 here. Top 5 Tips: How to learn App Inventor. How to work with Lists by Saj; How to work with Lists ...
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.
Bad news. When running the app i get a "Select list Item: List Index too large Select List item: Attempt to get item number 1 of a list of length 0:()".


Re: Error List index too large


I am researching about Arduino and control it through Blutooth and display data to Android.
I have problem with block list when design Android app. I want to display multi data sensor from Arduino ( light and temp number sensor) and separate each value sensor with "," into different label to display clearly
 When I run first programe without if.. then condition it display on Android that “Select list item: List index too large”
 Then I found in some forum that have to use if..then condition but unfortunately, it appeared that “ Bad Argrument to >  ….   ( in the pictue I attacted)
And can I use both string and number data from Arduino and send it to Android ?
Can anyone find out my issue and fix it for me. Thank you very much



--
For the 'list index too large' error you need to use 'Do it' to determine what value is being returned.
You are assuming that it is two values, but only one is being returned.

In the > error you are comparing a list containing one item to a number.
That is probably not what you wanted to do.

--
On the Arduino side, you need to send one pair of numbers per line.
Use print() ... print(",")... println() for  each line of output.

On the AI2 Bluetooth client in the Designer, set Delimiter to 
decimal 10 (= NL = LF = Line Feed = \n.)

In the AI2 blocks, you need two if/then guards protecting your read text block:
If connected and If bytes available > 0.

From the AI2 docs:


text ReceiveText(number numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
As for -1 bytes, to get one complete line of data,
and proceed to split it at the comma from there.

--
What is the  (= NL = LF = Line Feed = \n.), Can you make an example block for me to understand.
On the Arduino side, I do as you say
On the AI2 Bluetooth client, I set Delimiter to decimal 10 and make a block as below but nothing display and no error

ps :I collape 2 if into 1 If (connected and bytes available > 0). Is it ok ?

--
What is the  (= NL = LF = Line Feed = \n.),
Those are four different ways you might encounter for people talking about the same byte value.
(Too much information on my part, sorry.)

All you needed was setting the decimal 10 in the Bluetooth client Designer attribute.

 ps :I collape 2 if into 1 If (connected and bytes available > 0). Is it ok ?
This does not help you diagnose problems.
I suggest adding a label lblConnected, containing either the text
"Connected" or "Not Connected", and a label lblIncoming showing the raw input,
and changing the blocks to:
When Clock1.Timer
  If BTClient1.IsConnected then
     set lblConnected.Text to "Connected"
      if BTClient1.BytesAvailabletoReceive > 0 then
          lblIncoming.Text = BTClient1.ReceiveText(-1)  <= asks for everything until delimiter
          (split the lblIncoming.Text  at "," and show the two parts, like you did)
      end if > 0
 else 
     set lblConnected.Text to "Not Connected"
end if connected


Also check to see if your clock timer is set to repeat, and is enabled, otherwise it won't fire.

This should give you more data to see what is going on.

If this still does not give you data, post your Arduino code text as an attachment for us to read.

--
Thank you for helping me. I'm successful in spilting data from Arduino and fixed the list arlert error. But I found one problem that make me uncomfortable ( I circled in the picture below)
Firstly, my data display exaclly but for a while ( about 30s - 1 minute) my data sensor on Android display confusion and about 3-5s it run normally and repeatly
Can you explain for me ? Thanks a lots !  

P/s :
And here is my code Arduino to display data Sensor :
"
mySerial.print("10"); mySerial.print(",");
  mySerial.print("Do_sang"); mySerial.print(",");
  digitalClockDisplay();mySerial.print(",");
  delay(1000);
"

 On designed I set BlutoothClient1 Delimiter Byte to 10 as you said  and check on HighByte First
                     I also check on TimeAlwayFire and TimerEnabled in Clock1






--
I don't see where you are calling println() to close off the end of each message.

That's necessary to keep the receiving end from slipping out of sync with the transmitting end.

You also need to request -1 bytes in the .ReceiveText block, to insure that you get only complete messages.

If you fail to do this, your receiver will lose track of where the beginning of each message starts, and everything will slide down in your display like you saw.

--
I have tried to add println(); in my Arduino code but in Android threre are blank line between 2 value, error still display. the labe to show name of sensor display not exactly line. I know it's because of println() code and I can fix it in App Inventor. when I remove println(); It still work well despite the error I showed you

About -1 bytes in the .ReceiveText block

I make a labe to check byte to recive and I found out that when error byte available to recive # 0 (1,3,23,...) and when nomally byte = 0;

I dont't understand this, because when I set label 4 text to -  call BlutoothClient ReceiveText number of Byte to "-1" , nothing display

Can you make block clearly. Thanks

--
About -1 bytes in the .ReceiveText block
I make a labe to check byte to recive and I found out that when error byte available to recive # 0 (1,3,23,...) and when nomally byte = 0;
???
Please include screen shots of everything
I dont't understand this, because when I set label 4 text to -  call BlutoothClient ReceiveText number of Byte to "-1" , nothing display



text ReceiveText(number numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

Are you sending a delimiter byte ?

Maybe it's time to search this board for "Arduino" and "Bluetooth" for samples?

--

Is there a maximum size for Lists?


Using AI 2, I'm attempting to pull in a large amount of data from a Fusion Table.  I have 30 items per row in this database.

I've been getting an error stating that my "List index too large" and that I can't insert an item into the list because the maximum valid item number is 10. 

However, on a different part of my app, where I'm only pulling in about five or six of the 30 things, I get the same error message round 17 that says 17 is the maximum valid item number.  

Any suggestions?

--
It sounds like a problem in your code. Easy to test; make a list with say 30 items and print it in a label. If that works, the problem is in your code.

--
Sorry, I responded by email instead of on here.  The main reason I think its a separate issue is that it defines where I've had too many items in my list at different spots depending upon how much I'm pulling.

For one part of my app, I'm pulling 29 pieces of data per row.  It says 10 is too many, so that's somewhere over 290 items in that csv list that it thinks is too many.

For another part of my app, I'm pulling 7 pieces of data per row.  That one says that 18 is too many, which is only 119 items in that csv list.

Also, unless I'm forgetting something, I'm not sure of any ability to code the size of a list where it could be a code or syntax error.  I've gotten my fair share of grabbing items not in the list, or at the wrong place, or what not because I've done that wrong, and I've been able to troubleshoot that...  But this is a new error that just says my index is too large.

--
You get that error when reading from the list or inserting to it?

--
I'm reading from the Fusion DB which is populating a CSV list from the results in the DB.  That's when I get the error.  Attached are my call to the DB for information and then the loading of it into the array:

--
what happens, if you use this select statement instead?
SELECT * FROM <tableid>

--
So i found oddly, that there is a code problem, although it's not what you might expect.

Whenever I hit the "Back" button that takes me to my main screen, I had assumed that when I opened the main screen, the previous screen would close, but it does not.  So then when I go back to do anything the previous instance that is still open seems to be interfering with the other instance.

But there is also a bit more of a problem to this in that on my phone, which is an HTV EVO 4G LTE from sprint, running what I think is Android 4.2 (maybe 4.3), if you use the exit button from the Menu, the app dispapears as if its closed, but when I use the page through open app buttons, it didn't actually close, and stays open on the prompt to close the app.

Anyway, at least until just now I had not had any problems with data populating.  I was moving data from one list to another, which I stopped doing and it resolved the issue.  But I can't seem to fix the app not closing thing from the regular exit menu.  Is this a known bug?

--
Whenever I hit the "Back" button that takes me to my main screen,
use the close screen block instead of reopening the already opened main screen
But there is also a bit more of a problem to this in that on my phone, which is an HTV EVO 4G LTE from sprint, running what I think is Android 4.2 (maybe 4.3), if you use the exit button from the Menu, the app dispapears as if its closed, but when I use the page through open app buttons, it didn't actually close, and stays open on the prompt to close the app.
to exit the app, use the close application block

--
You do not appear to be exceeding the number of items in a list. What is the limit of tags..items in any list?  See this: discussion  https://groups.google.com/forum/#!topic/appinventor/O3LSt3QrGXA   It indicates you should be able to handle several thousand tags or so.  With the size of your files, you should have no issues, so you probably have something errant in the code.

A possible issue/limitation on the list size could be exceeding the app size of 5Mb, if all the list items are saved in the app.  However, several thousand tags are possible and probably more.   If you use a TinyDB component, the limit is the size of the database is 2mB; not the number of items but the total bits attributed to the text of the items in the DB stored.

Another possibility, is amount of memory in your phone.  However, the error messages point to a coding misstep in your case.

--

fall detection


want to make an app that says something after the phone has fallen, just to notify the user. for this i used accelerometer and also tried other accelerometer tutorials. what i noticed is that in all these tutorials and my app the text to speech thing keeps speaking the line again and again depending directly on the intensity of falling/shaking the phone. is it because the accelerometer may be keeps moving/vibrating even when the phone has stopped moving? can i expect this problem to be different with different phones due to their different accelerometers? can there be a solution where the text-to-speech thing speaks only once?

--
Could you use a boolean variable, set it to true initially.

If boolean is true (
// Play speaking sound //
Set boolean to false
)

--
Be aware that your app won't work, when the device is sleeping or your app isn't open.
App Inventor cannot run in the backround.
So if your device falls from the table and you haven't opened your app and kept the device awakw it will say nothing.

--

How to Generate A Particular Sound Frequency?


I am developing an Android Application.I want to generate Sound of Frequency Ranges between 1KHz to 20KHz. is there anyway to generate sound at a specific Frequency.

--
Take a look at android.media.ToneGenerator

--
I found this code from another SO post. from what I can tell it is still a little buggy but it should do the trick.


public class PlaySound extends Activity {
    // originally from http://marblemice.blogspot.com/2010/04/generate-and-play-tone-in-android.html
    // and modified by Steve Pomeroy <steve@staticfree.info>
    private final int duration = 3; // seconds
    private final int sampleRate = 8000;
    private final int numSamples = duration * sampleRate;
    private final double sample[] = new double[numSamples];
    private final double freqOfTone = 440; // hz

    private final byte generatedSnd[] = new byte[2 * numSamples];

    Handler handler = new Handler();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected void onResume() {
        super.onResume();

        // Use a new tread as this can take a while
        final Thread thread = new Thread(new Runnable() {
            public void run() {
                genTone();
                handler.post(new Runnable() {

                    public void run() {
                        playSound();
                    }
                });
            }
        });
        thread.start();
    }

    void genTone(){
        // fill out the array
        for (int i = 0; i < numSamples; ++i) {
            sample[i] = Math.sin(2 * Math.PI * i / (sampleRate/freqOfTone));
        }

        // convert to 16 bit pcm sound array
        // assumes the sample buffer is normalised.
        int idx = 0;
        for (final double dVal : sample) {
            // scale to maximum amplitude
            final short val = (short) ((dVal * 32767));
            // in 16 bit wav PCM, first byte is the low order byte
            generatedSnd[idx++] = (byte) (val & 0x00ff);
            generatedSnd[idx++] = (byte) ((val & 0xff00) >>> 8);

        }
    }

    void playSound(){
        final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
                sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO,
                AudioFormat.ENCODING_PCM_16BIT, numSamples,
                AudioTrack.MODE_STATIC);
        audioTrack.write(generatedSnd, 0, generatedSnd.length);
        audioTrack.play();
    }
}

--