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

Hello there,

I found out a little speciality of the using of the "length block".
(I mean the winered length block from the winered text blocks

If you make for example a list:

  1. Set list to global

  2. Add item to list
    a. List (where you will put the text):
    (For example: "global list")
    (normally set to: "empty list")
    b. item: (any letter or sign)

  3. Now you will take this letters from the list: for example: direktly

Set "button1" to "global_list"...

But you have more than on item in this list, and you will or must configure the width of this Button to adjust automatically to the length of the longest item in the list.

How you find out the length of the item?

Yes, yo say with the winered length block from the text part....

Ok, you think:

"For each item" block
"If block" , ah and don't forget to set a "letter width variable" (this can be maked also with a button, textbox, or other also)... You can use the text part of this thing's, but because the button text part is empty, this is the same like you set a variable an put them a 0 from the math blocks.

Ok, if length "get item block" > "letter width variable"
Then set "letter width" to length
of item

What comes out?
Sometimes 1 (the right one) or 10 or other thing....

Why is this so?

Ok, you make your list.
Set list to global
Add item list: "get global list"
Item: "textblock"

Then comes out lengt = 1

But if you add by "item" the "make list block" and then put the item, for example a textblock, then comes out 5

And if you add a" join Block" then comes out 10

Or, if you add a second join block in cascade then comes out a other number. (I was not tested it jet, but I will)

The longer the cascade the longer the number....

1 Like

Try to take the length of this list.

Tell us what you get.

No, I going totally conform with you, for store the list data, this is only possible with setting a "variable"

Because the list block don't accept a "button.text" block , there only goes when you put a variable "get (any name))" variable block.

But the other problem are really present, the number of the textlengt varies by the cascade what you use by the text or letter inserting in the add to list part.

For example: when I was using it in the first time:

"Add to list" block + join 1. Item: "Textblock: [text: Sprite]
2. Item "get local [spritenumber]

And it was giving me 10 or 15...

And I was thinking: "ah ok, this system gives me automatically the pixels width of the letters"... And I forget to look further on this numbers.

But when I looking recently, to make a little bit order in the program, and change to the longer words... There I see the discrepancies, and that there is something wrong...

And there I see what I explain above.

leftedge_copy_1 (8).aia (24.8 KB)

1 Like

Why don't you post your blocks. That way it is more "visible" what you are trying to do. Use a Do it to get the results.

I was simplifying and automate it a little bit, but the result is the same, list view or button, the result is the same...

Test4 (1).aia (2.1 KB)

1 Like

Do you mean for instance this?

That the length is 10, is correct.
The string ["a", "b"] = in total 10 characters.

Yes, I have this results, but I get it when I take the result from the "get local/global[name] block" but, i think it's the same...

But how comes the result "10" I m confused.... Because, when I counted the letters = 2 + the 4 " signs + the "," =1 + the space =1 i count only 8, not 10...

And normally when accept this 8 as a 10. How it comes that I repently from the same letters when I put an second join with the textblock with the \n code then I have 30 or so?

But I ask the block for the length of the word or letter, because this comas and or brackets are putted by the block, but I need to know the length of the letters, not the length of the programming internal signs... For this normaly was created in the past the diference between CSV, and other sheet formats, and the integer, decimal, or string things or what are called this other formats... But normaly by length I mean words or letters, by the text thing, and when i will know how much rows with data i have in my list or sheet, then i take the blue lengt block from the list part....

Because this I m confused, which code then I must add to the programming to get the realy length of my text, but only the visible words or letters.... Because if not, then it is not possible to get clean numbers to calculate the width of my text, and only my text.... And without hidden signs.

Excuse my long explanation, but it is important that I provide you with the complete information of the problem/issues.....

1 Like

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?


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:
This is with project properties: show lists as JSON: false.

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