I personally prefer native 1!:2 instead of covering verb like fwrite. More
specifically 1!:2 expect an at most rank-1 string as left argument and a boxed
file name as right argument. so
(q,LF) 1!:2 <'c:\q1.txt'
will raise error if q is not a rank-1 string. That also means you have to
convert the numeric array q to a rank-1 character string yourself.
eg.
(<'/tmp/q1.txt') 1!:2~ LF,~ ,TAB,~("0) ": ,.1 2 3
there should be verb for clipboard format in J base library.
PackRat wrote:
Bjorn Helgason wrote:
(q,LF) 1!:2 <'c:\q1.txt'
and Ric Sherlock wrote:
The verb fwrites (write a file as a string) takes the left argument
and does a toHOST on it (undoing your toJ) before writing to file.
If you want to write the actual content of the left argument without
it being changed you should use the fwrite verb instead.
(toJ,q) fwrite...
Thanks, Bjorn and Ric, but... for whatever reason, using "fwrite"
doesn't seem to work, always giving errors--that's why I didn't include
it in my original examples. (I actually had tried all of these
"fwrite" variations before writing my original message, but because
none of them worked, I limited myself in that info request to those
forms that *did* work.) Here are results from your suggestions:
Bjorn:
(q,LF) 1!:2 <'c:\q1.txt' NB. your original suggestion
|domain error
| (q ,LF)1!:2<'c:\q1.txt'
(LF,q) 1!:2 <'c:\q1.txt' NB. xchg x args
|domain error
| (LF ,q)1!:2<'c:\q1.txt'
(q,LF) 1!:2 jpath ('~user\data\q1.txt') NB. variant file spec
|domain error
| (q ,LF)1!:2 jpath('~user\data\q1.txt')
(q,LF) fwrite <'c:\q1.txt' NB. variant verb form
|domain error
| (q ,LF)fwrite<'c:\q1.txt'
(LF,q) fwrite <'c:\q1.txt' NB. xchg x args
|domain error
| (LF ,q)fwrite<'c:\q1.txt'
(q,LF) fwrite jpath ('~user\data\q1.txt') NB. variant verb form
|domain error
| (q ,LF)fwrite jpath('~user\data\q1.txt')
(LF,q) fwrite jpath ('~user\data\q1.txt') NB. xchg x args
|domain error
| (LF ,q)fwrite jpath('~user\data\q1.txt')
Ric:
(toJ,q) fwrite <'c:\q1.txt' NB. your original suggestion
|domain error: toJ
| ( toJ,q)fwrite<'c:\q1.txt'
(q,toJ) fwrite <'c:\q1.txt' NB. xchg x args
|value error: fwrite
| (q,toJ) fwrite<'c:\q1.txt'
(toJ,q) fwrite jpath ('~user\data\q1.txt') NB. variant file spec
|domain error: toJ
| ( toJ,q)fwrite jpath('~user\data\q1.txt')
(q,toJ) fwrite jpath ('~user\data\q1.txt') NB. xchg x args
|value error: fwrite
| (q,toJ) fwrite jpath('~user\data\q1.txt')
(toJ,q) 1!:2 <'c:\q1.txt' NB. variant verb form
|domain error: toJ
| ( toJ,q)1!:2<'c:\q1.txt'
(toJ,q) 1!:2 jpath ('~user\data\q1.txt') NB. variant verb form
|domain error: toJ
| ( toJ,q)1!:2 jpath('~user\data\q1.txt')
As you can see, I tried exchanging the "x" arguments, exchanging the
verb form between "fwrite" and "1!:2", and exchanging the "jpath"
syntax and regular syntax for the "y" arguments--but all to no avail.
I just could not get "fwrite" to work correctly. Any other
suggestions? Thanks!
Harvey
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm