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

Well, if you want a solution, then vage descriptions are not useful. Blocks can show where you go wrong.

I was sending everytime a version of my AIA file, and a screenshot of mi blocks, to make it understandable for you and your colleagues, look, and you will find....

But I have a bunch of suggestions from your colleagues, to apply, excuse when I'm a little bit slow in responding your cuestions, but I will send you a Block overview when I adapted the suggestions from your colleagues...

Thanks :slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::slightly_smiling_face::+1:

1 Like

Ok, here comes one of my pngs:

I'm working on my problem now, but sometimes you see my issue, in the moment my internet connection is a little bad, (Paraguayan internet) (sometimes it is working, sometimes not) :frowning::frowning::frowning::frowning:

And here comes the newest one, with one part of the solution, it works if I fill in only one item per Sprite in to the list...

Ok, ... I have then te result:
And by this version it gives me a length of 15, what gives me a letter width of 7,5...
And when I round it then it gives me 8
And this gives me the right letter width.
And you see 15 X 8 gives me 120,
And this gives me the fine width for the sprites button .

Sprites
Sprite1X:0
Sprite2X:30
Sprite3X:30
Sprite4X:30

There I have the X position of each Sprite.
Now we need the Y position too...

I will try if it works....

Ok, and there I was see possiblity to make the formula shorter, because I have "add to list " block, then I have my "make list" block, and then the "join" blocks...

Ok, for what I need the make list block, if the add to list block have the option to add more then one item's in itself... Ok, I throw the make list block out....

And repently we have???? What???? We have 10 as the length....

Because, the 15 of length was fully ok.

But how this is possible?

Because this was my initial explanation: when i have a word that have 13 letters then the length must be 13, and not 15, 20 or 30. or I m lost anything?

How I will calculate something if there everytime that must be steady, changing my result to other Things.

And here the block where I was making the changes:

But here when I added this second join group, to generate the "y" item. There I was noticed the changing from length "15" to "10"...

It is how I say.... The longer the cascade, the bigger will be the number....

Thanks for reading my posts, I hope my explanations help you a little bit?

So far, I am even more confused. Where does every come from?
Why don't you have a list of sprites instead of sprite names?
Assuming now that you have a list of sprites, what do you want to do with them? Put them on a Canvas? How and where? Where are the pictures in the sprites?
After answering these questions it is maybe time for a new aia.

Now, keep in mind that we are all volunteers here, answering questions in our own time. At least my patience is running out, therefore be careful. Are you really a Freiherr?

Hello Ghica,

The list of sprites is generate by the every Sprites block. From there I get how much sprites, and other information.

So automatically when I put a Sprite in the canvas, I t recognizes it and list it in my sprites-list.

That first thing is achieved.

But I will display that in some way, For this I need the list data, .... But I need the length from the new generatet SpriteNames. So that I have the width of my list view. Because the numbers with the time get bigger, and need more place.

And for this I let a for each loop Take the length of each sprite name in the list. But there was issue with the length block .

The length what the length block gives me, is not the length, what I need.

Because the length block gives me the number of letters, but not the width of the letters.

So I musst find out this by a formula....

So I found out that:

Length of each item (the largest one) are not the same as the length getting from the combination length + "get global list" block.

But this Diference gives me the information of how how much letters are really there

And don't worry I Will provide you with an AIA file....

Ok, how we come to the information of how how much letters are really there?

Ok here it comes:

Length block + "get global list" block -
Length block + item block
= Diference = letter width


Length block + "get global list" block + letter width
= How much letters are really there.

And here are my promised AIA file

leftedge_copy_6jan02_35.aia (24.1 KB)

Show sample content of SpriteNames.

I think I understand. Do you need to know the text length in pixels? Possibly to display it in the appropriate place on the canvas? AppInventor does not provide a method to obtain the text length in pixels.
But I think you can use a label for this. Add a label to the project, set it to invisible, and set the width to automatic. Set the font size to the same as in Canvas. Load the measured text into the label, then read the label width.

1 Like

Did you consider that letter width depends on the font size and type?
In a monotype font a letter i is just as wide as a letter m.
In other fonts you may have many variations.

