Hello!
Is it possible for [openpanel] to return filename that includes spaces?
Thanks,
Miha...
it appears not, but even if it could, you would not really have any luck processing a value that contained spaces in pd. since it would be treated as a list most of the time.
it is particularly nasty that it doesn't work tho. especially with mp3play~, as it crashes pd if you give it an "open" command with a filename that doesn't exist (like one that is truncated at the first space, for example).
On Wed, 14 Nov 2001 21:42:15 +0100 (CET) Miha Tom miha.tomsic@guest.arnes.si wrote:
Hello!
Is it possible for [openpanel] to return filename that includes spaces?
Thanks,
Miha...
- Miha Tom¹iè --- C. na postajo 55 -- SI-1351 Brezovica pri Lj. ---
SLOVENIA -
hi,
any string is processed as an atom once it gets packed into one symbol. If you really need spaces in filenames, try [opanel], which is a crude [openpanel] clone.
Krzysztof
pix wrote:
it appears not, but even if it could, you would not really have any luck processing a value that contained spaces in pd. since it would be treated as a list most of the time.
...
Miha Tom miha.tomsic@guest.arnes.si wrote:
...
Is it possible for [openpanel] to return filename that includes spaces?
/* Copyright (c) 1997-2000 Miller Puckette.
#include <stdio.h> #include <string.h> #include "m_pd.h"
static t_class *opanel_class;
typedef struct _opanel { t_object x_obj; t_symbol *x_s; } t_opanel;
static void *opanel_new(void) { char buf[50]; t_opanel *x = (t_opanel *)pd_new(opanel_class); sprintf(buf, "d%x", (t_int)x); x->x_s = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_s); outlet_new(&x->x_obj, &s_symbol); return (x); }
static void opanel_bang(t_opanel *x) { sys_vgui("pdtk_opanel %s\n", x->x_s->s_name); }
static void opanel_anything(t_opanel *x, t_symbol *s, int argc, t_atom *argv) { char buf[MAXPDSTRING]; *buf = '\0'; while (argc--) if (argv->a_type == A_SYMBOL) { if (*buf) strcat(buf, " "); strcat(buf, argv++->a_w.w_symbol->s_name); } if (*buf) outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); }
static void opanel_free(t_opanel *x) { pd_unbind(&x->x_obj.ob_pd, x->x_s); }
static void opanel_guidefs(void)
{
sys_gui("proc pdtk_opanel {target} {\n");
sys_gui(" global pd_opendir\n");
sys_gui(" set filename [tk_getOpenFile -initialdir $pd_opendir]\n");
sys_gui(" if {$filename != ""} {\n");
sys_gui(" set directory [string range $filename 0
[expr [string last / $filename ] - 1]]\n");
sys_gui(" set pd_opendir $directory\n");
sys_gui(" pd [concat $target "filename" $filename\;]\n");
sys_gui(" }\n");
sys_gui("}\n");
}
void opanel_setup(void) { opanel_class = class_new(gensym("opanel"), (t_newmethod)opanel_new, (t_method)opanel_free, sizeof(t_opanel), 0, A_DEFFLOAT, 0); class_addbang(opanel_class, opanel_bang); class_addanything(opanel_class, (t_method)opanel_anything); opanel_guidefs(); }
#N canvas 0 0 774 308 12; #X obj 15 53 opanel; #X msg 15 13 bang; #X obj 44 91 print; #X symbolatom 44 124 80 0 0; #X obj 15 198 soundfiler; #X obj 15 241 table t; #X msg 15 158 read -resize $1 t; #X connect 0 0 3 0; #X connect 0 0 6 0; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 6 0 4 0;
Here's a (cranky) idea I'm thinking about for this: what if "openpanel" translated filenames into encoded strings without white space, so that a filename, "program files", became "program\sfiles" and "a\b c" became "a\b\sc". I'd fix all the file opening messages throughout Pd to make the opposite translation -- whenever you see a backslash - s, substitute a space...
gotchas are:
message box, has to change it;
de-backslashing function (which I'll incorporate into open_via_path() for instance) before opening the file in question; same for "save" operations.
Does this sound like a reasonable solution?
cheers Miller
On Thu, Nov 15, 2001 at 01:09:23PM +0100, pix wrote:
it appears not, but even if it could, you would not really have any luck processing a value that contained spaces in pd. since it would be treated as a list most of the time.
it is particularly nasty that it doesn't work tho. especially with mp3play~, as it crashes pd if you give it an "open" command with a filename that doesn't exist (like one that is truncated at the first space, for example).
On Wed, 14 Nov 2001 21:42:15 +0100 (CET) Miha Tom miha.tomsic@guest.arnes.si wrote:
Hello!
Is it possible for [openpanel] to return filename that includes spaces?
Thanks,
Miha...
- Miha Tom¹iè --- C. na postajo 55 -- SI-1351 Brezovica pri Lj. ---
SLOVENIA -
Is this sort of thing really necessary? The standard system on both Win32 and OS X is to wrap paths in quotes, as in "C:\My SoundFiles\Bass Riff.wav"
indeed, as you illustrate below.
Doesn't this already work with PD?
Richard Dobson
Miller Puckette wrote:
Here's a (cranky) idea I'm thinking about for this: what if "openpanel" translated filenames into encoded strings without white space, so that a filename, "program files", became "program\sfiles" and "a\b c" became "a\b\sc". I'd fix all the file opening messages throughout Pd to make the opposite translation -- whenever you see a backslash - s, substitute a space...
Test your DAW with my Soundcard Attrition Page! http://www.bath.ac.uk/~masrwd (LU: 18th July 2001) CDP: http://www.bath.ac.uk/~masjpf/CDP/CDP.htm (LU: 1st August 2001)
No, Pd doesn't do this, at least not yet. Perhaps this is a better scheme than the one I'm proposing. I have to look and see how hard it would be to implement (maybe it's just easy)...
cheers Miller On Fri, Nov 16, 2001 at 05:29:13PM +0000, Richard Dobson wrote:
Is this sort of thing really necessary? The standard system on both Win32 and OS X is to wrap paths in quotes, as in "C:\My SoundFiles\Bass Riff.wav"
indeed, as you illustrate below.
Doesn't this already work with PD?
Richard Dobson
Miller Puckette wrote:
Here's a (cranky) idea I'm thinking about for this: what if "openpanel" translated filenames into encoded strings without white space, so that a filename, "program files", became "program\sfiles" and "a\b c" became "a\b\sc". I'd fix all the file opening messages throughout Pd to make the opposite translation -- whenever you see a backslash - s, substitute a space...
.....
Test your DAW with my Soundcard Attrition Page! http://www.bath.ac.uk/~masrwd (LU: 18th July 2001) CDP: http://www.bath.ac.uk/~masjpf/CDP/CDP.htm (LU: 1st August 2001)
hi,
the prospect of refining Pd internals to allow for a more flexible dealing with message text, is good news, no doubt.
Please, do not restrict this discussion to "how to accept filenames with spaces" only! If the only problem was: how to prevent [open(save)panel] from truncating of filenames, then the best solution would be to leave it as an internal matter of gui -> [openpanel] communication, with [openpanel] output being an unquoted symbol with unescaped whitespace[1]. If this does not work, please show me why.
But embedding whitespace in symbols typed into message box or loaded from file is a totally different story. And it does not matter, if those symbols are to be interpreted as filenames, or as anything else.
In tune with Richard -- quoting is less clumsy than escaping, it is less foreign for an average user (unix user as well :-), less restrictive, and less expensive to parse. For instance, {symbol "why not"} is a valid message box to type, while {symbol why\snot} is not -- at least this is now the case.
And the algorithm for atom_string() would be simple and cheap: if a symbol contains special chars or separators, or if it starts with a digit, then do add quotes. The algorithm for binbuf_text() would be even simpler -- no characters need special treatment, except the quotes themselves.
But making quoting a universal standard, while retaining existing escaping scheme for dollars, semis, and commas, requires care. There are many special cases, various pitfalls, and much room for users to abuse them. If having message target or message selector in quotes does not really scare me, what about resolving any combination of quoted and escaped or not escaped dollars, semis, and commas? Maybe it is easy, but I am lost here...
K"puzzled"of
[1] This effect could be achieved crudely, just as in my [opanel] example, which bashes any separator (be it single- or multi- character) to a single space. Otherwise some escaping scheme could be used -- and it really does not matter what scheme.
Miller Puckette wrote:
No, Pd doesn't do this, at least not yet. Perhaps this is a better scheme than the one I'm proposing. I have to look and see how hard it would be to implement (maybe it's just easy)...
...
On Fri, Nov 16, 2001 at 05:29:13PM +0000, Richard Dobson wrote:
Is this sort of thing really necessary? The standard system on both Win32 and OS X is to wrap paths in quotes, as in "C:\My SoundFiles\Bass Riff.wav"
On Sat, Nov 17, 2001 at 06:37:34PM +0100, Krzysztof Czaja wrote:
But making quoting a universal standard, while retaining existing escaping scheme for dollars, semis, and commas, requires care. There are many special cases, various pitfalls, and much room for users to abuse them. If having message target or message selector in quotes does not really scare me, what about resolving any combination of quoted and escaped or not escaped dollars, semis, and commas? Maybe it is easy, but I am lost here...
Indeed, I almost went insane that way once trying to get commas and semis to work in Max... then Zicarelli somehow added a quoting feature ON TOP of that for Cycling74. I'd like to find something simple this time...
cheers Miller
<newbie> You could possibly url form encode things for greater network portability.. Ie a space becomes %20 etc... </newbie>
on 16/11/01 4:45 PM, Miller Puckette at mpuckett@man104-1.ucsd.edu said something like:
Here's a (cranky) idea I'm thinking about for this: what if "openpanel" translated filenames into encoded strings without white space, so that a filename, "program files", became "program\sfiles" and "a\b c" became "a\b\sc". I'd fix all the file opening messages throughout Pd to make the opposite translation -- whenever you see a backslash - s, substitute a space...