Loading ...
Sorry, an error occurred while loading the content.

559Re: Redirecting GAWK Output

Expand Messages
  • mycroftj
    May 14, 2012
    • 0 Attachment
      --- In ntb-scripts@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
      >
      > --- In ntb-scripts@yahoogroups.com, "mycroftj" <mycroftj@> wrote:
      > >
      > > --- In ntb-scripts@yahoogroups.com, "flo.gehrke" <flo.gehrke@> wrote:
      > > >
      > > ---snip
      > > >
      > > > ;[path to exe]
      > > > ^!Set %lua%=
      > > > ;[path to the script]
      > > > ^!Set %script%=
      > > > ;[text to process, e.g. ^$GetSelection$, ^$GetClipboard$]
      > > > ^!Set %input%=
      > > > ^!InsertText ^$GetOutput(^%lua% "^%script%" "^%input%")$
      > > >
      > > > I tried to reproduce this with GAWK but I can't get it to work.
      > > > For me, GAWK doesn't seem to accept the input from that ^%input%
      > > > variable.
      > > >
      > > > It works when getting the input from a file:
      > > >
      > > > ^!Info ^$GetOutput(^$GetGawkExe$ -f ^$GetScriptPath$script.awk ^$GetDocumentPath$input.txt)$
      > > ---snip
      > > > Regards,
      > > > Flo
      > > >
      > >
      > > Did you ever get an answer to this part of this problem???
      > > I think the problem here is the missing '-f' in the InsertText statement. Looks like it should be
      > > ^!InsertText ^$GetOutput(^%lua% -f "^%script%" "^%input%")$
      > >
      > > Joy
      > >
      >
      > Joy,
      >
      > diodeom described a working solution with Lua. IMHO, we can't speak of a "missing '-f' in the InsertText statement": In diodeom's model, the input doesn't come from a file but is assigned to an %Input% variable (with ^$GetSelection$ or ^$GetClipboard$).
      >
      > The problem is that we cannot apply this model to GAWK (called with NT) because we cannot use a variable as an argument in ^$GetOutput$ in a way like...
      >
      > ^$GetOutput(^$GetGawkExe$ -f ^$GetScriptPath$script.awk ^%Input%)$
      >
      > -- unless anyone explains how to achieve that.
      >
      > I hope we'll get some replies to all your questions in message #555.
      >
      > In my latest message, I described how to redirect the GAWK output TO the clipboard. So, for your own studies, it might interest you that there's also a way to get the input FROM the clipboard. See...
      >
      > http://groups.google.com/group/comp.lang.awk/browse_thread/thread/35fe58692e3ae4fa/ff3ac224c1e6afae?lnk=gst&q=clipboard
      >
      > If we could get this to work in a NT clip then it should be even possible to adjust diodeom's model to GAWK/NT.
      >
      > Flo
      >

      Accchh. Sorry about that. You are correct about the -f. I did see the input was from a variable then forgot later on. Between testing different versions of clips, external subs, running GAWK from DOS, learning GAWK syntax, etc. I was getting quite dizzy.

      I did see that message you referenced but didn't try it. Did you? At this point, I'm feeling the best way is to use your original code or, if it is applicable, my solution of echoing all the lines back out with the results as the last line.

      This is Windows, not UNIX and unless you have a good reason (which I'm sure you do) the solution you are looking for might be more effort than it is worth for most situations.

      I haven't given up. Ideas do come to me in the middle of the night.

      Joy
    • Show all 16 messages in this topic