Hi Xtian,
thanks, included in SVN 838.
/// Jürgen
On 01/06/2017 03:16 AM, Christian
Robert wrote:
I see your point, well, I hacked something, some kind
of a wrapper around ⎕FIO
who give me *very near* of what I wanted, eg: not to have to copy
tenth's of functions
to be able to call the FIO by name.
∇FIO[⎕]∇
∇
[0] z←L FIO[X] R;a
[1] →(2≠⎕nc 'X')/Noaxis
[2] →(0=↑0⍴X)/Number
[3] a← ('errno' 1) ('strerror' 2) ('fopen' 3) ('fclose' 4)
('ferrno' 5) ('fread' 6) ('fwrite' 7) ('fgets' 8) ('fgetc' 9)
('feof' 10)
[4] a←a,('ferror' 11) ('ftell' 12) ('fseek_set' 13) ('fseek_cur'
14) ('fseek_end' 15) ('fflush' 16) ('fsync' 17) ('fstat' 18)
('unlink' 19) ('mkdir' 20)
[5] a←a,('rmdir' 21) ('printf' 22) ('fwrite' 23) ('popen' 24)
('pclose' 25) ('readfile' 26) ('rename' 27) ('dir' 28) ('ls' 29)
('getcwd' 30)
[6] a←a,('access' 31) ('socket' 32) ('bind' 33) ('listen' 34)
('accept' 35) ('connect' 36) ('recv' 37) ('send' 38) ('usend' 39)
('select' 40)
[7] a←a,('read' 41) ('write' 42) ('uwrite' 43) ('getsockname'
44) ('getpeername' 45) ('getsockopt' 46) ('setsockopt' 47)
('fscanf' 48)
[8] a←a,('open' 3) ('close' 4) ⍝ And some handy aliases
[9] →(0=↑⍴X←,⊃((⊂X) ≡¨↑¨a)/a)/Nomatch
[10] X←¯1↑X
[11] Number: →(2≠⎕nc 'L')/Monadic
[12] Diadic: z← L ⎕FIO[X] R ⋄ →0
[13] Monadic: z← ⎕FIO[X] R ⋄ →0
[14] Nomatch: ∊("Unknown function:") (X) ⋄ →0
[15] Noaxis:→(2≠⎕nc 'L')/NoaxisMonadic
[16] NoaxisDiadic: z←L ⎕FIO R ⋄ →0
[17] NoaxisMonadic: z← ⎕FIO R ⋄ →0
∇
Only one function is needed to be copied into a workspace (FIO),
it understand the axis by number as usual but it also
understand the axis by name.
Juergen, feel free to include it into the FILE_IO workspace if you
think it may be useful to others (and rename it if you
want, like FIO∆ or something else).
not yet 100% tested but you get the idea. I had to use "usend" and
"uwrite" for the UTF-8 aware send/write.
and thanks again for your thoughtful explanation,
Xtian.
|