#! /usr/lib/veetest/veetest -r
(revision "B.00.00")
(date "Mon 26/Oct/1992")
(component 0 "ROOTCONTEXT"
 (interface
 )
 (implementation
  (locked no)
  (trigMode deg)
  (nextID 1)
  (component 0 "CONTEXT"
   (name "File Editor")
   (description 36 4
    The FILE EDITOR device implements a simple text
    editor that operates on the supplied file name
    text string.  The named file is opened, if it
    exists, and read into the "edit buffer".  The user
    can modify the buffer as desired, then choose the
    Write or Cancel buttons.  Although limited, this
    device allows you to edit a file using Vee objects
    rather than using Execute Program to spawn an unix
    file editor.
    
    DESCRIPTION:
    The Detail view of the File Editor will let you
    examine the Show Description selections for most
    of the devices.
      
    CAVEATS:  
    Because the Text Constant device was not designed
    for use as a Text Edit window, several edit
    operations are somewhat different.  For example,
    the TAB key is used to move to the next "line",
    and cannot be inserted into the text file.  When
    positioned at the last line, a TAB will create ONE
    new line for input.  If several "blank" lines are
    needed at the end, temporarily create a dummy line
    with some text and use the Insert Line key to
    create the black lines about it, then delete or
    edit the dummy line.
        
    Because X-windows/ Motif style guides mandate that
    the "Return" key be used to terminate editing on a
    field, you must learn not to use the Return KEY;
    the TAB key performs the required line termination.
        
    You can move around the edit window with the key-
    board Arrows, Prev and Next keys, etc.  You can
    also use Emacs key mappings if you know them.
   )
   (interface
    (sequence in)
    (sequence out)
    (input 1
     (type data)
     (name "File Name")
     (requires
      (datatype Text)
      (shape "Scalar")
     )
     (optional yes)
    )
   )
   (implementation
    (locked no)
    (trigMode deg)
    (nextID 20)
    (component 0 "REPEATUNTILBREAK"
     (description 5 6
      Since we don't know how many lines are in the file,
      the read operation must be repeated until EOF is
      found.  The EOF triggers the collector to send
      all accumulated lines of text, then does the
      BREAK device that terminates this iterator.  
     )
     (interface
      (sequence in)
      (sequence out)
      (output 1
       (type data)
       (name "Continuous")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 15 268)
       (extent 110 64)
       (iconImage "loop.icon")
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 1 "FORMULA"
     (name "Editing:")
     (description 2 6
      This device constructs the "Editing: <filename>"
      text string displayed while editing is allowed.
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type data)
       (name "A")
       (optional yes)
      )
      (output 1
       (type data)
       (name "Result")
       (lock name constraints)
      )
     )
     (implementation
      (component isLocked no)
      (component expr 1 "\"Editing: \"+A")
     )
     (views
      (icon
       (origin 15 388)
       (extent 110 25)
      )
      (detail
       (origin 120 380)
       (extent 151 60)
      )
      (terminals on)
      (active icon)
     )
    )
    (component 2 "JUNCTION"
     (name "JCT")
     (description 2 6
      This device passes thru either the Loading or the
      Editing string to the display device.
     )
     (interface
      (input 1
       (type data)
       (name "A")
       (lock name constraints)
      )
      (input 2
       (type data)
       (name "B")
       (lock name constraints)
      )
      (output 1
       (type data)
       (name "Data")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 167 378)
       (extent 46 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 3 "TOFILE"
     (description 22 6
      Using the file name supplied on the Control input
      pin, the ToFile device overwrites the existing
      contents of the file with the array of data sent
      from the "Editable Text Constant" device. 
      
      The transaction uses STR format to write each 
      array element as a Text STRing.  The Config
      options are set to add a "\n" (newline) after
      each array element is written.  Since the last
      element receives no "\n" separator character, the
      Array separator char is set to "\n" to provide
      the final newline.
      
      Note that the ToFile device is set to Clear File
      at Prerun, causing any data written to start at
      the beginning of the file, rather than to be
      appended to the file.  (The file isn't actually
      cleared at pre-run; it is opened for overwriting
      at prerun, but not truncated until the first
      write operation takes place.  Thus, CANCELing
      the edit session does not truncate the file.)
      
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type data)
       (name "StrArray")
       (tag "A")
       (optional yes)
      )
      (input 2
       (type control)
       (name "File Name")
       (tag "File Name")
       (requires
        (datatype Text)
        (shape "Scalar")
       )
       (lock name constraints)
       (optional yes)
      )
     )
     (implementation
      (attr iopath file write "/dev/null"
       (readTerm "\n")
       (fs "\n")
       (eol "\n")
       (multiField fullSyntax)
       (arrayFormat block)
      )
      (procedure
        WRITE TEXT StrArray STR EOL
      )
     )
     (views
      (icon
       (origin 381 308)
       (extent 78 25)
      )
      (detail
       (origin 482 551)
       (extent 327 98)
      )
      (terminals on)
      (active detail)
     )
    )
    (component 4 "TEXTDISPLAY"
     (name "File Name")
     (description 3 6
      This device has been added to the File Editor
      Panel view to allow the user to see what file is
      being loaded and edited.
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type data)
       (name "Data")
      )
     )
     (implementation
      (component clearAtPrerun 1)
      (component clearAtActivate 1)
     )
     (views
      (icon
       (origin 235 378)
       (extent 110 25)
      )
      (detail
       (origin 165 463)
       (extent 190 35)
      )
      (active icon)
     )
    )
    (component 5 "CONFIRM"
     (name "WRITE")
     (description 12 6
      This Confirm/OK device is added to the Panel view
      to allow the user to initiate a write of the
      data in the Text Constant to the named file.
      
      If the user clicks on this button, the "Editable
      Text Constant" will operate, sending it's current
      data to the ToFile divide.  
      
      Note that the Cancel button is activated in 
      parallel with the Write; whichever one is pressed
      first by the user will allow control to continue
      from that device.
     )
     (interface
      (sequence in)
      (sequence out)
      (output 1
       (type data)
       (name "Go")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 17 452)
       (extent 67 37)
      )
      (detail
       (origin 36 120)
       (extent 59 40)
      )
      (terminals on)
      (active icon)
     )
    )
    (component 6 "JUNCTION"
     (name "JCT")
     (description 3 6
      To feed either the collected text array or an 
      empty text array to the Editable Text Constant,
      the JCT device is used.
     )
     (interface
      (input 1
       (type data)
       (name "A")
       (lock name constraints)
      )
      (input 2
       (type data)
       (name "B")
       (lock name constraints)
      )
      (output 1
       (type data)
       (name "Data")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 307 448)
       (extent 46 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 7 "EXITCONTEXT"
     (description 6 6
      Executing this device terminates the File Edit
      operation without writing the modified text to
      the file.  The Editable Text Constant device is
      first cleared by sending an empty array to it.
      
      
     )
     (interface
      (sequence in)
     )
     (implementation
     )
     (views
      (icon
       (origin 158 598)
       (extent 145 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 8 "EXITCONTEXT"
     (description 4 6
      Operating this device terminates the File Edit
      session after dumping the edited text to the 
      ToFile device for writing.
      
     )
     (interface
      (sequence in)
     )
     (implementation
     )
     (views
      (icon
       (origin 8 598)
       (extent 145 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 9 "CONFIRM"
     (name "CANCEL")
     (description 12 6
      This Confirm/OK device allows the user to cancel
      an edit session without writing the possibly 
      modified data to the file.  It does this by first
      clearing the "Editable Text Constant" by sending
      an empty array to it, then using the ExitUserObj
      device to terminate all operations in the File
      Editor User Object.
      
      Note that this device operates in parallel with
      the Write button; whichever is pressed first by
      the user will allow propagation to proceed from 
      that device.
     )
     (interface
      (sequence in)
      (sequence out)
      (output 1
       (type data)
       (name "Go")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 112 452)
       (extent 76 37)
      )
      (detail
       (origin 561 170)
       (extent 68 40)
      )
      (terminals on)
      (active icon)
     )
    )
    (component 10 "DO"
     (interface
      (sequence in)
      (sequence out)
      (output 1
       (type data)
       (name "Do")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 127 508)
       (extent 46 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 11 "JUNCTION"
     (name "JCT")
     (interface
      (input 1
       (type data)
       (name "A")
       (lock name constraints)
      )
      (input 2
       (type data)
       (name "B")
       (lock name constraints)
      )
      (output 1
       (type data)
       (name "Data")
       (lock name constraints)
      )
     )
     (implementation
     )
     (views
      (icon
       (origin 197 518)
       (extent 46 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 12 "LITERALCONSTANT"
     (name "Empty")
     (description 11 6
      Although the "Editable Text Constant" can have a
      "RESET" control input added, that input only 
      clears each element of the existing array and does
      not re-size the configured array.
      
      Thus, we use this small Text Constant to load an
      empty array into the edit constant after a Cancel
      request or after the file has been written.  If
      we did not clear the Editable Text Constant, it's
      current contents would be saved along with the
      user's program needlessly.
     )
     (interface
      (sequence in)
      (sequence out)
      (output 1
       (type data)
       (name "Text")
       (lock name constraints)
      )
     )
     (implementation
      (component value Text
       (name "Empty")
       (numDims 1)
       (size 1)
       (data
        [ "" ]
       )
      )
      (component autoTrigger off)
      (component initializeAtPrerun off)
      (component initializeAtActivate off)
      (component initValue Text
       (name "CString")
       (datum "")
      )
     )
     (views
      (icon
       (origin 241 548)
       (extent 78 25)
      )
      (detail
       (origin 220 538)
       (extent 201 64)
      )
      (active icon)
     )
    )
    (component 13 "FROMFILE"
     (description 25 6
      The From File device is specially configured to
      read complete lines of text from the specified
      file, including blank lines consisting of just
      a newline.
      
      The method used is to read each line as one large
      TOKEN composed of all characters except the "\n"
      marking the end of a line.   Reading the file as
      an TEXT STRING instead of a TOKEN would cause all
      empty lines to be skipped, since STRING format
      collapses multiple white space into one separator.
      
      After reading the text (possibly nil) up to the
      newline ("\n"), we must read and discard the \n
      itself.  The CHAR read into "null" consumes the
      newline and puts it in the special variable "null"
      that discards all input.
      
      The EOF pin is added to allow detection of End of
      File which occurs on the read following the last
      successful TEXT read, if any.  The EOF pin is 
      used to cause the Collector to output the array
      of text strings it has been building as each line
      is read from the file.
      
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type control)
       (name "File Name")
       (tag "File Name")
       (requires
        (datatype Text)
        (shape "Scalar")
       )
       (lock name constraints)
       (optional yes)
      )
      (output 1
       (type data)
       (name "X")
       (lock constraints)
       (optional yes)
      )
      (output 2
       (type data)
       (name "EOF")
       (tag "EOF")
       (lock name constraints)
       (optional yes)
      )
     )
     (implementation
      (attr iopath file read "/dev/null"
       (readTerm "\n")
       (fs " ")
       (eol "\n")
       (multiField fullSyntax)
       (arrayFormat block)
      )
      (procedure
        READ TEXT x TOKEN EXCLUDE:"\n"
        READ TEXT null CHAR:1
      )
     )
     (views
      (icon
       (origin 525 138)
       (extent 110 25)
      )
      (detail
       (origin 264 277)
       (extent 393 86)
      )
      (terminals on)
      (active detail)
     )
    )
    (component 14 "FROMFILE"
     (name "Rewind File")
     (description 7 6
      Each time the editor is invoked, we need to rewind
      the file.  Since all instances of a From File with
      the same file share a single file pointer, and
      since that pointer is only cleared when the file
      is closed at post-run, attempts to re-edit a file
      would fail if the pointer were not reset to the
      start of the file.
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type control)
       (name "File Name")
       (requires
        (datatype Text)
        (shape "Scalar")
       )
       (lock name constraints)
       (optional yes)
      )
     )
     (implementation
      (attr iopath file read "/dev/null"
       (readTerm "\n")
       (fs " ")
       (eol "\n")
       (multiField fullSyntax)
       (arrayFormat block)
      )
      (procedure
        EXECUTE REWIND
      )
     )
     (views
      (icon
       (origin 285 178)
       (extent 110 25)
      )
      (detail
       (origin 116 138)
       (extent 239 65)
      )
      (terminals on)
      (active detail)
     )
    )
    (component 15 "FORMULA"
     (name "Loading:")
     (description 3 6
      This device constructs the "loading: <filename>"
      string displayed while reading the file into the
      edit buffer.
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type data)
       (name "A")
       (optional yes)
      )
      (output 1
       (type data)
       (name "Result")
       (lock name constraints)
      )
     )
     (implementation
      (component isLocked no)
      (component expr 1 "\"Loading: \"+A")
     )
     (views
      (icon
       (origin 15 228)
       (extent 110 25)
      )
      (detail
       (origin 120 220)
       (extent 151 60)
      )
      (terminals on)
      (active icon)
     )
    )
    (component 16 "COLLECTOR"
     (description 7 6
      Each line of text is taken from the From File as
      a text string and added as the next element of a
      1-D array of text strings.  After the final line
      line has been read, the EOF pin operates to have
      the Collector send the entire collected array of
      text strings to the Editable Text Constant.
      
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type data)
       (name "Data")
       (tag "Data")
      )
      (input 2
       (type trigger)
       (name "XEQ")
       (lock name constraints)
      )
      (output 1
       (type data)
       (name "Array")
       (tag "Array")
       (lock constraints)
      )
     )
     (implementation
      (component clearAtPrerun 1)
      (component clearAtActivate 1)
      (component output1D YES)
     )
     (views
      (icon
       (origin 725 298)
       (extent 110 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 17 "BREAK"
     (description 7 6
      This device terminates the endless Until Bread
      used to read each line from the file.  After the
      Collector has passed the collected array of text
      to the next device, it's Sequence Out pin will
      let the Break device operate to terminate the 
      loop.  Control will proceed with the device 
      connected tot he Until Break's Sequence Out pin.
     )
     (interface
      (sequence in)
     )
     (implementation
     )
     (views
      (icon
       (origin 741 348)
       (extent 78 25)
      )
      (detail
      )
      (terminals on)
      (active icon)
     )
    )
    (component 18 "NOTE"
     (name "HINTS:")
     (interface
     )
     (implementation
      (component text 3 7
       See the Show Description on most
       of the devices for more detailed
       descriptions.
      )
     )
     (views
      (icon
       (extent 78 0)
       (iconImage "notepad.icon")
      )
      (detail
       (origin 476 139)
       (extent 308 63)
       (editing enabled)
      )
      (active detail)
     )
    )
    (component 19 "LITERALCONSTANT"
     (name "Editable Text Constant")
     (description 24 6
      This device, used somewhat differently, is the
      basis for the editing function.  A resized view
      of this device has been added to the File Editor
      Panel that pops up when the User Object executes.
      
      How does the editing work? In general, each of the
      Data Constant devices can be configured as scalar
      or 1D arrays.  When configed as an array, the
      size of the array changes as the user edits the
      data from the keyboard.  By configing a Text Constant
      as an array, we allow the user to modify each line
      of the array independently.
      
      To load an entire new set of values into a Data
      Constant, the Default Value control input is used.
      A "control" pin operates asynchronously, meaning
      that data arriving on the pin is "used" immediately
      by the device without waiting for other DATA or
      Sequence In pins to be activated.  This allows us
      to load the text array read from the file over any
      existing data in the Text Constant, where the user
      can modify it.
      
      
     )
     (interface
      (sequence in)
      (sequence out)
      (input 1
       (type control)
       (name "Default Value")
       (requires
        (datatype Text)
        (shape "Array 1D")
       )
       (lock name constraints)
       (optional yes)
      )
      (output 1
       (type data)
       (name "Text")
       (lock name constraints)
      )
     )
     (implementation
      (component value Text
       (name "Editable Text Constant")
       (numDims 1)
       (size 1)
       (data
        [ "" ]
       )
      )
      (component autoTrigger off)
      (component initializeAtPrerun off)
      (component initializeAtActivate off)
      (component initValue Text
       (name "CString")
       (datum "")
      )
     )
     (views
      (icon
       (extent 208 0)
      )
      (detail
       (origin 512 428)
       (extent 276 64)
      )
      (terminals on)
      (active detail)
     )
    )
    (configuration
     (connect D15:0 D0:0)
     (connect D0:0 D1:0)
     (connect I1:1 D1:1)
     (connect D15:1 D2:1)
     (connect D1:1 D2:2)
     (connect D19:0 D3:0)
     (connect D19:1 D3:1)
     (connect I1:1 D3:2)
     (connect D2:1 D4:1)
     (connect D1:0 D5:0)
     (connect D16:1 D6:1)
     (connect D12:1 D6:2)
     (connect D10:0 D7:0)
     (connect D5:0 D8:0)
     (connect D1:0 D9:0)
     (connect D9:1 D10:0)
     (connect D10:1 D11:1)
     (connect D3:0 D11:2)
     (connect D11:1 D12:0)
     (connect D0:1 D13:0)
     (connect I1:1 D13:1)
     (connect I1:1 D14:1)
     (connect D14:0 D15:0)
     (connect I1:1 D15:1)
     (connect D13:1 D16:1)
     (connect D13:2 D16:2)
     (connect D16:0 D17:0)
     (connect D5:1 D19:0)
     (connect D6:1 D19:1)
    )
    (ShowOnExecPanel
     (origin 15 76)
     (extent 846 609)
     (panel
      (origin 19 115)
      (extent 842 571)
      (widget 4 detail
       (title off)
       (origin 39 642)
       (extent 370 36)
      )
      (widget 9 icon
       (title off)
       (origin 624 642)
       (extent 76 37)
      )
      (widget 5 icon
       (title off)
       (origin 538 642)
       (extent 67 37)
      )
      (widget 19 detail
       (title off)
       (origin 32 127)
       (extent 815 503)
      )
     )
    )
   )
   (views
    (icon
     (origin 385 388)
     (extent 110 25)
    )
    (detail
     (origin -11 94)
     (extent 882 593)
     (configuration
      (connect D15:0 D0:0
       (Point 70 255)
       (Point 70 265)
      )
      (connect D0:0 D1:0
       (Point 70 334)
       (Point 70 385)
      )
      (connect I1:1 D1:1
       (Point -9 400)
       (Point 12 400)
      )
      (connect D15:1 D2:1
       (Point 127 240)
       (Point 150 240)
       (Point 150 380)
       (Point 164 380)
      )
      (connect D1:1 D2:2
       (Point 127 400)
       (Point 164 400)
      )
      (connect D19:0 D3:0
       (Point 610 494)
       (Point 610 520)
      )
      (connect D19:1 D3:1
       (Point 840 460)
       (Point 860 460)
       (Point 860 500)
       (Point 360 500)
       (Point 360 570)
       (Point 379 570)
      )
      (connect I1:1 D3:2
       (Point -9 400)
       (Point 0 400)
       (Point 0 630)
       (Point 379 630)
      )
      (connect D2:1 D4:1
       (Point 215 390)
       (Point 232 390)
      )
      (connect D1:0 D5:0
       (Point 70 415)
       (Point 70 430)
       (Point 50 430)
       (Point 50 449)
      )
      (connect D16:1 D6:1
       (Point 837 310)
       (Point 850 310)
       (Point 850 380)
       (Point 350 380)
       (Point 350 420)
       (Point 290 420)
       (Point 290 450)
       (Point 304 450)
      )
      (connect D12:1 D6:2
       (Point 321 560)
       (Point 340 560)
       (Point 340 530)
       (Point 290 530)
       (Point 290 470)
       (Point 304 470)
      )
      (connect D10:0 D7:0
       (Point 150 535)
       (Point 150 550)
       (Point 230 550)
       (Point 230 595)
      )
      (connect D5:0 D8:0
       (Point 50 491)
       (Point 50 510)
       (Point 80 510)
       (Point 80 595)
      )
      (connect D1:0 D9:0
       (Point 70 415)
       (Point 70 430)
       (Point 150 430)
       (Point 150 449)
      )
      (connect D9:1 D10:0
       (Point 190 470)
       (Point 210 470)
       (Point 210 500)
       (Point 150 500)
       (Point 150 505)
      )
      (connect D10:1 D11:1
       (Point 175 520)
       (Point 194 520)
      )
      (connect D3:0 D11:2
       (Point 610 651)
       (Point 610 670)
       (Point 180 670)
       (Point 180 540)
       (Point 194 540)
      )
      (connect D11:1 D12:0
       (Point 245 530)
       (Point 280 530)
       (Point 280 545)
      )
      (connect D0:1 D13:0
       (Point 127 300)
       (Point 140 300)
       (Point 140 230)
       (Point 430 230)
       (Point 430 246)
      )
      (connect I1:1 D13:1
       (Point -9 400)
       (Point 0 400)
       (Point 0 350)
       (Point 140 350)
       (Point 140 320)
       (Point 161 320)
      )
      (connect I1:1 D14:1
       (Point -9 400)
       (Point 0 400)
       (Point 0 170)
       (Point 13 170)
      )
      (connect D14:0 D15:0
       (Point 200 205)
       (Point 200 220)
       (Point 70 220)
       (Point 70 225)
      )
      (connect I1:1 D15:1
       (Point -9 400)
       (Point 0 400)
       (Point 0 240)
       (Point 12 240)
      )
      (connect D13:1 D16:1
       (Point 699 300)
       (Point 722 300)
      )
      (connect D13:2 D16:2
       (Point 699 340)
       (Point 710 340)
       (Point 710 320)
       (Point 722 320)
      )
      (connect D16:0 D17:0
       (Point 780 325)
       (Point 780 345)
      )
      (connect D5:1 D19:0
       (Point 86 470)
       (Point 100 470)
       (Point 100 420)
       (Point 160 420)
       (Point 160 430)
       (Point 360 430)
       (Point 360 390)
       (Point 610 390)
       (Point 610 397)
      )
      (connect D6:1 D19:1
       (Point 355 460)
       (Point 379 460)
      )
     )
     (stackingOrder 0 1 2 3 4 5 6 7 8 9
       10 11 12 13 14 15 16 17 18 19)
    )
    (active icon)
   )
  )
  (configuration
  )
 )
 (views
  (detail
   (origin 0 62)
   (extent 880 413)
   (configuration
   )
  )
  (active detail)
  (numberFormats
   (realFormat standard)
   (realSigDigits 4)
   (realRadixSpec 4)
   (integerBase decimal)
  )
  (waveformSettings
   (timeSpan 0.02)
   (numPoints 256)
  )
 )
)
