[PD] Backslash
Frank Barknecht
fbar at footils.org
Wed Jul 16 19:43:11 CEST 2008
Hallo,
Jorge Cardoso hat gesagt: // Jorge Cardoso wrote:
> I'm having a problem with backslashs on windows and none of the solution I found
> on the web works in my case:
>
> I have an OSC message that has a path to a file. Something like: "c:\folder\image.jpg"
>
> How can I convert that, in PD, to "c:/folder/image.jpg"? I can't control how the OSC messages
> are generated...
For example with attached pdlua external (needs pdlua)
You need some kind of external, as it's not possible with pure Pd to
split a symbol at a certain character. You could also use something
like Zexy's symbol2list for this task - use
[92(
|
[makefilename %c]
to generate a backslash symbol to feed into s2l's right inlet then.
Using Lua has the big advantage that you can do some more string
processing in the same object immediatly and in my experience, once
you start with text processing you often need a bit more power anyway,
that's why I'd prefer Lua here.
Ciao
--
Frank Barknecht _ ______footils.org__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bs2x-help.pd
Type: application/puredata
Size: 603 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20080716/ba9d22a4/attachment.bin>
-------------- next part --------------
-- bs2x class: replace backslashes in symbol with something else (default: "/" or arg1)
-- fbar 2008
local M = pd.Class:new():register("bs2x")
function M:initialize(name, atoms)
self.x = "/"
if (type(atoms[1]) == "number") or (type(atoms[1]) == "string") then
self.x = atoms[1]
end
self.inlets = 2
self.outlets = 1
return true
end
function M:in_1_symbol(s)
local result = string.gsub(s, "\\", self.x)
self:outlet(1, "symbol", {result})
end
function M:in_2_symbol(s)
self.x = s
end
function M:in_2_float(f)
self.x = f
end
More information about the Pd-list
mailing list