PROC convert_dssl_to_text, condtt(
  dual_state_source_library, dssl: file = $required
  text_file, tf: file = dssl_text
  target_operating_system, tos: key nos nosbe = nos
  status)

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"The purpose of this procedure is to convert the NOS/VE dual state source library into
"a nos multi-file text file. (There are three files on the multi-file.)
*IFEND

IF $specified(target_operating_system) THEN
  create_variable wev$target_operating_system kind=string scope=xdcl ..
        value=$string($value(target_operating_system))
ELSEIF $variable(wev$target_operating_system, declared) = 'NONLOCAL' THEN
  create_variable wev$target_operating_system kind=string scope=xref
ELSE
  create_variable wev$target_operating_system kind=string scope=xdcl ..
        value=$string($value(target_operating_system))
IFEND


  create_variable local_status k=status
  create_variable ignore_status k=status

  create_variable n=errors_file k=string v=$unique
  create_variable internal_text_file k=string v=$unique
  create_variable scratch_library k=string v=$unique

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"Create a nos deck header.
*IFEND

  put_line '/DECK,DUAL' o=$fname(internal_text_file//'.$boi')
  put_line '/WIDTH 255,0' o=$fname(internal_text_file//'.$eoi')

  SCU
  condtt_proc: ..
    BLOCK
      use_library $value(dual_state_source_library) r=$null status=local_status
      EXIT condtt_proc WHEN NOT local_status.normal

      set_list_options errors=$fname(errors_file)

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"The first entry in the multi-file file contains all of the ccl procedures which
"are to go onto nvelib.  Each procedure is separated by an EOR mark which
"is contained on the end of the deck.
*IFEND

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nvelib ccl_procedures) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,15' o=$fname(internal_text_file//'.$eoi')

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"The second entry in the multi-file file contains the compass and sympl modules which
"are to go onto nvelib (each language group is separated by an end-of-record mark; but
"there are no marks between individual modules); and the ccl procs which go onto nosbins.
"(There are end-of-record marks between each ccl proc module.)
*IFEND


      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nvelib cp_compass) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nvelib sympl) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nosbins ccl_procedures) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,15' o=$fname(internal_text_file//'.$eoi')


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"The last entry on the multi-file file contains the compass modules which go onto
"nosbins, the compass and cybil modules which go onto nverels, the sympl modules
"(for FASLAVE) which go onto nverels and the FASLAVE compass modules.  Each language
"group is separated from the others by an end-of-record mark.  (The FASLAVE modules
"get special treatment because they require additional NOS interfaces when linking.
*IFEND

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nosbins cp_compass) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nverels cp_compass) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group (osf$nverels cybil_cc) all
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group sympl_modules
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

      EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
        include_group  compass_modules
        exclude_group deleted_decks status=ignore_status
      END
      EXIT condtt_proc WHEN NOT local_status.normal
      IF wev$target_operating_system='NOSBE' THEN
        put_line '/WEOR,0' o=$fname(internal_text_file//'.$eoi')

        EXPAND_DECK d=none $fname(internal_text_file//'.$eoi') sc=$command status=local_status
          include_group  fortran_cc
          exclude_group deleted_decks status=ignore_status
        END
        EXIT condtt_proc WHEN NOT local_status.normal
      IFEND
      put_line '/WEOR,15' o=$fname(internal_text_file//'.$eoi')

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"Change the /EOR seperators contained on the end of all ccl_procedures into /WEOR's
"which are needed for nos.
*IFEND

      EDIT_FILE $fname(internal_text_file) i=$command o=$null p=$null status=local_status
        replace_text '/EOR' '/WEOR,0' n=a l=a status=ignore_status
      end
    BLOCKEND condtt_proc
    include_line 'END false' status=ignore_status
"$COMMAND=END FORMAT=TRUE


  detach_file $fname(scratch_library) status=ignore_status
  IF local_status.normal THEN
    copy_file $fname(internal_text_file) $value(text_file) status=local_status
  ELSE
    copy_file f=$fname(errors_file) o=$response status=ignore_status
  IFEND
  detach_file $fname(internal_text_file) status=ignore_status
  detach_file $fname(errors_file) status=ignore_status
  EXIT_PROC WITH local_status WHEN NOT local_status.normal

PROCEND convert_dssl_to_text
