There are some general utilities at the end of WS.ijs that are commented out
but perhaps should not be - I'll fix the existing wiki reference but for
now, these are as follows:
dsp=: deb"[EMAIL PROTECTED]"1
isNum=: 3 : '0=1{.0$,y.' NB. 1 if numeric arg
nameExists=: 0:"_<:[:4!:0 <^:(L.=0:) NB. 1 if var or fnc name exists, else
0.
dirExists=: 3 : '0~:#(1!:0)@< (-''\''={:y.)}.y.' NB. 0: dir does not
f2v=: 3 : 0
NB.* f2v: File to Vector: read file -> vector of lines.
vec=. l2v 1!:1 <y.
NB.)
v2f=: 4 : 0
NB.* v2f: Vector to File: write vector of lines to file as lines.
if. -.nameExists 'EOL' do. EOL=. LF end.
(;x.,&.><EOL) 1!:2 <y.
NB.EG ('line 1';'line 2';<'line 3') v2f 'C:\test.tmp'
)
l2v=: 3 : 0
NB.* l2v: Lines to Vec: convert lines terminated by LF to vector elements.
<;._1 LF,y.-.CR
)
baseNum=: 4 : 0
NB.* baseNum: return number y. in base with digits x.: positive
NB. integers only.
len=. #alph=. x. [ num=. y.
if. isNum num do.
digits=. >:<.len^.1>.num
alph{~(digits$len)#:num
else. NB. Assume "number" is character -
len#.alph i. num NB. convert to base 10 number.
end.
NB.EG '0123456789ABCDEF' baseNum 255
NB.EG '0123456789ABCDEF' baseNum 'FF'
)
On 7/9/07, Ira Fuchs <[EMAIL PROTECTED]> wrote:
Thanks! That worked fine for logger but I have a new problem using
WS.ijs:
load '/Users/ihf/Documents/J Books/J Scripts/WS.ijs'
saveAllVars '/Users/ihf/j601/temp/'
|value error: dsp
| nmlst=.<;._1' ', dsp,(names__ 0),"1' '
On Jul 9, 2007, at 8:27 PM, Sherlock, Ric wrote:
> > [mailto:[EMAIL PROTECTED] On Behalf Of Ira Fuchs
> > That would explain it. I was hoping to use these scripts on a
> > Mac. I didn't realize they were platform-dependent.
>
> I'm pretty sure the only bit that is platform-dependent it the setting
> of the tempdir (in verb todayfile).
> If you manually set the global variable FNM_logger_ to the name of log
> file you wish to write to, it will skip that part and then the script
> should work fine.
>
> Alternatively you could replace getTempDir with a Mac version, or
> even:
> getTempDir=: 3 : 0
> td=. PATHSEP_j_ ,~ jpath '~temp'
> )
>
> Which will write the log file to your J temporary directory on all
> platforms.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm