home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1995 March / SOFM_Mar1995.bin / mac / SRI / General Interest / Programming / J / Examples / script.js < prev   
Encoding:
Text File  |  1993-12-02  |  2.3 KB  |  88 lines  |  [TEXT/????]

  1.    NB. utilities for script files
  2.    NB.
  3.    NB. script utilities assume files have extension:  .js
  4.    NB. and by default use directory:  examples
  5.    NB. 
  6.    NB.  builds        builds a script file from several script files
  7.    NB.  prints        print script file (requires Windows MS Write)
  8.    NB.  reads         read script file
  9.    NB.
  10.    NB.  gets          get script  ...is defined in init.js
  11.    NB.
  12.    NB.  prfiles       print files (called by prints)
  13.    
  14.    SCRIPTNAMES=: 'builds prfiles prints reads'
  15.    
  16.    NB. builds
  17.    NB. newfile builds oldfiles
  18.    builds=: 0 : 0
  19. :
  20. dat=. 1!:1&< &. > }.0;y.
  21. dat=. ;(,&LF @ toLF) &.> dat
  22. delnb=. #~ -.@(+./\)@('NB.'&E.)
  23. dat=. delnb &.> < ;._2 dat
  24. dat=. ; (,&CRLF)&.>dat
  25. dat 1!:2 }.0;x.
  26. )
  27.    
  28.    NB. prfiles
  29.    NB. print script files
  30.    NB.
  31.    NB. Note: requires Windows MS Write. If not available, modify
  32.    NB. the definition accordingly.
  33.    NB.
  34.    prfiles=: 0 : 0
  35.     $.=. >(16<3!:0 y=. y.){$.;L0
  36.     y=. <;._1 ' ',y
  37.  
  38. L0) CRLF2=. CRLF,CRLF
  39.     dat=. read &.> y
  40.     del=. }.~ _2&*@(CRLF2&-:)@(_4&{.)
  41.     dat=. del &.> dat
  42.     y=. 'File: '&, &.> ,&CRLF2 &.> y
  43.     dat=. y ,&.> dat
  44.     line=. CRLF,(80$196{a.),CRLF2
  45.     dat=. dat ,&.> <line
  46.     dat=. (-#line) }. ;dat
  47.  
  48.     dat write scratch=. 'c:\prints.tmp'
  49.     wddl=. 6!:3@(1&[) @ wd
  50.  
  51.     'ymd' =. 3 {. 6!:0 ''
  52.     mth=. _3[\'   JanFebMarAprMayJunJulAugSepOctNovDec'
  53.     t=. (2":d),' ',(m{mth),3":100|y
  54.     hdr=. (11#TAB),t,'  Page '
  55.  
  56.     wd   'winexec "write.exe ',scratch,'";'
  57.     wddl 'sendkeys "n+^{end}%cfCourier New{tab}{tab}9~^{home}";'
  58.     wddl 'sendkeys "%dp{tab}0.75{tab}0.75{tab}0.75{tab}0.75~";'
  59.     wddl 'sendkeys "%dh%cfCourier New{tab}{tab}9~";'
  60.     wddl 'sendkeys "',hdr,'";'
  61.     wddl 'sendkeys "%dh0.4{tab} {tab}~{tab}{tab}~";'
  62.     wddl 'sendkeys "%fp~";'
  63. )
  64.    
  65.    NB. prints
  66.    NB. e.g.  prints 'files misc ts'
  67.    prints=: 0 : 0
  68. 'examples\' prints y.
  69. :
  70. NB. y. = script filenames, if empty prompt for a name
  71.     $.=. >(0<#y=. y.){$.;L0
  72.     t=. 'mbopen "Select File" "',x.,'" ""'
  73.     t=. t,' "Script(*.js)|*.js|All(*.*)|*.*"'
  74.     t=. t,' ofn_filemustexist;'
  75.     y=. wddata t
  76.     $.=. L1
  77.  
  78. L0) $.=. >(16<3!:0 y){$.;L1
  79.     y=. (<'') -.~ <;._1 ' ',y
  80.     js=. , #&'.js'@(-.@('.'&e.))
  81.     y=. x.&, &.> js &.> y
  82.  
  83. L1) prfiles y
  84. )
  85.    
  86.    NB. reads
  87.    reads=: '''examples\'' reads y.' : '1!:1 <x.,y.,''.js'''
  88.