ComponentFile Class

:Class ComponentFile
    :Field Private Instance tie
    
     Open filename
      :Implements Constructor
      :Access Public Instance
      :Trap 0
          tiefilename ⎕FTIE 0
      :Else
          tiefilename ⎕FCREATE 0
      :EndTrap
      ⎕DF filename,'(Component File)'
    
    
     Close
      :Access Public Instance
      ⎕FUNTIE tie
    
    
     rAppend data
      :Access Public Instance
      rdata ⎕FAPPEND tie
    
    
     Replace(comp data)
      :Access Public Instance
      data ⎕FREPLACE tie,comp
    
    
    :Property Count
    :Access Public Instance
         rget
          r¯1+2⎕FSIZE tie
        
    :EndProperty ⍝ Count
        
:Property Access
    :Access Public Instance
         rget arg
          r⎕FRDAC tie
        
         set am;mat;OK
          matam.NewValue
          :Trap 0
              OK(2=⍴⍴mat)^(3=2⊃⍴mat)^^/,mat=⌊mat
          :Else
              OK0
          :EndTrap
          'bad arg'⎕SIGNAL(~OK)/11
          mat ⎕FSTAC tie
        
    :EndProperty ⍝ Access
    
    :Property Files
    :Access Public Shared
         rget
          r⎕FLIB''
        
    :EndProperty
    
    :Property Numbered Default Component
    :Access Public Instance
         rshape args
          r¯1+2⎕FSIZE tie
        
         rget arg
          r⎕FREAD tie,arg.Indexers
        
         set arg
          (arg.NewValue)⎕FREPLACE tie,arg.Indexers
        
    :EndProperty
    
     Delete file;tie
      :Access Public Shared
      tiefile ⎕FTIE 0
      file ⎕FERASE tie
    
:EndClass ⍝ Class ComponentFile