[Top][All Lists]

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

Re: [Bug-apl] working with )HOST

From: Juergen Sauermann
Subject: Re: [Bug-apl] working with )HOST
Date: Sun, 06 Mar 2016 12:04:35 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


the cleanest way of reading as file is ⎕FIO[6] in general or
⎕FIO[8] to read line-by-line. ⍎')HOST' is actually the dirtiest way
of reading a file.

Boxing operates on the final result of a statement, not on (which is a variable).

FILE is assigned to Variable so it becomes a "committed value" which is not printed.
In other words, ]boxing has nothing to print.

/// Jürgen

On 03/06/2016 01:39 AM, Louis de Forcrand wrote:
Correction; to feed it a var, simply catenate the file name like:
FILE←¯1↓‘)HOST cat ‘ , filename←’relative_or_absolute/path/to/blablabla.txt’
Keep in mind your current dir is the one you started GNU APL from, so it can
change. Using ~/… or an absolute path is probably safer.


On 06 Mar 2016, at 01:35, Louis de Forcrand <address@hidden> wrote:

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]