Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:12 17 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : LONGSTRING TRIM, maximum clippable length is LLEN - 1

Author Message
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 06:53pm 20 Mar 2021
Copy link to clipboard 
Print this post

Hi,
I'm working right now with UDP communication with ESP and using LONGSTRINGs. I'm filling LONGSTRING with complete UDP buffer and after the packet is received, I need to read LF separated strings from it.

After read I need to remove this parts from LONGSTRING, it works all the way except last one. I'm getting error, that maximum clippable part is LLEN - 1. Can this be in the future FW changed, so I can TRIM complete LONGSTRING? It shouldn't affect any existing program but increase effectivity.

LF = STR$(10)
DO WHILE LLEN(buf()) > 0
 bufLen = LINSTR(buf(), LF)
 IF bufLen > 0 THEN
   part = LGETSTR$(buf(), 1, bufLen - 1)
   LONGSTRING TRIM buf(), bufLen 'this works up to last part, then error
 ENDIF
LOOP

now I have modified it to
LF = STR$(10)
DO WHILE LLEN(buf()) > 0
 bufLen = LINSTR(buf(), LF)
 IF bufLen > 0 THEN
   part = LGETSTR$(buf(), 1, bufLen - 1)
   IF bufLen < LLEN(buf()) THEN
     LONGSTRING TRIM buf(), bufLen
   ELSE
     LONGSTRING CLEAR buf()
   ENDIF
 ENDIF
LOOP

Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025