)NY?Y@@vY@DZAYBHYCYDYE program and USED by the program. This extention usage can be overridden by the /apl= switch as in xfrfrom 'myxfr.file /apl=DYW' Possible /apl= values are SAM (SHARP APL mainframe), SAX (SHARP APL Unix), DYW (Dyalog for Windows), APX (AplX) and A2K (APL2000). dumps all objects to file without translation. Those include all variable types (character, numeric, mixed, enclosed/boxed, packages and, within those, undefined) and functions/operators. Packages are transformed into namespaces under Dyalog, overlay under APLX and into nested structures for APL+Win. Special fns are included to handle these in the transfer workspace. They all start with the capital letter 'P'. The code will also use those names instead of pnames where appropriate. reads a file, maps the av if from a different APL and applies code translation if /trans=1 (or 2) is supplied with the argument. All functions start with a delta. For Dyalog APL they all reside in the 'xfr' namespace. Code is written in "common" APL. The internal names (locals) are unusual to minimize name conflicts. There is a different workspace for each APL version. Switches can be shortened to a short non-ambiguous form. The actual switches are (*=xfrfrom only, CAPITALS=minimum length): /Apl*, /File=, /List*, /Noam, /Objs=*, /RAnge=, /REplace*, /Trans=* /Lock= EXAMPLES xfrto 'myexportfile /file=myaplfile /range=100 999 ' xfrfrom 'yourfile /objs=fns /trans' apply translation xfrfrom 'x.xuw /list' only list objects xfrfrom 'fx.xuw /f/n' file, no access matrix Function will look like this when translated SAX Dyalog APL 2000 F; trap;ec F; TRAP;ec_ F; ELX;ec_ [1] 2 ws 2 [1] w_(SI) [1] w_SI [2] a replace t [2] a FREPLACE t [2] a FREPLACE t CODE TRANSLATION To change the behaviour of the translation edit variable 'equivalence' under the APL section desired. Each section starts with a colon followed by the APL vendor code (SAX, DYW or A2K) as in ':SAX'. Each non empty line after is made out of 2 strings separated by '%'. The first one is the string to replace, the second its replacement. Strings surrounded by " are the av value instead. names are case independent and treated syntactically but others are not. RESTRICTIONS The usual ws full problems can be encountered. If possible increase ws size to solve this problem. Many characters have no equivalent in other APLs. They are still mapped to a character when read from the file. If a function cannot be fixed in the workspace (possibly because of an invalid header) a variable with same name preceded by a '' contains the offending code. For example, if function cannot be fixed then variable 'F' will contain the (translated) code. HISTORY This workspace started life as an APL/PC workspace in the early 80's. It has gone through extensive changes over the years. The original workspaces did not have switches but they are still available with the format unmodified. In 2003 I included APLX and adopted CR as the standard for fn representation. DanB 2001 (c) 0D r_2 1id_(1 3(v_~' ') 2 n_) 0,names1r penclose names,$ parse argumentW$Td|+dYYYYTYHYYЦYTYY `CY Y Y ,!?~ _}{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789. ':  |`#@"%&   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~    %'_abcdefghijklmnopqrstuvwxyz.0123456789$ABCDEFGHIJKLMNOPQRSTUVWXYZ{}[/\<=>^-+?~*( ;,!"#&@`|:)]  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ | ! )<=>]^,+./0123456789([;:\_{'*?~ -ABCDEFGHIJKLMNOPQRSTUVWXYZ$}"#%&@`abcdefghijklmnopqrstuvwxyz<A ( XfrObjs $\brec write handle$ W770  :SAPL replace%FREPLACE appendr%FAPPEND signal%SIGNAL resize%FRESIZE create%FCREATE rename%FRENAME append%FAPPENDnor pnames%Pnames ;trap%;ELX avail%FAVAIL names%FNAMES erase%FERASE untie%FUNTIE ppdef%Ppdef plock%Plock 6 fd%ERASE 3 fd%DEF SINL%SINL trap%ELX rdfi%RDFI rdci%FRDCI size%FSIZE nums%FNUMS rdac%FRDAC stac%FSTAC hold%FHOLD read%FREAD stie%FSTIE drop%FDROP copy%FDUP pdef%Pdef psel%Psel pins%Pins pack%Pack pval%Pval EDIT%EDIT lib%FLIB tie%FTIE ><<% pnc%Pnc pex%Pex out%OUT fmt%FMT vi%VI fi%FI ws%WS fd%FD er%er_ ><% ec%ec_ sc%sc_ ps%ps_ sp%sp_ ht%ht_ ul%1 ws%WS fd%FD fc%fc_ >% >% <% <% enc % boxed <.%<. .%>. >/%>/ >%> >\%>\ >%> (<%( <% \<%\ <% <% <% <% <% <% <% <% <% ,<%, <% /<%/ <% (>%( +>%+ >% >% <>%< >% =>%= >% >>%> >% >% ^>%^ ->%- >% >% !>%! >% >% >% >% \>%\ >% >% >% >% ~>%~ >% >% >% >% >% *>%* >% [>%[ >% >% >% >% >% #<% #>% >% >% >% >% >% ,>%, >% ?>%? />%/ >% >% Rank >% Upon %a_ %w_ % lev % dex % @% index &% merge % ibeam % Rank % Upon :DYW IOVFI%FI IOVFI%VI MONITOR%MF SIGNAL%SIGNAL SHADOW%SHADOW ;trap%;ELX FHIST%RDFI size%SIZE SINL%SINL PATH%PATH TRAP%ELX "210"% notmatch "47"%"22" SI%SI ED%EDIT ML%ML % union % intersect :APX "210"%"22" 2 CR%VR SINL%SINL "175"% index EDIT%EDIT ERS%SIGNAL "11"% Fread "12"% Fwrite SI%SI ES%ERROR "9"% Fdrop "7"% Fhold EM%DM UL%1 FC%fc_ R%TCNL L%TCLF B%TCBS /%/ % 30B no decorators, return matrix0$\b =$D  DanB 1990 (c) Create obJs defined in string. V3ZD \ X93X96X93TU D] Drop trailing spaces, remove surrounding quotes2D$ toreadfi nw Fn$DD post/pos some cannot be used for replacementD$,rnames Pnc p;cl $msgcpt @DdS (7mask(`elx'l10' cptend(rng1+''FAPPEND tie ($(nc'names')0 $4wW87:( Pchk(W97vaLue))W86,W98''4$l' ',file,' '$$XfrIDXfrID,WSID$  t,file ( (11q)p^1p)/parms4,P X95fx(2,X96)X93,X94X, s1s $  $(8l30:line1fnline1,fn(pr0 0'' , obJX95obJ shape, rank, 54L(2>p)0 r_0 3'',obJX94obJ,(0X94)/',0', W944D xlateav[Xs[2+io;]] this global used by D$W88:(0X93'ej'obJ)26 4, cptarg[8]4Ș this cpt COULD be added/replaced40W81:W96(-W96W96'.'obJ)obJ0P8 Switches can exist with or without [possibly defaulted] valueP# all bout copyright create describe equivalencefix fopen fori forme nameof parse txtrepl version xfr xfrfrom xfrto xl close create open read write FX XfrObjs Xs Pack Pchk Pins PisID Pnames Pnc Psel Pval infile L Ufx ((U)'rup t'),[-.1]U'r(C[1;],t)[(C[0;],t)t]'LP( Quotes must be used to include spaces or '/' in arguments.XPLd valid elements are supplied with the pattern: verify themLLLm DanB 1990 (c) form object with vaLue (default by itself)L4 b\fb<\(\b)^(b>fb<\b)fn''4Txf 3=return package. With a left argument an exact defn is given.TPr If the object name is a package then the defn of its uniquecP4p X94(X93X99),X97 new full name4$m for various APLs$$EXP fori N;F;M;i$(l l10,xFr[2]xFr[2]-nn(X X90X90,(X951X95,X90)X95'.' namespace always followed by dotXXt@d|+lcYԀYYhvYYTmYY4CYpYt8 do we transfer the whole workspace?8@`d|+tYYYdY@4 set trap for 'file name' error4<d|+4YXYYkYsYYoYCY\YYxYY|Y DY Y \Y Y Y uYYYkYD|YYYYpY@qYZ<0D danb 19981013 translate text0`d|+$YdYY\ZYHZPY`0 X96(X931-io-X99' ')X990d|+XsYdqYY@YP YPYY|pYdoY qY,"YY@YY<Ğ(2=1,p)0 1st a string, 2nd a matrix<@/ hdlhdl,nsize hdl must return for APL/PCes@@d|+ZYdYY!Y@4[ xFr[2]xFr[2]-bufnread source4Td|+,gYDeY$YHZYčYT4 "| 4@/ if more chars are needed we grab them here @hd|+YwYYY ZY ZYh<hB obJW98, Pnames obJ package right arg<<1 if a passnumber was given, activate it<h&d|+fna FCREATE z > (i11tno)0 (H (cpt specifies the tie number and optional passnumber.XL<@M object follows as rank (len), Shape, obJ< DX9419+,X99 X L$H fna1(i1ifna' ')/fna' ',fna remove unwanted blanksL  if it exists; otherwise, create it.TDSl7:(wreadBuf)0 there's a least 7 chars hereD<h7 X94,X99,'obJ' covers boths fns & vars< elx''r_P,[ translation requested. The translation string is in 'CodT'PL_ 54 this fn will be kept in a variable to be fixed laterL88\ r0 1l1 penclose s make matrix8P] (Sharp starts at r19) otherwise we have to introduce them.'P4La we need to know how many to read;4@lK we rely on packages or fns to emulate them?@8\^wread xFr;n;io;toread;buf;sourcere8<X]p(e^^/tpat)einvalid value for switch <',(i-1)s<P^ We must define the fn w/o constraints. We do this shadowed.2PD  W99W99,(W95,'.',obJ)forme W97[io;] Psel vaLuelD8_ (   8$ X93X88,' obJ' $PlP read an opened file, leave it open & return the next objectsP8HI danb 1998 open file, return handle84 04[ (2rrep)0 matrices are fine4 lobJ0X97obJ Hc X99'' obJ now contains the representation of 1 obJ H$c X94X94,X95obJ $ lb obJFX obJ 0 d (2=obJ)33 8d 98[1+io]199990,198XfrObjs8XM COMPRESSOR: any double quote OR last quote NOT in \ or double delim.X$h(X87X91='ME')/39 $0c line0(-tt' '=line0)line000jl120:s(-tt' '=s)sfn[1;]no0He 8 }}/H h X88'def '1 4el60:line0s\(s~line0'{}')/line0X4LHe X90(2-(X90)nc'oNS')X90'0oNS' where to put theseL8Z all(((198),199)98),[io]all84` danb 2003 change representationX4L,f in 'stream' mode each object's length is also suppliedksLH` +Win won't accept a vector representation w/o line #sHPXZ fn(-bbb^0b''12fn)fn does not tolerate extra charsPLZ define fn - DO NOT OVERWRITE any existing fn if packageLTG 'name' contains the fn packaged which is returned now (code=3)t.TtXd|+YsYY4wYxYTYY|YpYt8X /lock= file lock to use8{Gz@Ld|+ԖYYY~YpYYPYYzY|YlY<t (''6rep)0 decorators? yes, exit now<$i(X91='?P')/51,45 $$\ (obJX95'')34$  X94X96X94 et H8i danb 83/9/27 will EXP for i:=N[1](or io) to N[2]=HHa X98X93X99 split object off string, recoup space1'H Lb (2=X94)33 , b (1 3ai[0],1,i)FSTAC z ,$a X951-io-obJ' ' $0} all(all[;2].'')all00Pj DanB 1998 all names not used0Dkifx((t)'rd s'),[0.1] t'r(~\s'' [='')/s' DD pat1'>unknown or ambiguous switch: <',1td s aD,k (nc 'readBuf')l5 89,$m wyz{|$ k (tfn)l20 k ,n (0nnread source)l20 , l bc=fnc,fne value required for switch <',q<  W95W96'?' i obJfix obJ 4nn,':',1str $xW77:(1W97)W89X$4w fnbout fn remove {} brackets44`l12:bc=fn merge ;locals linesg4$ W77,W971 0W97$`i (X91'N')27 Numbers. We need to account for capitalization for all but DYW`0@cmat: (/'{'line0fn[0;])0.0@[ For non var only codes 0 & 3 are meaningful.@4 error (1t)/'unbalanced quotes'4$0z e''2(q)pat $X /trans=(012) is level of code translation to occur (def 0)XHtzNaMbUf infile tIE,replace,range,noam,list,NaMH(obJ Pack 0 0X97obJe(d{ obJX98 ./$@{ pat[pat'']'='$ l10:lW[i;1] H@ special version for XFR: the switches' header is ''HT Shorter names are accepted but '=' MUST be used to supply values.T0 each name separated by a dot.0${ ('='s)l3,chkX${X893=cOde $| error(~'='s)/m$D If /trans=2 we will change av[refs] by AV[refs]D<} X911obJ <@|CodT((1rEf)CodT),NaM,(1rEf)CodT<<}rEfopen ArG grab proper fns, open file<LĀrEf[1+io]rEf[1+io]-q keep track of what's to be readL,<~ W97W98'rTvAl;x;',W96,$}chk:t(is'=')s $$X} (^/m' '=t)/comp$X X9219 $|} t((^\m)^\m)/t $$h~l3:(/s' '=t)l4 $<qq,replace,0=nc 2NaM unknown?X<( (/'{'line0tfn)0(8Tfnfix fn;io;b;b1;d;dlm;mat;t;fb;c,q8,~i''N2io,N-io<1=,N ,$~l4:i/s''''=t X$,t fn(dlmfn),(dlm+b)fn ,$~ \qparms'''' $$parms[p/p]1D $X Some characters could not be represented in other APLs. All we knowXXhX88'fx' ,,l30:fnCodT txtrepl fn,$nnameof str;b;io$  pospos>NClA H b(2lbr)1 0 D  Except for SAM all should be able to handle thisD X93-X970 X99X94 $ (0vaLue)W82 $$L| DanB 1990 (c) return a string representing objects namedL 0 t\arg='''' P swits/arg '  s(i-1)pat d X99X95 $P W83,W99,vaLueD$0ȃ W99pp16 16 fits all APLs0XTS txtrepl T;io;b;i;l;lbr;l0;l1;mask;n;p;pos;s;ss;t;up;A;C;NC;U;W)XX(|fnline0,(0 :G=LMN;</$?%P( tIEfile fopen 306(Pp DanB 19980824 verify Package is genuine - not valid for SAPLP4 DanB 1997 replace by proper fnd4   n'**NOTR**' 8drange(0 1+2(range),/0),NaM8@ change class 0 into 1, find all vars values@H locklock 0 by default - no check if numericH,lArgArg,(1XfrID),'f',8L Set av mapping; 'a' is for {ASCII}8Dĩ n_ may be several names. )EVLEVEL 2 or ml 2 onlyD@ l'rnL;m',0ex'nL' reuse name nL@4 are we supplying a tie number?4$ c_c_1c_' '=n_ $( screen objects here($| c_' '=n_c_/n_ed$D(r_b_/b_c_3 4 9)20 fns, ops & namespacesDD|  DanB 19971124 (c) transfer file or items to hostD rPnames x;io ,8t'' no tie no to close,4̪ArG'*** illegal component range'44h The source APL has been supplied 4LD(cpt<1fsz)no cannot replace even if /replace wanted L8 rEfrEf=CodT(NaM1NaMrEf=bUf)/bUf8,(trans=2)/oNS,'AVbUf' ,\bUf'/= /q/apl=/file[=]/replace/range=/noam/objs=/trans[=]0 1 2/list/debug'\8 CodTCodT,(trans=2)/'%av[%AV['8Lmsg'* Access Matrix not replaced (problem encountered)'edLT̮ if /list has been supplied only those that would be (re)definedT< (1file)17 no filename for the file?<@dXfrID'A2K',(version,1002 3ts),'; WS='et@PP '((FREAD t,i,lock) forme nL,i) write r' fori lPD0 Access Matrix: trap access problems if possibleD< file FSTIElock,t1+/FNUMS,306<Dqq,' with ',(61l)'EMPTY Access Matrix's]DXrob xfrto Arg;oNS;file;l;nL;q;range;t;XfrID;lockXT if /replace has NOT been supplied then a message will appearYT8aplArG'' gather messages herele8(5ArGxfrfrom ArG;bUf;inWs;oNS;rEf;tIE;xlate;readBuf;noam;apl;ascii;cR;debug;file;list;objs;q;range;replace;trans;CodT;NaM0{ ,q,'',(i/'1(\s)/'),'t' #00 insert room for new stringpt00lqq,' objects transfered'30(L((1bUf)objs)92)($(989798)3$0P 845-$96B%7)W0 t l-io-l o (l20:(nc'CodT')endn(0 (^/range' 0123456789,')340$ mask(NCT,T)0$@,trans83 set translation APL reference4@0з(qno value allowed for switch <',q88 System vars need no namespace header88 account for mixed types and prototype8@` create will return a name or a value to file@$H dlm1patn,'/' $<$ Is there a file extention? then warn user<Dfile(^\tIE'.')/tIE(-tIEtIE~ArG':/\')ArG2 D<l(rEf-io-NaM1)81 ASCII translation?<@, 'S' is delimited list of search/replace items@D4objs,(/NaMobjs)NaM use lower/uppercases!DPdNaM':','{}SAPLDYWA2KAPX'[(NaM/0 2 2 6 9 12)+NaM/2 4 4 3 3 3]P))t_ 0 Xd|+YLYXYYYnYY,YY(YXY0 Y0YYY Z Y Y qY `YYnYLYYZYYcYTYpZ,mYY<YYYxYLYZY$YmYcYdYxFYY Y Z!4Y"tY#4Y$Y%`Y <Ğ danb 1999 select a value from a package<Hl2 80l,80'r0elx''0''mfrdac t,lock'7 H  nLrange l76,bUf2bUfn L (t(/l' ',FNAMES,' ')FNUMS)27 already tied?L0, (t''ssS[W[i;0]+l])l20 0  (0file)43  ""] ,`k all(990 3all)all,8|l X940X96(X951-io-obJ' ')obJ ai8l10:elx'' k t1+d+b1b1 <܋ put in place (doing b/b might wsfull)e<Hppts> DELIMITERS: spaces NOT in quotes OR 1st quoteH@l W97W97W99' Pdef vaLuerT cr''',W96,''''@<9999,forme(1+971-io-98' ')98 <( 'no more chars!' 9( HW78:W96'P' ] 4 (';'=fn[t])l20 1st char ';'??44, (b1=b)l20 more than 1 line? 4  W80:W96'F' as  ('M'W96)W84  (W98obJ)W88 0m obJ[X88/obJ]'EJ'[X88/X93] 0X$q Check switches: set all allowable switches to 0 (assume not present) Xzts00W90:oxn^ io1 P X890 X9300X 23pio0 P 0Yclose f 0 080x siswit @ end$(nc'xlate')0$ i1sp 0'L cn can be a list (cm or cv) of names or a class (ex: 2)L0 (forme lnL) write r08 * objects are defined in this section8(W82:W961W96/'NCM'st(tP0 arg is tie#, replace, range(2), original file size(2), NO access matrix, list only, cpt no (0=AM)t,\l50:(n>ii+tpos2)/l10 ,@ No av mapping or translation for same APLCZ@4ArGArG,(,1NaM),(11qr(( (toreadtoread-n)0s( s[i]' ' Y(99xfr 98;97;oNSf (L /q quiet mode - mo messages displayedLD FUNTIE (t)t untie only if it wasn't tiedD0P(^/file'0123456789')25 W01$r_2 1( id_), r_e$pAHHVALUE ERROR Pdef[2] error (~Pchk n_)/'domain error' ^KYg 2YGYHY2Y[x2YLYGY2YH1YGY3YGYh<. X |    "  !#%,-1h(aplapl+NaM[io]K(, 'NaM' reset by ,H 0$L nL(l+1)nL $$( NaM2FSIZE tIE0$$l10:(cpt>rng)l20$H` the result is the actual tie number of the file.H|d|+YpY YԓYlY̫Y8YܚY4YY|42 tno(z+((z+j)jz,j)0),1tnoZ448NaM1(NaM+2561bUf)av,xlate4D /apl=(SAMSAXDYWA2K) source APL; av[positions]D@ /noam NO access matrix reset@4 (/rEf)83 is this a known APL?4pcom''  40e W89 io0 8 W93W98'' endd0,rlxF00, W920L 0(g<m 04 46 4io0 L io0T cOde0d end"nnbstr 8 bstr' 'rPisID id4end:mat0 amsend4 id1o_ 8T iq^1q t T  l5:io1 txd|+xY8bYYpY$YYbY}YНYt0B readBufreadBuf,xl buf0< D(X99X98)0 split length from stringSI< dd|+YZL>ZZ?Z`;Z XZ@Z@Z@Z!AZ0AZ@Z`@ZvZ8>Zd>Z,@Z|x>Z>ZD@ZY>Z?Z@ZY?ZZAZ\YHPAZ>ZAZYp+ZZZZZl/Z8ZZZ4-ZgYZ/Z .ZZE`Z.Zt.Z.ZtZZ#YZYX-ZZ`0ZHZ,Z`ZZ(/ZuT/Zh,Z/ZZ4.Z%H.ZxZZW-ZPZ/Z0ZCY,Z0Z ,Z-Z$-Z .Z.Z .Z\.ZZZ:.Z;x0Z,Z<ZZZ.Z4Z\Z0YHZ= Z2tZCZZJZ Z>Z@ZtZzY Z#8fY8"Y![YZY"Y jY?|ljl1spdpat\.fnapatn<^W780P@R̮T0S  d0aܞl2switR(tmpdnameoflvctestx0nsrlist"file`%nL Zobxsl01vnep!dis(cuthtestCodTXtnoLg<createHtxtrepll110 atbrzlXssxtl700&l808 showXCm l40msgxnosamW80upTX87j<am̮v/P@objscompl150<fopenkh0Zmask_debugWnXMIzz`parms,transvendArgpick<Pdescribextr_n_N_zPdefqsp xFrl74nl5 bufXfrObjsallrecthdl@writeobjtiecptlim,amrGXhandle,Hl20source97pl10toreadnOaoNStIeP5Lf7lImtrEf99s(SrHPuPmVdEfSr<98lUrRePdHiDopenfilel30PeNdxAlL`asnLread$xl|closed95(92<1<93@iTems91296Po94xPuP0readBuf90XfrIDpCfiLewiNwSD sScR489 75\8883p8785H8481 767977HW97W9878vAl74W87W93W95obJret W91482dW92880W90p86$W96obJ\W99xfre0W83lNmW86i9W84W85DW82F5XW81XW88infileDW89EXPM8xW94osresfn4dlmHb\tfXl05createell25sD Xmatcom(l60 xfrfileforiPselNaMsCRLFnd_F_7formePnames line0,id_bUfdFnX96X95X94X93X92X91 X90 X894X88Hp3cnvR_ Pncfix0'changea cl[HmFfiLe4xatdefinenpsinWsE nl2op DFxO_Dv_, l120,fns@id'To_|Pexl15vaLue8all2xlatesysIDBlcr 98X99`namesX versionxfr PinsX Plock PisIDdescribesr<XsDl160alline1q l130e X99 X98lX97Create@c_ b_(okPdefPPval(Pchkcopyrightx@PackPpdefcOden L x arDM f1] ' vTEsizap@6maCZFH CZ|CZdCZHCZ,CZCZBZBZBZBZBZBZH  P equivalence dR7Q*S3W-I(K&MP G) ?"LONVVE @_/0 1HOAU+5z86DF ,'94TB