<div dir="ltr">I'd guess it probably _is_ doable in Pd, with some tangled use of the [text] (using "search" and "set").<div>When I do this type of manipulation, it's for mobile, so I'm limited to Objective-C and Java, but if you use Java you could adapt Chris' parser:</div><div><br></div><div><a href="https://github.com/chr15m/PdDroidParty/blob/master/src/cx/mccormick/pddroidparty/PdParser.java">https://github.com/chr15m/PdDroidParty/blob/master/src/cx/mccormick/pddroidparty/PdParser.java</a><br></div><div><br></div><div>to get a java data structure representation. Or, potentially simpler, port the parsing logic in that file to python or whatever language you want to use.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 2016 at 12:36 PM, João Pais <span dir="ltr"><<a href="mailto:jmmmpais@gmail.com" target="_blank">jmmmpais@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear list,<br>
<br>
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:<br>
<br>
#N struct 1164-element float x float y float nr float index float nr-show<br>
float tick-show;<br>
#N canvas 168 80 670 664 gui 0;<br>
#X obj 186 548 textfile;<br>
#X obj 167 328 openpanel;<br>
#X obj 395 878 delay;<br>
#X obj 474 838 expr 60*$f1/$f2*1000;<br>
#X msg 166 668 stop;<br>
#X obj 293 207 hradio 17 1 0 6 \$0-instructions \$0-colord-i empty<br>
0 -6 0 8 -134268 -1 -1 0;<br>
<br>
I wanted:<br>
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 ...")<br>
<br>
b) to exclude from this operation the line numbers I supply, preferably in an expression such as "5 10 20-30" etc.<br>
<br>
To give an example, with the command "100 100 4-6", the text above would be changed to<br>
<br>
#N struct 1164-element float x float y float nr float index float nr-show<br>
float tick-show;<br>
#N canvas 168 80 670 664 gui 0;<br>
#X obj 186 548 textfile;<br>
#X obj 167 328 openpanel;<br>
#X obj 395 878 delay;<br>
#X obj 100 100 expr 60*$f1/$f2*1000;<br>
#X msg 166 668 stop;<br>
#X obj 100 100 hradio 17 1 0 6 \$0-instructions \$0-colord-i empty<br>
0 -6 0 8 -134268 -1 -1 0;<br>
<br>
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.<br>
<br>
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.<br>
<br>
Thanks,<br>
<br>
jmmmp<br>
<br>
_______________________________________________<br>
<a href="mailto:Pd-list@lists.iem.at" target="_blank">Pd-list@lists.iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="http://lists.puredata.info/listinfo/pd-list" rel="noreferrer" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
</blockquote></div><br></div>