Parsing CHAR array (string) with SREAD
-
Vlad222 -
November 1, 2017 at 3:43 PM -
Thread is marked as Resolved.
-
-
Geee... how long you have been here?
1. KSS version?
2. What is the EXACT message you get?
3. What is the EXACT code you use (not just that line)? Did you initialize offset?
4. SWRITE is used to COMPOSE string, SREAD is used to PARSE string. -
Geee... how long you have been here?
1. KSS version?
2. What is the EXACT message you get?
3. What is the EXACT code you use (not just that line)? Did you initialize offset?
4. SWRITE is used to COMPOSE string, SREAD is used to PARSE string.Yes, of course it is SREAD : )
KSS 8.3.290
Offset is 0 -
still no answers to all questions.
btw, you may want to try %i instead of %d
-
still no answers to all questions.btw, you may want to try %i instead of %d
As I understand, %i is the the same that %d - "Integer number represented as a decimal"
My code:
Code
Display More;FOLD Declaration CHAR bytes[200] DECL EKI_STATUS RET INT OFFSET, i, int1, int2, int3 DECL STATE_T state REAL real1, real2, real3 ;ENDFOLD ;FOLD INI ;FOLD BASISTECH INI ; BAS (#INITMOV,0 ) ;ENDFOLD (BASISTECH INI) ;FOLD USER INI int1=0 int2=0 int3=0 real1=0 real2=0 real3=0 ;ENDFOLD (USER INI) ;ENDFOLD (INI) FOR i=(1) TO (200) Bytes[i]=0 ENDFOR RET=EKI_Init("XmlServer") RET=EKI_Open("XmlServer") EKI_CHECK(RET,#QUIT) wait for $FLAG[600] OFFSET = 0 wait for $FLAG[21]==TRUE RET = EKI_GetString("XmlServer","Buffer",bytes[]) offset = 0 msgnotify(bytes[]) SREAD(bytes[],state,offset,"%d,%d,%d,%f,%f,%f",int1,int2,int3,real1,real2,real3) ...
bytes array is:
I tried with %i. Error is KSS02255 "Expression not equal to CHAR, INT, ENUM"
I want to use comma separator, not space
-
Buthe your string uses both...
-
KRC2 documentation mentions that SREAD can only use space as delimiter.
If you are using commas, you need to convert them spaces before using SREAD.