Re: [9fans] acme/sam language question

2013-11-21 Thread Mark van Atten
 I finally get around to trying this out and (so far) it seems to work.
 Thank you!

You're welcome!

Opening the group at the end of the first line has the effect of
replacing the empty command and its implied p; see sam's man page
under `Miscellany'. This also explains why your lines, without the
grouping, had the desired effect when you executed them one by one
yourself, but not when executed from a script.

Mark.



Re: [9fans] acme/sam language question

2013-11-06 Thread Rudolf Sykora
On 31 October 2013 20:24, Rudolf Sykora rudolf.syk...@gmail.com wrote:
 On 31 October 2013 16:49, Friedrich Psiorz f.psi...@gmx.de wrote:
 It works for me, but I found another inconsistency.

 I tried it on p9p and 9vx, both in acme and sam.

 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p

 Well. If I use these commands one by one inside p9p acme
 (and probably sam, too), I truly get what I want (and what
 you say). The problem appears when I want to run it from
 a script like this:

 sam -d EOF $1  [2] /dev/null
 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p
 EOF

 then you get, since the g is on a seperate line, an extra
 output from the line before g. And if you try to join g with
 the match like

 sam -d EOF $1  [2] /dev/null
 /A/+#0;/B/-#0 g/CC/ s/CC/DD/g
 p
 EOF

 then you get no output if CC is not between A and B
 (although when it is there, you get what I want).
 In neither case I am fully satisfied. :)

 Thanks
 Ruda

So far I still do not know how to do it properly...
But it seems nobody here proposes anything...

Thanks for any clue
Ruda



Re: [9fans] acme/sam language question

2013-11-06 Thread Micah Stetson
What if you specify the address twice like this:

/A/+#0;/B/-#0g/CC/ s/CC/DD/g
/A/+#0;/B/-#0p

That doesn't work if A and B occur more than once in the file or if DD matches 
A or B. But otherwise, it seems to work for me.

Micah

On Nov 6, 2013, at 10:47 AM, Rudolf Sykora wrote:

 On 31 October 2013 20:24, Rudolf Sykora rudolf.syk...@gmail.com wrote:
 On 31 October 2013 16:49, Friedrich Psiorz f.psi...@gmx.de wrote:
 It works for me, but I found another inconsistency.
 
 I tried it on p9p and 9vx, both in acme and sam.
 
 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p
 
 Well. If I use these commands one by one inside p9p acme
 (and probably sam, too), I truly get what I want (and what
 you say). The problem appears when I want to run it from
 a script like this:
 
 sam -d EOF $1  [2] /dev/null
 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p
 EOF
 
 then you get, since the g is on a seperate line, an extra
 output from the line before g. And if you try to join g with
 the match like
 
 sam -d EOF $1  [2] /dev/null
 /A/+#0;/B/-#0 g/CC/ s/CC/DD/g
 p
 EOF
 
 then you get no output if CC is not between A and B
 (although when it is there, you get what I want).
 In neither case I am fully satisfied. :)
 
 Thanks
 Ruda
 
 So far I still do not know how to do it properly...
 But it seems nobody here proposes anything...
 
 Thanks for any clue
 Ruda
 




Re: [9fans] acme/sam language question

2013-11-06 Thread Mark van Atten
I write the script like this:

/A/+#0;/B/-#0 {
g/CC/ s/CC/DD/g
}
p

Mark.


On Wed, Nov 6, 2013 at 7:47 PM, Rudolf Sykora rudolf.syk...@gmail.com wrote:
 On 31 October 2013 20:24, Rudolf Sykora rudolf.syk...@gmail.com wrote:
 On 31 October 2013 16:49, Friedrich Psiorz f.psi...@gmx.de wrote:
 It works for me, but I found another inconsistency.

 I tried it on p9p and 9vx, both in acme and sam.

 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p

 Well. If I use these commands one by one inside p9p acme
 (and probably sam, too), I truly get what I want (and what
 you say). The problem appears when I want to run it from
 a script like this:

 sam -d EOF $1  [2] /dev/null
 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p
 EOF

 then you get, since the g is on a seperate line, an extra
 output from the line before g. And if you try to join g with
 the match like

 sam -d EOF $1  [2] /dev/null
 /A/+#0;/B/-#0 g/CC/ s/CC/DD/g
 p
 EOF

 then you get no output if CC is not between A and B
 (although when it is there, you get what I want).
 In neither case I am fully satisfied. :)

 Thanks
 Ruda

 So far I still do not know how to do it properly...
 But it seems nobody here proposes anything...

 Thanks for any clue
 Ruda




Re: [9fans] acme/sam language question

2013-10-31 Thread Friedrich Psiorz
It works for me, but I found another inconsistency.

I tried it on p9p and 9vx, both in acme and sam.
9vx acme is different form the others, for some reason. It does print
the string between A and B, but prints it with CC and not with DD like
sam and like p9p acme.

~Fritz

Am 31.10.2013 16:21, schrieb Rudolf Sykora:
 On 30 October 2013 08:47, Rudolf Sykora rudolf.syk...@gmail.com wrote:
 On 29 October 2013 17:56, Friedrich Psiorz f.psi...@gmx.de wrote:
 this should do the trick

 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p

 Thanks for the suggestion, the g construct didn't come to my mind.
 However, it doesn't work for me: again, if CC is there, it works;
 if it's not, then the final dot only contains the match for the /A/ instead
 of the whole stretch from A to B.

 Ruda
 
 no other suggestions?
 Thanks
 Ruda
 




Re: [9fans] acme/sam language question

2013-10-30 Thread Rudolf Sykora
On 29 October 2013 17:56, Friedrich Psiorz f.psi...@gmx.de wrote:
 this should do the trick

 /A/+#0;/B/-#0
 g/CC/ s/CC/DD/g
 p

Thanks for the suggestion, the g construct didn't come to my mind.
However, it doesn't work for me: again, if CC is there, it works;
if it's not, then the final dot only contains the match for the /A/ instead
of the whole stretch from A to B.

Ruda



[9fans] acme/sam language question

2013-10-29 Thread Rudolf Sykora
Hello,

how can I set a dot from after A to before B, then make a global
substitution, within thus set dot, of CC to DD and print the resulting
text?

I.e., if there isn't any CC between A and B, just print what's between
A and B, if there is, change it to DD and print all between A and B.

I have sth like this

/A/+#0;/B/-#0 s/CC/DD/g
p

which works if there *is* the CC, but not if it is not there; then the
s command just resets the dot to an empty set.

Thank you
Ruda



Re: [9fans] acme/sam language question

2013-10-29 Thread Friedrich Psiorz
this should do the trick

/A/+#0;/B/-#0
g/CC/ s/CC/DD/g
p

~Fritz

Am 29.10.2013 16:31, schrieb Rudolf Sykora:
 Hello,
 
 how can I set a dot from after A to before B, then make a global
 substitution, within thus set dot, of CC to DD and print the resulting
 text?
 
 I.e., if there isn't any CC between A and B, just print what's between
 A and B, if there is, change it to DD and print all between A and B.
 
 I have sth like this
 
 /A/+#0;/B/-#0 s/CC/DD/g
 p
 
 which works if there *is* the CC, but not if it is not there; then the
 s command just resets the dot to an empty set.
 
 Thank you
 Ruda