GLBasic forum

Main forum => Bug Reports => Topic started by: uwe_gl on 2017-Apr-23

Title: len() reads wrong count
Post by: uwe_gl on 2017-Apr-23
Hello,
I use the len() function with  a variable is filled with the SOCK_RECV Command. len() tells me that the String has 45 Chars. But the String has 220 Chars. In the String are more Chars with an value less then 30.

Hallo,
Die Len() Funktion gibt eine falsche Zeichenanzahl zurück bei einen mit SOCK_RECV Empfangenen String der ASC-Zeichen kleiner 30 enthält.
Title: Re: len() reads wrong count
Post by: Qedo on 2017-Apr-24
It works for me
Try all the combinations
ciao

(modified)
// Project: len
// Start: Monday, April 24, 2017
// IDE Version: 14.497
a$=""
count=220
FOR k=1 TO 20000
   FOR i=1 TO count
      a$=a$+CHR$(RND(255))
   NEXT
   IF LEN (a$)<>count
      PRINT "error  " + LEN (a$),0,100
      SHOWSCREEN
      MOUSEWAIT
   ENDIF
   a$=""
NEXT
PRINT "OK",0,100
SHOWSCREEN
SLEEP 1000
Title: Re: len() reads wrong count
Post by: Ian Price on 2017-Apr-24
Can you post the string here? If it is a bug, then having the actual string can help solve it easier?

Maybe certain chars are not counted? Dunno. More info from you will help identify the problem.
Title: Re: len() reads wrong count
Post by: uwe_gl on 2017-Apr-24
Ok, i solved the problem.
The error was by my.  :nw:
I changed the programm for output the string to file. Suddenly the value of len() was ok. It was an error by printing the value.
Thanks to all.
Greatings Uwe
Title: Re: len() reads wrong count
Post by: Ian Price on 2017-Apr-24
Jobs a good'un. :D

Human input is generally the biggest bug in coding! :P