[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] working with )HOST

From: Louis de Forcrand
Subject: Re: [Bug-apl] working with )HOST
Date: Sun, 6 Mar 2016 01:35:02 +0100

I am not very good with files and such, but from what I understand:

      ⎕←T←⊃¯1↓⍎')HOST date'
Sun Mar  6 01:11:48 CET 2016

2 28

So you can save the result of )HOST in a variable if you use
⍎. To feed it a var, I would try something like:

      ]BOXING 2
      ⎕←FILE←⍎')HOST cat test.txt'
 hello, world  This file was written in my $HOME directory.  0  
.→-----------. .⊖. .→-------------------------------------------. .⊖. .→-.
|hello, world| | | |This file was written in my $HOME directory.| | | |0 |
'------------' '-' '--------------------------------------------' '-' '--'
Several things to note here. First of all, linefeeds / carriage returns / whatever
you want to call them in the file I read seemed to mark nested array ends, and
it seems that those LFs were lost. I don’t know how GNU APL handles LF chars,
so I would recommend you either keep the array boxed or disclose it like I did
in the first example (∊ enlisting it simply catenated all the lines together, as
the LFs were represented by ⊂⍬, boxed empty vectors).

Second, if you’re reading this Jürgen, note that even though ]BOXING was set
to 2, the result of ⎕←FILE is not boxed.

IMHO this is potentially the cleanest way to read a file. I have no idea how to tie
files and stuff like that.

Best of luck,

On 05 Mar 2016, at 03:54, address@hidden wrote:

Hi Bug-apl,

Currently, at a point in my code I do something like this:

⍝assume the variable 'yadda' exists and is correctly formed, as well as the read_file function
success←yadda ⎕fio[7] tie← 'wr'⎕FIO[3] "yadda.file"
)host ./shellscript.sh yadda.file yadda.file.new
yadda_new← read_file "yadda.file.new"
⍝end of code

My question is: is there either 1. a way to feed )host a variable (I don't think that is possible) or 2. a better way to implement this task in its entirety. I find it a small nuisance that I have to write and then read a file in my code to access non-APL stuff for processing.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]