ŒFWRITE Append, replace or insert component


The ŒFWRITE function allows you to write a component anywhere in the file, either inserting, replacing or appending. The syntax is:

      DATA ŒFWRITE TIENO {COMPONENT} {PASS}

DATA is any APL array, or an overlay created using ŒOV. TIENO is the tie number you used to tie or create the file (or the tie number returned by APLX if you tied or created it using 0 instead of your own tie number). If you tied the file using a pass number, you must provide the same pass number, as the PASS parameter.

COMPONENT is the component number at which the data should be written. This can be one of the following:

The following complete sequence illustrates the various possibilities:

Create a new file, and append four components to it in different ways:

      'EXAMPLE' ŒFCREATE 
      'First component' ŒFWRITE 2 1
      'Second component' ŒFWRITE 2
      'Third component' ŒFWRITE 2 0
      'Fourth component' ŒFWRITE 2 3.5

Read back the four components:

      ŒDISPLAY ŒFREAD ¨2,¨¼4
Ú…ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÌ
Û Ú…ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÌ Ú…ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÌ Ú…ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÌ Ú…ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÌ Û
Û ÛFirst componentÛ ÛSecond componentÛ ÛThird componentÛ ÛFourth componentÛ Û
Û ÀÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÙ ÀÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÙ ÀÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÙ ÀÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÙ Û
À¹ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÙ

Drop the first component, components are now number 2 to 4:

      ŒFDROP 2 1
      ŒFSIZE 2
2 5 3584 0 256
      ŒFREAD 2 1
COMPONENT NOT IN FILE
      ŒFREAD 2 1
      ^

Replace component 3 with a new value:

      'Third rewritten' ŒFWRITE 2 3
      ŒFREAD 2 3
Third rewritten

Insert a new component before the existing first component, renumbering existing components to allow for it:

      'Inserted first' ŒFWRITE 2 1.5
      ŒFREAD 2 2
Inserted first

Insert a new component between the existing third and fourth components (it will become the new component 4):

      'Interloper' ŒFWRITE 2 3.5

See what we've ended up with:

      ŒFSIZE 2
2 7 4096 0 0

(First component number is 2, next available is 7)

      ŒFREAD 2 2
Inserted first
      ŒFREAD 2 3
Second component
      ŒFREAD 2 4
Interloper
      ŒFREAD 2 5
Third rewritten
      ŒFREAD 2 6
Fourth component

We're done. Untie the file:

      ŒFUNTIE 2

Topic: APLX Help : Help on APL language : System Functions & Variables : ŒFWRITE Append, replace or insert component
[ Previous | Next | Contents | Index ]