Hi João,

This functionality can be created in any proper language, but it is hard to create a generic solution based on your example. For instance, how do you know it will be all the lines except the ones you specify, and do you really want all the objects at 100,100 ?

Only if you have a large number of patches with the same structure and object order it is worthwhile to create a program like you propose to patch them. Otherwise a proper code-editor will be as time-efficient in changing the patches.

If in this case you just want the [expr] and [hradio] at 100,100 for a number of patches a sed* script will do...

Creating a script to convert patches costs effort, so you want it as generic as possible. If it can be used only once, a code editor is a better way.

Fred Jan

*) sed is a unix tool just like grep, only more flexible... Maybe you should try to install cygWin, then you get most unix tools on Windows. However, prepare for a steep learning curve...

Success,

Fred Jan

P.S. first non-optimized attempt:
cat jmmmp.pd | sed -e 's/#X obj [1-9][0-9]* [1-9]expr/' -e 's/#X obj [1-9][0-9]* [1-9][0-9]* expr/#X obj 100 100 hradio/'

Dear list,

I wanted to edit some Pd files so that I can change the coordinates of
*some* lines. For example, if in a pd file there is the content:

#N struct 1164-element float x float y float nr float index float nr-show
float tick-show;
#N canvas 168 80 670 664 gui 0;
#X obj 186 548 textfile;
#X obj 167 328 openpanel;
#X obj 395 878 delay;
#X obj 474 838 expr 60*$f1/$f2*1000;
#X msg 166 668 stop;
#X obj 293 207 hradio 17 1 0 6 \$0-instructions \$0-colord-i empty
0 -6 0 8 -134268 -1 -1 0;

I wanted:
a) in the lines beginning with "#X obj", to change the 2 fields
afterwards to a general value I'll give in the command (e.g. all lines
are changed "#X obj 100 100 ...")

b) to exclude from this operation the line numbers I supply, preferably
in an expression such as "5 10 20-30" etc.

To give an example, with the command "100 100 4-6", the text above would
be changed to

#N struct 1164-element float x float y float nr float index float nr-show
float tick-show;
#N canvas 168 80 670 664 gui 0;
#X obj 186 548 textfile;
#X obj 167 328 openpanel;
#X obj 395 878 delay;
#X obj 100 100 expr 60*$f1/$f2*1000;
#X msg 166 668 stop;
#X obj 100 100 hradio 17 1 0 6 \$0-instructions \$0-colord-i empty
0 -6 0 8 -134268 -1 -1 0;

where all lines starting with #X obj were change, except for lines 4-6.
Further numbers or ranges after 4-6 would indicate other lines to
exclude from the replacement.

I know this isn't a task which can be done in Pd, but much better in a
language such as lua or python. As I don't know any of these languages,
I would appreciate some guidance on how to start, and maybe I could
myself continue the work. Preferably I would like to try it in lua, so
that I could process it in pdlua. But any suggestions are welcome.
Except using grep, as I only have access to an ms-dos console, no bash
or similar ones.

Thanks,

jmmmp

_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list

_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to