JavaScript without Timer and WebViewStringChange

Hello to everybody,
is there a way to do something like this:

B = ""
A = ""
A = JavaHTMLResultA ((first call Java)) (1)

.... stop until A <> ""

B = JavaHTMLResultB ((second call Java)) (2)

Do (2) if (1) is done

Hello Rudolf

You want to port Java code into App Inventor Blocks? App Inventor uses conditional statements to Programming Your App to Make Decisions might help you.

Your pseudo code does not appear to have anything obviously to do with you topic Title Rudolf. Perhaps if you could provide some background information and a more complete explanation about what you want to do?

Here are some resources to help you learn to use the AI2 tools. A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook ... 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 and the aia files for the projects in the book are here:

How to do a lot of basic things with App Inventor are described here: .

Also look here and here for more tutorials.

Learn about components
and visit the Library Help>Library on the MENU

are you talking about JavaScript?
you do not need a clock, just use the WebViewStringChanged event together with an if statement and a global variable...

Set global action to A
Call A

In the webViewStringChanged event:
If action = A
set A = value
Call B
set B = value


Thank you,
your lines are helpfull!
What I'm trying to ask was: is there a way to put the webViewStringChange "Result" in a variable like a procedure result.
I want to use the Java "call" like an extern function.
Your answer put the hole thing in the webviestringchange event. Is that a good place for a calculation?
Number1 = ASC("a")
Number2 = ASC("b")
Number3 = Number1 + Number2
(( ASC is my extern Java call ))

You declare a variable "Action" is that the only way?

Ich bin aus Deutschland, bitte entschuldigen sie mein schlechtes Englisch!

This is an ongoing problem in AI2 development, and in general any asynchronous environment where you have to coordinate multiple interdependent processes .

It's like a 3 ring circus, where the ringmaster has to watch not to release the elephants until all the clowns are back in the clown car and the lion tamer has caged his lions.

That requires a ringmaster who knows about all the acts, their progress, and their requirements for further progress in the show.

Thank you, I understand.
I will put my stuff to the inventor without caling an extern java script. I think that will be a little bit slow... I hope it will be working.

Procedure sorting a list in ten screens
means ten times the same procedure in ten screens.
like sorting a list

you do not necessarily need 10 screens see also tip 1 here

to sort a list you also can use an extension List Utils Extension by Appybuilder

your English is quite good... btw. I'm also German... :wink:


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

You don't need Javascript or extensions to sort.

See my customizable merge sort blocks in FAQ Section: Lists

Very good, your ListSort Procedure seems to work much faster than the bubble sort example made by Sajal Dutta.

you will get the fastest result if you use an extension or the JavaScript solution, see also
How to sort a list using the webviewer(!)


I never used an extension before and I am a little bit afraid of loosing control. What I was looking for was:

Fill List
Sort List ( MIT or Java )
Work with sorted List

(( execute and wait sort List ))

The merge sort procedure and the bubble sort procedure are doing a nice joh but both of them got if statements in the deepest loop.

The textcompare statement is using the ascii order but I need the German norm order (ä less than b) so I have to write my own textcompare function and put it into the sort algorithmus

Thanks to everybody

(very nice Circus text)

Do you have a sorted alphabet string with all the letters in order, including caps?
My Google searches for German norm order are returning undesired results.

This could be used in a replacement procedure for the compare text block in the merge sort.

The fact that the compare happens in the innermost loop is inevitable, but not so bad considering that the compare happens n*log(n) times, the theoretical minimum.

If you want to sort the german norm you need to change minimum seven letters: ä=a, ö=o, ü=u, ß=ss, Ä=A, Ö=O, Ü=U. There are many more letters (French etc) but I think I will need them not yet
txt = join listStart
replace ä to a, ö to o etc in txt
NormList = Split txt
Sort NormList
If there is a need to swap Item, I swap them in both lists.

Here's a blocks implementation, with a mapping dictionary builtin.

merge_sort_German.aia (5.9 KB)

Gigaset E370HX,

Thank you!

I never worked with a dictionary before but it seems to be very useful.

You are changing the items to German Norm every time you use them, many times the same work?

Is there a way to translate the whole list to German Norm and after that to work with only one list? Perhaps a kind of tag that can remember the original position in the source list?

By the way:

I would like to have the "real" textcompare not binarycompare because I have more steps.

Text1 → lower →German Norm → TextA

Text2 → lower →German Norm → TextB

compare TextA / TextB

The dictionary will be smaller because I do not need Ä Ö Ü any longer.

Thank you again for your help!

This is typically done by turning the list into a table, adding an extra column pre-populated with a sort key pre-calculated to include the original sort key transformed with norming and downcasing. I have seen this done in database tables.

If you go that route and want to apply a merge sort to the table, have the comparison function select the new sort key column to decide which row precedes the other row.

After the table is sorted, select your original data column for display purposes or .Elements

Thanks again!

In the end hopes and wishes for basic text blocks and more::

I know the substitude solutions, but I think this "must" be basic...

LTrim (Space)
LTrim (Letter)

RTrim (Space)
RTrim (Letter)

ASC (Letter)
CHR (digit)
the optic of CHR(32) Space, is just the same as CHR(160) HardSpace ))
Variabe = " "
Space or not... ? CHR(32) is more clearly

Rights (Text, Len)


Global Variables and global Procedures should be global and not restricted to one screen

The answer "under construction" is the best answer...

In fact, the screens are treated as separate applications. Since the screen is an application, the global variable is within one screen. I have long stopped using screens, there are only problems with them. Use Arrangement.

Those are nice ideas, deserving of a separate thread.
Some one with more MIT mojo than me should promote them.