First-time I need the really length in letters (how much letters contains my item, in a number: if I have the word "sprite1", how much letters must give me lengt of item? ("Length" block + "get item" block) if I m right , then it must be : 7 (because that's the text I work with)) and not the brackets or paréntesis, or comas that the MIT App Inventor like to put in randomly.

Because, (and now I will repeat something what I say in past post's)

Randomly because when I use the add to list block, only and then strait behind this the item in a textblock for example: the text "Sprite", (what i was doing some times before to test if the formula works, and what it gives me in my display (but in this time i was not looking for the length, but only the displaying , and because this i was not recording a length) and later, when i use the length block, there was so much difrenent numbers, that im not recall it no more, because i was focused in other therms of this single formula, and was having problems with the MIT App Inventor Homepage... you see it's difficult to work one thing at the time....

And there was coming out one number of length (but not "7".

Randomly, because, when I use the add to list block, and then the make list Block, and then the join block, and then the textblock with "Sprite" and then "the generatet spritenumber"....

There comes an other lengtnumber (but not "8",(because "Sprite"+"for example: "1") you see? Not the desired textlengt (but an other number) Ghica was bring the examples that displays my issues, and Anke to.

I need first time my really length of my word or string, or what you name this things..... Aaaaaannnnnndddd, thhhhheeeeeennnnnn a long time nothing, only this, and only this, (you all recall my my words in much of much of my posts... "Step by step ... One by one" only like this I can understand and learn ...)

And the simplest and shortest formula to get it achieved.

And I need first the length of my word or string.... Later we can work the width.... This will be other step.

But first length of word or string really length and length under all combinations, anyway if I use only the add to list, and then only a textblock, or add to list, make a list, and then text blocks, or add to list, make a list, then join, and then a textblock (or more then one textblock) i need everytime the really length of text.

And Ghica was right too, when we will come to the width, we must think in lettersize, because a letter with 12 have a size of 12 pixels (the word used by developers, o other technicians) , or dots (used by text writers, or other simply Computer using people)

Then the word size will be: "8" but the width will be 8 X 12 ( but the size 12 is not 12 because only the width, it is 12 because hight 6 x width 2.... (I think so the writers come to the number 12...))

But I was testing this too, and when I used the division by a fontsize of 18 in MIT App Inventor, it not works, because this I ask for help and my issue is not solved by now ....

Ok short:

  1. Length of word

For this we need first-time to achieve the word lengt issue.....

  1. Width of word, in relation to the fontsize that I will use (but in this I only will work if I understand point 1.) And when the developers solve the difference in result depending on cascade or iteration...

This is our collection of Font threads ...

By the way, font sizes are measured vertically, not horizontally, so don't expect easy math for text width in px.

Whixh means, you did not really understand how to work with lists

See again

And

Taifun
PS: for the rest you are writing let me just say tl;dr, sorry...

Ok, I see, the most important parts you understand.... And for the rest,.... No problem... I don't expect a 100 % solution, if there is a part solution, then the system is solving this part, and then solving the next part of the problem.... This is ok for me....

And I was looking so much tutorials, and because the tutorials I was more confused, because this I was asking for support ...

And your example with the select block involved was a wonderfull one ... But in the moment when I was wanting to use it, I was stumplet over this "length" issue.... Because this I was saying "stop all other learn activities, and learn first-time to solve the "length problems "....

And because this I ask you so specified.....

There is no such thing as a length issue
There is an issue of not understanding how to work with lists from your side

What about providing some relevant blocks as small as possible, so others are easily able to understand where exactly you are struggling and provide help...

Most of rhe volunteers here are not really interested in reading long stories, at least I'm not interested in that... please keep your posts short ... thank you...

And use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
Taifun


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

Short as possible, that's what I everytime say, but sometimes just when I try to work one problem, and try to learn, then comes the problems with the homepage, such as I was explain in posts before, that makes sometimes a short explanation impossible, and before I was learn to sending AIA files or how to make screeshot i was not able to make an explantion ether.... And don't worry, I will send you AIA files but sometimes I need first-time some information, and there is my problem, when i have not only one problem , but 100....

And sometimes I explain things to you or your colleagues explain me other tings that I was not asking... Or what I was planning to ask later....

And I everytime when I can I was sending AIA files and block pngs, but I was only recently learning how to send only the blocks where I was having problems, and in some cases I'm simply a slow learner....

But anyway, thanks that your read my posts, and take your time for me... :slightly_smiling_face:

I hope I will make it better in the Future...

This topic touched upon the problem of the length of the text from the list. Apparently you still don't understand...

Yes I was thinking the same, I was working with length in the past, and it was working, and I was so happy with that, then I was copying the formula and blocks but it was not working no more, and because I found this behaviour Strange, because this I ask here to you or your colleagues... And there I was investigating by myself, and there I was found this strange length differences.... What I can not explain by myself...

I'm normally are a person that everytime find a way, but in this case it was to strange....

Ok, I will look in the next days what I need to know, and then I will send, you an AIA file, and all what is new....

The examples in that topic work and return the correct lengths. Show us an example you built yourself that returns incorrect lengths.

1 Like

In the Moment is not possible to show something, because:

  1. Submenue don't works again
  2. The half of the frame In the display is not usable.
  3. The MIT App Inventor restarts the site randomly,
  4. It's select randomly which project it opens...
  5. Sometimes examples works and then later not
    Und 6. Ich stehe kurz davor zu explodieren weil nix vorwÀrts geht, und wir seit einem Monat an einem einzigen Button herumgemacht wird, obwohl ich schon x mal erklÀrt habe was ich brauche, und wie ich es brauche, und es werden mir leider keine brauchbaren beispiele gezeigt mit denen ich etwas anfangen kann und die auch auf die verschiedenen situationen passen.

Sorry, ich kann mich gerade auf Englisch nicht korrekt ausdrĂŒcken.

Und desweiteren ist gerade mein Handy kaputt gegangen, so dass ich den companion nicht starten kann....

Und dann lese ich noch es sei ja alles nur meine eigene Schuld, ich hÀtte einfach mehr tutorials schauen sollen.

Die tutorials enthalten aber nichts was mir weiterhilft, sie verwirren zur Zeit nur noch mehr...

Es wird doch wohl möglich sein Daten in eine liste einzufĂŒllen, die einzelnen Zeilen in dieser Liste auszulesen, die LĂ€nge des Wortes in der Zeile zu ermitteln, und die lĂ€ngste LĂ€nge davon als Wert zu ermitteln, das als Zahl , und das im Zusammenhang mit der SchriftgrĂ¶ĂŸe, daraus die breite zu ermitteln, die mein Button haben soll, und dann das ganze in meinem Button untereinander darzustellen?

Ich hoffe der letze Satz war jetzt kurz genug um zu erklÀren was ich machen möchte,... Und dass das nachher auch funktioniert.

Dankeschön

Und Entschuldigung vielmals dass ich das in Deutsch geschrieben habe.

Hello Ghica,

Yes, I m really a "Freiherr" only to respond to your question.... Excuse that I lost so much time for this short answer...