PDA

View Full Version : String functions



Art
- 27th November 2016, 02:40
Hi Guys :)
The most requested feature for PBP is string functions.
A string is an array full of text with a zero at the end.
Presto you now have string functions! The End :)













Seriously though... What is actually meant when someone requests string functions?
What exactly is the new ability achieved with them, and provide an example syntax.
PBP commands such as LCDOUT and SERIN/OUT can already be likened to strings, so I’m curious to know.
Cheers, Art.

richard
- 27th November 2016, 05:34
yes, string functions can be implemented with pbp code blocks but just like in your "serout code space " thread
what looks like a simple code block often turns out to be larger,slower,clunkier and having much less functionality than a properly integrated
piece of code . unless its done in asm of course but thats no guarantee . asm code that takes full advantage of chip resources over the range
of chips that pbp supports is not that simple to implement , with 8/16 bit fsr's , linear memory etc it gets complicated.
i'm sure programers could integrate some handy equivlents of some useful C functions ,but a lot can be emulated anyway
len() eg for j = 0 to len(mystr): do stuff : next
equiv j=0: while mystr[j] : do stuff : j=j+1:wend
strcat() eg newstr = oldstr+mystr (c strcat(newstr,oldstr); strcat(newstr,mystr) )
equiv arraywrite newstr,[str oldstr,str mystr]
atoi() eg int j = atoi(mystr)
equiv arrayread mystr,[dec j]



strok() missing in action

Art
- 27th November 2016, 07:03
That's pretty much what I think,
hence I'd like to hear what native string handling is supposed to achieve.

The most fun to write that I can think of right now is sprintf with format modifiers
that would naturally extend the length of the original string,
but then if you had the string with all the nice verbose numbers in it, what use would it be? :D
Especially when the likes of lcdout and serout do the same thing.