I am looking to split a string containing several records into individual items in a stringlist. (Delphi 7.)
Here is the raw text in a single long string:
+CMGL: 0,”REC UNREAD”,”+27832729407″,,”12/03/17,21:32:05+08″This is the text in message 1+CMGL: 1,”REC UNREAD”,”+27832729407″,,”12/03/17,21:32:30+08″And this is the text in message 2+CMGL: 2,”REC UNREAD”,”+27832729407″,,”12/03/17,21:32:58+08″This is the text in message 3+CMGL: 3,”REC UNREAD”,”+27832729407″,,”12/03/17,21:33:19+08″And finally text in message 4+CMGL: 4,”REC UNREAD”,”+27832729407″,,”12/03/17,21:34:03+08″Ok one more the the text in 5th messageOK
I received it from a GSM device. The final character 2 characters are always OK, being the result from my GSM device.
This is the result I require:
+CMGL: 0,"REC UNREAD","+27832729407",,"12/03/17,21:32:05+08"This is the text in message 1
+CMGL: 1,"REC UNREAD","+27832729407",,"12/03/17,21:32:30+08"And this is the text in message 2
+CMGL: 2,"REC UNREAD","+27832729407",,"12/03/17,21:32:58+08"This is the text in message 3
+CMGL: 3,"REC UNREAD","+27832729407",,"12/03/17,21:33:19+08"And finally text in message 4
+CMGL: 4,"REC UNREAD","+27832729407",,"12/03/17,21:34:03+08"Ok one more the the text in 5th message
(each +CGML is the start of a new line)
I can work with it from here as it is uniform. I would appreciate any help. I hope this makes sense.
Thanks!
You can use the
PosExandCopyfunctions to build a function to split the string.Check this sample