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

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...

I checked your blocks and aia and still dont get it. Why do you need the length of the list? You only need the lenght of the longest item. And that can be found in a "for each" cycle.

Edit: Ok. I see your point now in the newer version of your aia.
I am tired and have to work tomorrow, so yust explain it. I make blocks tomorrow if needed.

  1. You have to declare a new list for coordinates and added that to the one that you already use.
  2. Split the used list to multiple elements. I mean 1 coordinate is 1 element.

Nobody (at least not me) really understands what it's all about. So explain it in detail and finally give us a concrete example (including an aia). And show us screenshots of what it currently looks like and what it should look like.


Niemand (auch ich nicht) versteht wirklich, um was es genau geht. Also erkläre es im Detail und gib uns endlich ein konkretes Beispiel (inklusive einer aia). Und zeige uns Screenshots, wie es aktuell aussieht und wie es aussehen sollte. Also wo das Problem ist.

Hallo Anke, Danke,....erstmal danke, dass du dich meiner nochmals angenommen hast....

Ja das Problem.... AIA files habe ich euch ja das schon massenhaft geschickt dazu wie es aussehen sollte....

Es hatte ja in einem anderen Beispiel mal funktioniert, mit einer anderen Objektart.... Da waren es labels... Und buttons deren Länge herausgefunden werden sollte, da hatte ich das irgendwie hinbekommen, ... Aber als ich dann das mit den Sprites versucht habe, kamen ja dann die Zwischenprobleme, und weil ich ja dann wieder was neues dazugelernt habe, habe ich ja dann, auch neue Herangehensweisen probiert. Und ab da ging es dann bergab...

Wie gesagt, AIA files habe ich bei jedem mal wenn ich etwas verändert habe, geschickt, auch Block pngs zu dem Block an dem ich gerade dran bin, nur habe ich gerade bei deinen Kollegen den Eindruck vermittelt bekommen, dass im gleichen Maße, wie durch die neuen Erkenntnisse, dass ich da erstmal durcheinander kam, dass sie aber im gleichen Maße an Gedächtnisverlust litten, obwohl ich auch zu jedem zwischenstadium der Entwicklung ebenfalls immer immer AIA files und block pngs geschickt habe, und zu diesen auch immerwieder Erklärungen, über das wie und was ich brauche, und welcher Punkt da unklar ist, also screenshots gab es in der letzten Zeit immer.

Ich hoffe ich bekomme da noch etwas hin, bei mir ist es jetzt nur Abends und ich komme gerade von einer langen Reise zurück...

Wollte dir aber wenigstens antworten, dass du wenigstens siehst, ich habe dich nicht vergessen,... habe mich übrigens sehr gefreut vor dir zu lesen...

Werde mich ab Morgen und in den nächsten Tagen mit dem Thema nochmals beschäftigen, in der Hoffnung, dass da das System wieder funktioniert, und ich wieder in meine Datei reinkomme, und zum anderen auch erstmal wieder verstehe, was da überhaupt der neueste Stand ist.

Habe durch die ganzen Zwischenprobleme erstmal die Übersicht verloren, und habe dementsprechend mit meinem Lerneffekten ein bisschen Rückschritte erlitten...

Also gerade totale Verwirrung da ich gestern und in den letzten Tagen oftmals nichtmal mehr Normal in mein jeweiliges Projekt hereinkam.

Und dort an die richtige Stelle zu scrollen auch sehr schwer war... Und wenn ich dann gerade eine neue Lösung eingeben wollte , lud mein Browser die Seite neu, und ich war wieder irgendwo ganz oben auf dem Blockdesigner, und nachdem ich ne Halbe Stunde gebraucht habe um reinzukommen, oder um eine neue AIA file zu senden, (ich weiß nichtmal mehr welche Aktion und welcher Fehler zuerst kam) lud dann die Seite wieder neu,

Dann haben in der Zwischenzeit die Developer bei euch irgendwas an der Homepage gemacht, so dass ich Jetzt plötzlich auch noch nicht mal Mehr in mein dropdownmenue hinein komme,

Dazwischen dann auch wieder unerwartetes neu laden, nachdem ich mich dann plötzlich auf der Projektauswahl Seite vom MIT App Inventor wiederfinde.

Zu diesem Punkt dann das Nächste Problem:

Sobald ich dann ein Projekt ausgewählt habe, springt es in irgendein anderes Projekt, also ein Projekt anwählen, und es springt wie durch Zufallsgenerator in ein anderes Projekt hinein...

Bis es das dann geladen hat, dauert dann auch wieder ewig...

Ghica hatte da zu dem Problem schon etwas gepostet... Sie war dem Fehler am nahesten gekommen, du hattest da auch etwas gepostet was das Problem aufzeigte.

Aber wie gesagt Developer bei euch haben irgendetwas verändert, was die Situation dann noch schlimmer gemacht hat, also du siehst absolutes Chaos....

Und bitte nochmals, bitte verstehe mich nicht negativ, wenn ich etwas schreibe und auch manchmal die Erklärung etwas länger wird, oder die Themen manchmal ein bisschen gemischt sind.

Aber ich mache das nicht um euch zu Ärgern, oder weil ich nicht weis was ich schreibe, sondern weil es sich wirklich so zuträgt.... Und ich Versuche es auch in der Reihenfolge an euch weiterzugeben, damit auch eure Developer die maximalen Infos bekommen, über alles wie es passiert ist... Oder welcher Fehler passiert ist.

Darum werden meine Nachrichten auch manchmal so lang... Sind einfach ne Menge Fehler die passiert sind, und dann ging mir zwischendurch noch mein eigentliches Ziel verloren, "das lernen"

Ich hoffe ich bekomme das in den nächsten Tagen wieder in Ordnung...

Und dann gibt es wieder AIA s und pngs.... Versprochen, bis dahin Bitte ich noch ein bisschen Geduld, vergesse euch keine Sekunde, bin immer dabei.

Dankeschön

Bis zur nächsten Mail.

PS: Beschreibung was ich brauche, (ich hoffe ich bekomme das dann so kurz wie möglich hin) kommt alles in den nächsten Tagen....

Grüße auch an die Kollegen

Gunnar Scott Freiherr von Brandenstein