| Hi all -
thanks to the new csound parser (= the hard work of Steven, John, Tito
and others) which makes it now possible to return strings from UDOs, I
can provide a much simpler version of my Stray collection. They can be
useful for working with filenames or any collection of strings and/or
numbers. If a Stray consists of numbers, it can be converted to a
function table via StrayNumToFt. The UDOs can be found at
www.joachimheintz.de/soft/Strays.zip or in the attachment (examples
included). More examples and a complete documentation are in the UDO
repository (www.csounds.com/udo > Utilities).
Some examples:
ilen StrayLen "a b c d e"
ilen -> 5
Sel StrayGetEl "a b c d e", 0
Sel -> "a"
inum StrayGetNum "1 2 3 4 5", 0
inum -> 1
ipos StrayElMem "a b c d e", "c"
ipos -> 2
ipos StrayNumMem "1 2 3 4 5", 3
ipos -> 2
Sres StraySetEl "a b c d e", "go", 0
Sres -> "go a b c d e"
Sres StraySetNum "1 2 3 4 5", 0, 0
Sres -> "0 1 2 3 4 5"
Srev StrayRev "a b c d e"
Srev -> "e d c b a"
Sub StraySub "a b c d e", 1, 3
Sub -> "b c"
Srem StrayRemDup "a b a c c d e e"
Srem -> "a b c d e"
ift,iftlen StrayNumToFt "1 2 3 4 5", 1
ift -> 1 (same as f 1 0 -5 -2 1 2 3 4 5)
iftlen -> 5
Thanks for testing and reporting any problems. And, by the way, I am not
very happy with the code for the UDOs StrayExpr and Stray1Expr which are
used by StrayNumToFt
(http://www.csounds.com/udo/displayOpcode.php?opcode_id=118). I think
there is certainly a better solution, and if someone feels dedicated to
this sort of string parsing, I am happy to borrow his code.
Best -
joachim
|