Difference in output of text length depending on from where it comes, list direkt, or list with blocks between

This mess comes out when I was give up to get help from your colleagues and was trying to find out the solution by myself with math, and there i was trying different things, and when was trying to clean this mess up, then I was having problems to re-enter to my project or to send my new aia file...

And now MIT App Inventor gives me the option to send AIA file, but it says AIA file, but it sends zip file...

I was trying it 5 minutes before, for a second time, because I was not sure if I was clicking the right item, but, I was right, I says "export to your computer as AIA file" but it sends me an zip file.

And you are right , the problem is there but your colleagues look in the solved part, the first part, and say to me that is all ok , and that they don't understand why it is not working....

I was speaking from the problems to get the length, and they give me examples for how to make lists...

You get my confusion?

Here finally comes the AIA file. Thanks to the help from your colleague kevinkun

Ok, AIA file:

leftedge_copy_5jan.aia (24.1 KB)

Calculating a text's length in pixels is not easy. Well, it is not difficult but not exact. You can't calculate it with en exact math, because advenced operation systems does not use monospace fonts. It means not all font's (characters) width is the same. For example "A" is 7 pixel wide, "I" is 1 pixel wide. Not sure the actual values are correct, it is just an example. And It depends on the font size as well. But at least that is a mathematically usable variable. So you can calculate a roughly close value for pixel lenght but not the proper one. I would say automatic length calculation for the button would do the job, but the AI2 button width does not work that way. Maybe there is an extension that offers buttons with more costumisable preferences, i do not know.

I've just read maybe it works if you set the automatic length in blocks not in the designer. Have to try it.

Hello usane,

Now you understand my confusion, and my dump face, in this situation.

Because this I was having a mountain of formulas in this length part, to look with what numbers I can work what numbers come from which block, and so on, or which number I must use as my global letter width. And so on...

And when you see my newest AIA file, then I think I find something that I usable, and then aplicable on the rest of the programming.

And it is posible to Generate it with the length block.

But in anyway I was asking your colleagues, because sometimes there is a block that make mi just this work...

And when you running my AIA, you will understand, what I want to achieve...

But if you have a better solution to my problem, don't worry, show it me, Because I will learn... I m not angry if you show me a better and shorter way ....

But,.... Take your time, take it easy, Because I will learn... And fast learning is not my way ... :wink::wink::wink::wink::wink::+1::+1::+1::+1:

leftedge_copy_1_5jan8_41.aia (24.1 KB)

Only to be sure, that you have the newest AIA file....

Setting the button width to automatic in blocks works.
blocks
Also you can get the numerical value from the button if you need it.
And you missed out the new line characters from your list in the new AIA ("\n").
Also you can put the other join blocks in one like this:
Capture2

Ok, putting the width to -1,activates the automatic width, if I understand you right?

And jes, I will reuse the data, or make it reusable...

Ok, thanks for this information.

The new line "\nl" I was taking out because I was testing, if there makes a difference in the length result if I let it without this character...

And then was coming the big crash, and I was no more abled to enter in my project...

  1. I m first time was trying to put it all compactly together, as you suggested, but because the Frame displaying problems from the MIT App Inventor Homepage, I was regretting this and was using littler groups, because on tablet to use the multi item option as you suggested is nearly impossible...

Because this I was only use the multi item option from the "and to list" block...

Happy to help.

As for the record, noone here is my colleague, I am a simple user as you, I just happen to understand the ai2 better than you or a lot of user here because of my little programmer past. But there are people with much more ai2 experience here than me, but they could not help you because it was hard to understand what you want. I barely understood as well. I only could figure out because I followed your questions from the beginning and examined compared it to your AIA file. I know english is not your native language, dont' worry, neither mine.

1 Like

Hello Usane,
First-time excuse me that I writing with errors your name.

Then, a pleasure to read form you.

And third but no less important, thanks for your time...

And now a cuestion: you know someone that want to work with my in my projects, and can help me like you, with your knowledge ,and to help me to make from my ideas an (for other understandable) Projekt.

Someone that have a computer, with an a little bigger screen, with which I can have a more direkt contact, for example alternatively over WhatsApp or Telegramm, or sometimes for the future a system where we can program together live and sometimes that we can create an app that achieve anything like this.?

And here my cleaned version of my AIA file:

leftedge_copy_6jan02_35.aia (24.1 KB)

Ah, ok now I understand, i was solving this by math, (Is not the easiest way but it gives me the posibility to display it properly that you can understand better what I want to achieve).... And sometimes you have a block Combination that works better...
That I can try it....

And here my newest AIA file:

leftedge_copy_6jan02_35.aia (24.1 KB)

Hello Ghica, yes, indead we must consider the fontsize, this is what I will find out, a block combination that gives me how much letters my item contains, (the biggest one) than this in relation with the fontsize, and then converter in pixel, to have the width.... (Hey, I was learning to write the word "width", yipiehiaiey).... :slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::+1::+1::+1::grin:

Und hier noch meine neueste AIA file: (wie versprochen)

leftedge_copy_6jan02_35.aia (24.1 KB)

Here's a solution that doesn't use any math. So it will always work regardless of the font. As @Usane wrote earlier, just set the button width to -1.

leftedge_copy_1_5jan8_42.aia (23.5 KB)

Hello Patrick,

Finally you found a solution, and a solution that is simple to make and to understand even for me, you did iiiitttt !!!
:+1::+1::+1::+1::+1::+1::+1::+1::+1::+1:
Congratulations.

And here the final product, (for now):

leftedge_copy_1_6jan7_17.aia (23.6 KB)


This is what the app looks like on my phone.

Probably the sprites are moving to the 4 corners, until stopped, but what is the purpose of those labels with the large font?

And I think there is duplication in the code. You can either move a sprite to a certain position, or let it head into a certain direction, but to do both, I am not sure what happens.

Hello Ghica, wonderful that you look at me and my AIA files...

But there is something strange in this picture, because by me it is workin well at all, but sometimes you opened the old one of my AIA file, this one with the incomplete programmation.

But by me it gives only the 8 lines, not 16...
For sure there are rests of my old programming,

I was cleaning it all before I send my last AIA...

Or which AIA you tested there? Wait I will send you the newest version...

leftedge_copy_1_6jan7_17.aia (23.6 KB)

Ok, try this... And if this gives the same result, then give me little bit of time to look in it if this gives the same result...

You made some change in the aia file compared to my aia, which causes the line to be more than 8.

Yes, there was situation, where the wrong block was moving, but I was thinking that I was put the block in the right place, ... ok, no problem, I have the original from you saved already... Then I will remake my changes in a second copy...

But in my companion even this faulty version works fine ... Hmmm strange... But I will solve that, no worries... And excuse the inconveniences....

Entschuldige bitte vielmals,:slightly_frowning_face::slightly_frowning_face::slightly_frowning_face::slightly_frowning_face:

Looking at your code, I wonder what you want to achieve, do you want to display the current sprites coordinates all the time while the app is running? Since your current code will only display the sprite locations once and will do so in a loop, it will always be the initial sprite coordinates. Even when the sprite drops, your code won't catch it.

Yes , you are so right, this was my next cuestion, what I was having too, but I was interested to finish, the length/ width problem, no that we was solving this first problem, I will look first-time the working AIA, to see what is the next thing where I want to put my learning interest,... But I like you intelligence....

I will look tomorrow, because today my concentration is empty... Don't be decepcioned when I make a little brake for today... I'm a little bit old, and old people sometimes need to walk a little slower...

So you will see some messages from me tomorrow...