Nested Splits -- what am I missing?

I’m having trouble with apps that use nested “split at” components to parse data from a text file or html. Here is a simple example to demonstrate the point:

The first two splits seem to work fine but the third one fails!? What am I missing?

Thanks in advance.

Nested_Splits.aia (3.5 KB)

Please explain what the result is and what you expect.

1 Like

I'm not sure what you want to achieve, but try something simpler:

1 Like

or this:

1 Like

Thank you both (Italo and Anke) for your prompt replies. You both question what the desired result for this program is. This program is only an example that illustrates an issue. I appreciated the suggestions for alternative approaches, but I’d really like to know why the blocks I show don’t work. By “don’t work” I mean the following:

  1. Split_1 button will correctly split an example text string (“abc…xyz”) at the letter “m” and display the expected chosen fragment (“nopqrstuvwxyz”) and fragment length (13).
  2. Split_2 button also correctly splits the above-mentioned fragment at the letter “t” and displays the resulting chosen fragment (“uvwxyz”) and length (6).
  3. However, Split_3 button results in no new displays. It seems to do nothing. The other two buttons remain functional and continue to display as described above, but Split_3 does nothing.

Why does this not work? That is my question.

Thanks again!

Works OK for me…
(you may have some layout/formatting issues in your aia)

1 Like

Interesting that it works for you but not me! Could it have to do with the version of Android I’m using (4.2.2)? What possible layout/formatting issues could give rise to the behaviour I observe?

Thanks much for taking the time to look at this.

I tried it on the stock AI2 emulator, with Companion,
and built as .apk onto a GenyMotion 4.1.1 emulator.

All worked okay.


Could it be that you are building an .apk file but running an older .apk version in your tests?

1 Like

How about my simple approach: Nested_Splits2.aia (2.7 KB)

1 Like

Anke and ABG: Thanks for your input. Here’s what I observe:

  1. Anke’s simple approach WORKS FINE on my tablet when I use AI Companion (thanks!)
  2. My original version STILL FAILS on my tablet when I use AI Companion.
  3. My original version WORKS FINE when I create an apk and install on my tablet!?! (Does that address your suggestion ABG?)
  4. Prospecting (with “Do It” and Enable/Disable) indicates the problem lies with the “Length” block for Split_3_btn (returns nothing – “Length” block for the other buttons return expected value upon “Do It” interrogation).

I would very much like to understand this – there MUST be some learning here! Any clues?

Thanks again!

If your Companion falls behind the current version of the AI2 server, weird things can happen at run time with the stack. Double check that you are up to date.

1 Like

Should have mentioned I’m using AI Companion version 2.57b – I think that’s the most current version, isn’t it?

How do you know this?
Can you show us?

1 Like

Also, under the heading of Inheritted Wierdness,
has this project been imported from any other AI2 spinoff?

1 Like

Here is a “clean” nested splits aia for you to try. Tested and working in companion and compiled app

Try this. Same Issues ?

othernestedsplits.aia (3.4 KB)

1 Like

Maybe this is working for you:

or try to use Companion version 2.57bu and / or remove the folder AppInventor (Internal Storage > AppInventor) from your device before connecting to Companion and try again.

1 Like

Neither the “clean” version (othernestedsplits.aia) from TIMAI2 or the latest suggestion from Anke work. Same problem with button 3. “Do It” returns 0 for the “Length” block in Anke’s code.

ABG – are you asking how I know the version number of the AI Companion I’m using? If so, it is indicated on the app itself when I open it. Also, no other AI2 spin off used previously.

Anke – I’ll try your suggestion about deleting the AppInventor folder…

… no joy (deleting AppInverton folder).

Another observation – tried the program on another Android device (ZTE phone). Same behaviour as with the ASUS Tablet – Buttons 1 and 2 work fine, Button 3 fails.

And yes, all works fine on the ZTE phone when installed as an app (as opposed to using AI Companion). Just like the tablet…