Transferring code between APL suppliers in APL2000
This page shows how to transfer code in workspaces or component files and read them back. This can be used to take backups or go back to previous versions of the interpreter.
It can also be used to import/export code from/to other interpreters.
There are at least 2 ways to export/import code in APL2000:
1. Using variable record length EXTENDED files
This format produces a representation of just about everything in the workspace. Translation of code from other APLs is limited but possible. For example, code imported from another APL might use Quad functions unavailable in APL2000. It can often be translated to use the equivalent APL2000 functions.
2. Using fixed record length ATF files
This format produces a representation of each function and variable in the workspace. It cannot perform translation of code when importing code from other APLs.
This format was introduced to deal with the 5 major APLs of the time (1990s): Sharp APL, APL*PLUS, APLX (discontinued), APL2 and Dyalog APL. It lays the representation of each variable or function in the ws, system variables included, onto variable length records.
You need a special workspace to read in and write out the code. The workspace should be available here: XFRPC11.w3.
This format was introduced by IBM many years ago and has been supported by many other vendors, APL2000 included. It basically lays the representation of each object in the ws, system variables included, onto a number of 80 chars wide records in a file with extension ATF.
Note that the ATF file should be regarded as a binary file, not text. For example, the line-ending convention must be <CR><LF> (something which is apt to get changed when e-mailing ATF files between Windows and Macintosh systems, unless care is taken)
The user commands ]IN and ]OUT are used to import and export code in ATF format. No other software needs to be used.
Let's assume we have a workspace containing the following:
title←'Big Application' ⎕fx ⊃'r←avg v' 'r←(sum v)÷⍴,v' avg ⎕fx ⊃'z←sum x' 'z←+/x' sum mat←.01×?2 5⍴10000 record←'Joe Blough' 19550209 (.22 .45 1.2 1.56) ∇l←list  l←l,⎕nc l←⎕nl 2 3 4 5  ∇ list avg 3 list 3 mat 2 record 2 sum 3 title 2 )WSID myws
Using the EXTENDED format
To write the workspace to file, including ⎕IO, ⎕CT, ⎕PW and ⎕LX (assume the workspace used to do the transfer is in \apl\xfrpc) do
)COPY \apl\xfrpc ∆xfrto '\tmp\mycode' * XFR version 3.11 10 objects transferred
To write specific items put them before the file name (here 'title' and 'mat'):
'title mat' ∆xfrto '\tmp\my2objs' * XFR version 3.11 2 objects transferred
To read the workspace back:
)LOAD \apl\xfrpc saved... ∆xfrfrom '\tmp\mycode.xsw /replace' ⍝ note the XSW extension, necessary when importing APL2000 code * XFR version 3.11 APX3.11 20100217 34458; WS=myws 10 objects defined list avg 3 list 3 mat 2 record 2 sum 3 title 2
To read only some groups
)load \apl\xfrpc SAVED ... ∆xfrfrom '\tmp\mycode.xpw /obj=c' ⍝ bring in only character variables (c) * XFR version 3.11 APX3.09 20100217 40418; WS=myws * "⎕lx:C" not redefined 3 objects defined ⎕nl 2 mat record title
⎕LX was not redefined because we did not add the /replace switch.
Component files can be transferred too.
'\tmp\ft1' ⎕fcreate 10 title ⎕fappend 10 1 record ⎕fappend 10 2 mat ⎕fappend 10 3 (1 3⍴0 ¯1) ⎕fstac 10 ⎕fsize 10 1 4 3584 0 0 ∆xfrto '\tmp\exf1 /file=10' * XFR version 3.11 3 cpts transferred with Access Matrix ∆xfrfrom '\tmp\exf1.xpf /file=\tmp\new1' * XFR version 3.11 4 objects defined '\tmp\new1' ⎕fstie 11 ⎕fsize 11 1 4 3584 0 0 ⎕fread 11 1 Big Application mat≡⎕fread 11 3 1 ⎕frdac 11 0 ¯1 0
For details see http://www.milinta.com/xfrpc.htm.
Using the ATF format
To write the workspace to file do the following
You cannot write specific items, only the entire workspace.
To read the workspace back:
]IN \tmp\mycode ⍴⎕nl 2 3 6 6