Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #35529

Re: Batch pipe JScript question

Newsgroups comp.lang.javascript
Subject Re: Batch pipe JScript question
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <f15ab55b-562a-4005-a351-230861244b24@googlegroups.com> <XnsA942EB3CBFE8Eeejj99@194.109.6.166> <1effe412-1e7a-4140-a805-e24e05281ca2@googlegroups.com> <XnsA94376AFE4063eejj99@194.109.6.166> <b6a9a974-1a69-4313-98ee-c6d984e45ef4@googlegroups.com>
Date 2018-08-19 22:49 +0200
Message-ID <XnsA943E833B7EDFeejj99@194.109.6.166> (permalink)

Show all headers | View raw


Dr J R Stockton <J.R.Stockton@physics.org> wrote on 19 Aug 2018 in 
comp.lang.javascript:

> On Sunday, August 19, 2018 at 10:40:08 AM UTC+1, Evertjan. wrote:
>> Dr J R Stockton  wrote on 19 Aug 2018 in 
>> comp.lang.javascript:
>> 
>> > Your way might be better for piping the output into,
>> > for example, FIND or MiniTrue.
>> 
>> Yes, stdin and stdout are marvelous to bag piping.
>                                          ==========
> N.B. No normal English person would ever say or write that;

I've never met a normal English person, 
and probably would hate it when I would.

Normality is not something to strive for, 
and a dirthy mind should be a joy forever.

> to many English, 

I prefer the Scottish version.

> Royalty excepted (they seem to like it),
> "bagpiping" 

I dit not write that.

> refers to something like vehement caterwauling.
> 
> It has been said that a WWII troopship, carrying a Scots regiment
> across some part of the Indian Ocean, was reduced to a sinking condition
> by an enemy torpedo. The resourceful Pipe Sergeant-Major firstly employed
> his set of bagpipes to hearten the troops assembled on deck, secondly
> used the bag of the disassembled set to help him float ashore, and
> thirdly found the reassembled and dried set useful to dispel the
> thereby-terrified local tigers.
> 
> 
>> A pity jscript is not keeping up with javascript, ...
> 
> Maybe, but I prefer to use only code that I can read,
> which means ECMA <= 3.  And I take advantage of the
> different format of Date.toString, unlikely to change.
> 
> The results of forgetting to remove the 'g' property
> from the RegExp were somewhat surprising.  But now :
> 
> 
> // PLUS-DOW.JS Add day-of-week to output of DIR, piped I/O
> // (c) JRS 2018-08-19+
> // PLUS-DOW.BAT holds :
> //  @DIR %* /o:d | CSCRIPT //nologo C:\UTYS\PLUS-DOW.JS
> 
> function AddDow(match) { return match + " " +
>     new Date(match.replace(/-/g, "/")).toString().substring(0, 3) }

I would think there is no use for the replace function here.

However, I love Regex to much to go without, so:

function AddDow(match) { 
	return match +
	" " +
	new Date(match).toString().replace(/ .*/,'');
};

 
> //// OK, not preferred
> //// var tmp = WScript.StdIn.ReadAll()
> //// var TEMP = tmp.replace(/(\d\d\d\d-.+:\d\d )/g, AddDow)  // g HERE 
ONLY
> //// WScript.Echo(TEMP)
> 
> var stdin = WScript.StdIn
> var stdout = WScript.StdOut
> var str, RE = /(\d\d\d\d.+:\d\d )/
> 
> while (!stdin.AtEndOfStream) { 
>   str = stdin.ReadLine()
>   if (RE.test(str)) {
>     str = str.replace(RE, AddDow)
>     stdout.WriteLine("  " + str) } }
> 
> // End
> 
> Sample output :
> 
>   2014-01-10  14:29  Fri        1,165,170 $CURRASH.PNG
>   2014-03-05  00:48  Wed            3,058 SHIUMING.TXT

A normal person would perhaps prefer:

2014-01-10  14:29  free
2014-03-05  00:48  married



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Batch pipe JScript question Dr J R Stockton <J.R.Stockton@physics.org> - 2018-08-18 12:46 -0700
  Re: Batch pipe JScript question "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-08-18 13:44 -0700
    Re: Batch pipe JScript question Dr J R Stockton <J.R.Stockton@physics.org> - 2018-08-18 14:43 -0700
  Re: Batch pipe JScript question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-18 23:07 +0200
    Re: Batch pipe JScript question Dr J R Stockton <J.R.Stockton@physics.org> - 2018-08-18 15:09 -0700
      Re: Batch pipe JScript question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-19 11:40 +0200
        Re: Batch pipe JScript question Dr J R Stockton <J.R.Stockton@physics.org> - 2018-08-19 09:12 -0700
          Re: Batch pipe JScript question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-19 22:49 +0200
            Re: Batch pipe JScript question Dr J R Stockton <J.R.Stockton@physics.org> - 2018-08-20 03:22 -0700

csiph-web