home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-02 | 2.7 KB | 100 lines | [TEXT/????] |
- NB. standard J initialization
- NB.
- NB. (excluding windows definitions)
-
- t=. 'TAB LF CR CRLF EAV PAV'
- t=. t,' script sscript read write append out'
- t=. t,' names erase drep tree lrep ts timer'
- t=. t,' bind box datatype gets indx list nl'
- t=. t,' toCR toLF toCRLF type'
- SCRIPTNAMES=: t
-
- TAB =: 9{a.
- LF =: 10{a.
- CR =: 13{a.
- CRLF =: 13 10{a.
- EAV =: 255{a.
- PAV =: 254{a.
-
- NB. box if open
- NB. can be used with external conjunctions requiring boxed arguments,
- NB. e.g. allowing both read '\config.sys' and read <'\config.sys'
- box=: ]`<@.(32&>@(3!:0))
-
- script=: 0!:2&box f.
- sscript=: 0!:3&box f.
- read=: 1!:1&box f.
- write=: (1!:2 box) f.
- append=: (1!:3 box) f.
- out=: 1!:2&2
- names=: 4!:1
- erase=: 4!:55&box f.
- drep=: 5!:2&box f.
- tree=: 5!:4&box f.
- lrep=: 5!:5&box f.
- ts=: 6!:0
- timer=: (1000&*)@(6!:2) NB. result in milliseconds
-
- NB. bind - bind monadic verb to an argument creating a new verb
- NB. that ignores its argument
- NB.
- NB. e.g. fini=: out bind 'finished...'
- bind=: [. @ (]. (&[))
-
- NB. datatype
- t=. ;:'boolean literal integer floating complex boxed'
- datatype=: {&t@(2&^.@(3!:0))
-
- NB. gets - get script
- NB.
- NB. syntax: {directory} gets name
- NB. file extension is set to .js
- NB. directory defaults to 'examples\'
- gets=: 0 : 0
- 'examples\' gets y.
- :
- SCRIPTNAMES=: i.0 0
- 0!:3 <x.,y.,'.js'
- SCRIPTNAMES
- )
-
- NB. indx
- NB. used to build case statements (e.g. in Windows programs)
- NB. syntax: verb=. gerund indx noun
- NB. resulting verb looks up noun in its argument, and executes
- NB. corresponding item from gerund
- indx=: [. @. (]. (&e.) (i.&1@))
-
- NB. list
- NB. syntax: {width} list data
- NB. accepts data as one of:
- NB. boxed list
- NB. character vector, delimited by CR, LF or CRLF; or by ' '
- NB. character matrix
- NB. formats in given width, default 77
- list=: 0 : 0
- 77 list y.
- :
- $.=. >(2=#$y=. >y.){$.;L0
- $.=. $. #~ 0<#y.
- d=. (' ',LF) {~ LF e. y=. toLF ": y.
- y=. [;._2 y, d #~ d ~: {: y
- L0) y=. y-. ' '{.~ c=.{:$ y=. (": y),.' '
- (- 1>. <. x. % c) ;\ <"1 y
- )
-
- NB. nl - namelist, e.g. nl 3 lists verbs in workspace
- nl=: list@(4!:1)
-
- NB. toCR returns character strings delimited by CR, etc.
- subs=. [. & ((((e.&) (# i.@#@)) (@])) })
- crlf=. #~ -.@(CRLF&E.)
- toLF=: LF subs CR @ crlf f.
- toCR=: CR subs LF @ crlf f.
- toCRLF=: 2&}.@;@(((CR&,)&.>)@<;.1@(LF&,)@toLF)
-
- NB. type (of object)
- t=. <;._1 '/not defined/NA/noun/verb/adverb/conjunction/other'
- t=. {&t@(4!:0)
- type=: t&box f.
-