2008-11-06

Saving code snippets

I usually save snippets to my Desktop, or to "My Documents" folder, to try, then to a created folder called "C:\_CMD". This one is for long term use. I've added "C:\_CMD" to the path variable so it can be searched.

The saved file icon should display as fancy-scroll "S". If not -- the editor may be "helping" by automatically adding(& hiding) the ".txt" extention. To get around save in double-quotes: "Chrome_Incognito.js" -- and the name with this extention should "stick". If double-clicking the file opens it in the editor -- script "open" is interpreting as "open with editor" -- to get around: ctrl+shift+click to obtain a context menu that will have an "Open with..." option. Choose this - then choose: "Microsoft (R) Windows Based Script" (and check "always use..." -- if you prefer it).

WScript & external libraries

For those interested in trying some google code

1) go here: http://code.google.com/p/datejs/
    ...to download date.js

2) Save this snippet in same folder as #1 as date_sample.wsf:
      <job>
      <script src='date.js'></script>
      <script>
      var ws=5;var dt=4096+0+64;var sn=WScript.ScriptName;
      var oSh=WScript.CreateObject('WScript.Shell');
      var disp_var;
      sn='Return day start';disp_var=Date.today();
      oSh.Popup(disp_var,ws,sn,dt);
      sn='Return next Friday';disp_var=Date.today().next().friday();
      oSh.Popup(disp_var,ws,sn,dt);
      sn='Return previous Monday';disp_var=Date.today().last().monday();
      oSh.Popup(disp_var,ws,sn,dt);
      </script>
      </job>
3) Double-click date_sample.wsf

If you have trouble saving code snippits see notes here.

LibriVox's New Releases

Blog Archive