Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,552 of 68,980    |
|    dr.j.r.stockton@gmail.com to dr.j.r...@gmail.com    |
|    Re: Remove all but digits    |
|    26 May 20 05:46:07    |
   
   On Tuesday, 26 May 2020 13:08:25 UTC+1, dr.j.r...@gmail.com wrote:   
      
   > REVISION : so far so good, but "regexp" must be replaced by two   
   > parts, the main expression and the modifiers, to be joined by   
   > new RegExp if using JavaScript.   
      
   BUT : The following writes to the current environment, but the change is lost   
   when the JavaScript ends.   
      
   // REGLARXP.JS (c) JRS 2020-05-26+   
   // Arguments are : SRC Rex Mod Sub DST   
      
   WScript.Echo(" REGLARXP.JS has started")   
      
   WScript.Echo(" Test .replace : " + "*NO*".replace(/NO/, "YES"))   
      
   var Args = WScript.Arguments   
   WScript.Echo(' Arguments : ' + Args(0) + ', ' +   
    Args(1) + ', ' + Args(2) + ', ' + Args(3) + ', ' + Args(4))   
      
   var WshShell = new ActiveXObject("WScript.Shell")   
   var objEnv = WshShell.Environment("Process") // was Process   
      
   var Src = objEnv(Args(0))   
   var Reg = Args(1)   
   var Mod = Args(2)   
   var Sub = Args(3)   
   var Dst = Args(4)   
   WScript.Echo(" REGLARXP.JS got Args(0) : " + Args(0) + " = " + Src)   
   WScript.Echo(" REGLARXP.JS got Args(1) : " + Reg)   
   WScript.Echo(" REGLARXP.JS got Args(2) : " + Mod)   
   WScript.Echo(" REGLARXP.JS got Args(3) : " + Sub)   
   WScript.Echo(" REGLARXP.JS got Args(4) : " + Dst + " = " + objEnv(Args(4)))   
      
   var Out = Src.replace(new RegExp(Reg, Mod), Sub)   
      
   WScript.Echo(" Src.replace result is : " + Out)   
      
   WScript.Echo(" Current " + Dst + " is " + objEnv(Args(4)))   
      
   WScript.Echo(" Write to environment next")   
      
   objEnv(Dst) = Out   
      
   WScript.Echo(" Current " + Dst + " is " + objEnv(Args(4)))   
      
   WScript.Echo(" REGLARXP.JS finishing")   
      
   // End REGLARXP.JS   
      
      
   which gives me   
      
   C:\Here>call REGLARXP ZIN "\D+" "g" "A" ZOUT   
    REGLARXP.JS has started   
    Test .replace : *YES*   
    Arguments : ZIN, \D+, g, A, ZOUT   
    REGLARXP.JS got Args(0) : ZIN = 123 fff 456   
    REGLARXP.JS got Args(1) : \D+   
    REGLARXP.JS got Args(2) : g   
    REGLARXP.JS got Args(3) : A   
    REGLARXP.JS got Args(4) : ZOUT = X   
    Src.replace result is : 123A456   
    Current ZOUT is X   
    Write to environment next   
    Current ZOUT is 123A456   
    REGLARXP.JS finishing   
   Current ZOUT is : X   
      
      
   C:\Here>   
      
      
   So, how do I, with default privilege, write to the   
   environment which SET will now show?   
      
   --   
    (c) John Stockton, near London, UK. Using Google Groups.   
    Mail: J.R.""""""""@physics.org - or as Reply-To, if any.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca