Author Topic: len() reads wrong count  (Read 641 times)

Offline uwe_gl

  • Mc. Print
  • *
  • Posts: 2
    • View Profile
len() reads wrong count
« 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.

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 121
  • UNUS SED LEO
    • View Profile
Re: len() reads wrong count
« Reply #1 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
« Last Edit: 2017-Apr-24 by Qedo »

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4072
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: len() reads wrong count
« Reply #2 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.
I came. I saw. I played.

Offline uwe_gl

  • Mc. Print
  • *
  • Posts: 2
    • View Profile
Re: len() reads wrong count
« Reply #3 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

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4072
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: len() reads wrong count
« Reply #4 on: 2017-Apr-24 »
Jobs a good'un. :D

Human input is generally the biggest bug in coding! :P
I came. I saw. I played.