Variable Length Strings, No Delimiter
T Chap
Posts: 4,223
Is there some method already worked out for reading varying lengths of strings that don't have any termination?
Next, anyone know what the theoretical maximum string length is on the Propeller?
Thanks
Next, anyone know what the theoretical maximum string length is on the Propeller?
Thanks
Comments
One metod of having varying lengths of strings is to have length pointers at the beginning of that strings.
But I have not see that Obiect on Forum
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer
If you don't ask you wont know
If your gonna construct something, make it·as simple as·possible yet as versatile as posible
Sapieha
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
It is not simple metod.
It must scan for string Line Number and length.
In principle it is many old Basic computers have that system.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer
If you don't ask you wont know
If your gonna construct something, make it·as simple as·possible yet as versatile as posible
Sapieha
Post Edited (Sapieha) : 9/19/2008 10:42:28 PM GMT
To answer your second question, strings like those in Spin that use a terminator have no theoretical maximum length. The downside is that you can't use the terminator (in Spin's case, $00) as an element of the string. Also, you have to know ahead of time how long your longest strings will be, so you can allocate big enough arrays to hold them.
For strings like Sapieha is talking about, the maximum length would depend on the size of the length indicator. One byte is common, in which case the maximum length would be 255 characters; for two bytes, 65535 characters; and so on.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Post Edited (Phil Pilgrim (PhiPi)) : 9/19/2008 10:30:36 PM GMT
I have that system on My Control system that have Tiny Basic as its base.
It was more efective in in speed that systems based on delimiters to scan for next Line of program code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer
If you don't ask you wont know
If your gonna construct something, make it·as simple as·possible yet as versatile as posible
Sapieha
crude concept:
Pub Read
array[noparse][[/noparse] 0] := ser.rx 'wait until string starts
array[noparse][[/noparse] 1] := ser.rxtime(1) ' if there is a byte, read it, if not, waits 1ms then next line (returns)
array[noparse][[/noparse] 2] := ser.rxtime(1) ' waits 1ms
....
array[noparse][[/noparse] 1000] := ser.rxtime(1) ' waits 1ms
When it gets to the end, done, return and do other stuff
Thanks for that info Phil, I do have an occasional payload string of 934 bytes to manage, so trying to look for ways to get it, and send it somewhere else. All responses from a certain device are different lengths with no delimeter. Using time seems to be a solution, just return if it waits too long for a byte.
Post Edited (Originator) : 9/19/2008 11:13:39 PM GMT
In system I scribe on it is not necessary that strings must have given positions in file/minnen type arays.
It is not necessary Line numbers from (1-X). It can have Line numbers type (1, 5, 3, 10 etc... ).
You only scan for Line number and if it is not what you want ad pointer length for Line and test for next Line number etc...
Ps. Line length pointer is Line number + line length pointer·+ Chars
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer
If you don't ask you wont know
If your gonna construct something, make it·as simple as·possible yet as versatile as posible
Sapieha
Post Edited (Originator) : 9/20/2008 3:28:18 AM GMT