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

You also have too count the [ and ], that is all part of the list.

Again, please show your blocks and a Do it.

Because this I was accepted the 8 for a 10, Because I was not sure if I was counting right....

1 Like

Ok, I will see what I can do... thanks for your patience...

1 Like

And my other problem is, I don't ned the complete lengt of the sentence, if I was put this make a list block, then I need to know how much letters I have per item... And by your example "a" is one item, and "b" is an other and I need to know how long is this first item, only this first item, so when I read my list with the for each block and put the lengt block before the item for example, in the if filter, then it must give me 1 and not 2, or 10, because what i need from the item is the lengt of the item that contains "a" , and "a" = 1 not other number, and that is what i need.

Is there a block that gives me 1 when I say by the option "letters", and it gives me only letters?, and in this example it gives me "1" , or when I select " words", it must give me "1" also, because "a" is one item, and because this it is considerable as one word.....

And that is what I mean, when I use the make a list block, or other cascades then the length Block must recognise this and and give me everytime "1", and not "5" or "10" or other number, because the number of the length of one letter is everytime "1" and must be "1", because if not then the lengt block are not counting rightly....

Or when I have 5 letters in one item, then the number must be "5" and not "6" or worst "4"...

You understand the speciality of my problem?

1 Like

Ok, I see you really understand my explanation... Yessss, I think this will be the solution, I think this is possible to combine that I get the data directly and automatically by using the for each block? And a counter of course, to get the number of the index in the list.... I will try it to, but I have no problem if you have a suggestion?

Thanks

1 Like

Die Verwendung der "length"-Methode aus dem Text-Block macht nur bei "Strings" Sinn. Eigentlich sollten Nicht-strings gar nicht angekoppelt werden können.

(Using the "length" method from the text block only makes sense for "strings". Actually, non-strings shouldn't be able to be coupled (mounted) at all.)

1 Like

Let me add to the confusion:
Snap2
This is with project properties: show lists as JSON: false.

Snap3
Same blocks, now with show lists as JSON: true.

As Anke says, it is really wrong to try and use the length of a list in this way. The lengths of a list is defined as its number of elements, which for myList is 3.

1 Like

Du hast genau die richtigen Kombinationen , nur eine hast du ausgelassen, und das wäre "for each item block" + "get global list" und dann "length" + "item".... Und genau da bekomme ich dann statt wie in deinem Beispiel für das eine item "1", und für das nächste item "4" und für das 3 item "2", dort würde ich dann auf dem zweiten item "10" , "15" , oder sogar "30" rausbekommen . Und das ist dann das wo ich euch das Problem dann gemeldet habe... Weil auch laut meiner logic normalerweise "1", "4", "2" rauskommen sollte,.... Tut es aber nicht... Sondern gibt mir zahlen raus die keinen Sinn ergeben, ...

So jetzt werde ich mir noch kurz das Beispiel von Ghica anschauen, (ich habe sicherlich den Namen falsch geschrieben, .... Sie möge mir bitte verzeihen)

1 Like

Yes, your are right, but I don't use this combination.

I use

  1. set my list to global....
  2. Set colum_width to global
  3. Set letter width to global
  4. " For each item of" + " every Sprite", (to fill the list)
  5. "Length" + "item"
  6. If "Length" + "item" > "get global colum_width"
    Then set "colum_width" to "Length" + "item" (so i get the biggest lengt of itemlength, with this i have te width for mi column)
  7. Set button width to "colum_width"
  8. Set button text to "get global milist"

This is my setting...

But, in place that length gives me: "1" as the length, it gives me sometimes "5", sometimes "10", or sometimes "15" or other gibberish (just like your example displays it, or "28" like your example)

I m so released, that I m not crazy, because I m not the only one with this crazy result...

1 Like

Put in some blocks. As you write it down here it is total nonsense to me.

Excuse me, I was try to make the explanation by writing, but, my explanation abilities are not the best, you are right....

But thanks for reading anyway....

1 Like

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.