!++
! FILENAME: DECUS_PROCS.TPU
! FUNCTION: TPU Procedures excerpted from DECUS symposium tapes and modified
!           or augmented by me to work within EVEDT.
! AUTHOR:   DECUS, Steven K. Shapiro
!           (C) Copyright SKS Enterprises, Austin TX. All Rights Reserved.
!
!           The format, structure and contents of this file are the sole
!           property  of Steven K. Shapiro  and are  copyrighted to  SKS
!           Enterprises, Austin Texas.
!
!           The information may be freely distributed, used and modified
!           provided  that the  information in this  header block is not
!           changed, altered, disturbed or modified in any way.
!
! DATE:     30-DEC-1988 Original.
! HISTORY:  -<( 30-DEC-1988 10:54:00.61 )>- current.
! CONTENTS:
!           eve_move_rel
!           eve_ins_numbers
!           eve_del_numbers
!           eve$double_quotes (string_with_quotes)
!
!23456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H
!--
!*----------------------------------------------------------------------------*!

procedure decus_procs_module_ident

  local file_date,
        module_vers;

  file_date := "-<( 15-NOV-1988 14:20:18.41 )>-";
  module_vers := substr(file_date,5,2) +
                 substr(file_date,8,3) +
                 substr(file_date,14,2) +
                 substr(file_date,17,5) ;

  return module_vers;

endprocedure;

!*----------------------------------------------------------------------------*!

!*----------------------------------------------------------------------------*!
! FROM KMSKITLSE_LSE$PROCEDURE.TPU
!+-----------------------------------------------------------------------------+
!|  This procedure moves the user up or down a specified number of lines.      |
!|  This is good when debugging TPU and you have to go to the Nth line.        |
!+-----------------------------------------------------------------------------+

PROCEDURE eve_move_rel

LOCAL 
        user_input,
        move_to;

  user_input := READ_LINE ('Relative Line Number: ',4);
  move_to := int(user_input);
  SET (SCREEN_UPDATE,OFF);
  move_vertical(move_to);
  SET (SCREEN_UPDATE,ON);

ENDPROCEDURE

!*----------------------------------------------------------------------------*!
! FROM KMSKITLSE_LSE$PROCEDURE.TPU
!*----------------------------------------------------------------------------*!
! This procedure inserts line numbers incrementing by one at the beginning 
! of each line for the whole file.  
!*----------------------------------------------------------------------------*!

PROCEDURE eve_ins_numbers

LOCAL 
        number_string,
        number,
        count,
        number_indent,
        curr_pos;

  SET (INFORMATIONAL,ON);
  SET (INSERT,current_buffer);
  curr_pos := MARK(NONE);
  POSITION (BEGINNING_OF (current_buffer));   ! Position cursor at top
  count := GET_INFO(current_buffer,"record_count");
  number := 1;

  LOOP
    number_string := FAO("!5ZL!AS",number," ");
    MOVE_TEXT(number_string);
    MOVE_HORIZONTAL(-6);
    MOVE_VERTICAL(1);
    EXITIF count = number;
    number := number + 1;
  ENDLOOP;

  SET (INSERT,current_buffer);
  POSITION (curr_pos);

ENDPROCEDURE

!*----------------------------------------------------------------------------*!
! FROM KMSKITLSE_LSE$PROCEDURE.TPU
!------------------------------------------------------------------------------+
! This procedure deletes the line numbers placed by the ins_line_paste 
! procedure from the file. 
!------------------------------------------------------------------------------+

PROCEDURE eve_del_numbers

LOCAL 
        mrker,
        number,
        count,
        rnge,
        curr_pos;

  SET (INFORMATIONAL,ON);
  curr_pos := MARK(NONE);
  POSITION (BEGINNING_OF (current_buffer));   ! Position cursor at top
  count := GET_INFO(current_buffer,"record_count");
  number := 1;

  LOOP
    mrker := SELECT(NONE);
    MOVE_HORIZONTAL(6);
    rnge := select_range;
    mrker := 0;
    ERASE (rnge);
    MOVE_VERTICAL(1);
    EXITIF number = count;
    number := number + 1;
  ENDLOOP;

  SET (INSERT,current_buffer);
  POSITION (curr_pos);

ENDPROCEDURE

!*----------------------------------------------------------------------------*!
! FROM: RCAS_EVESECINI.TPU
!*----------------------------------------------------------------------------*!
! Procedure for handling quoted string.  Takes the argument, doubles
! all quotation marks, and return the resulting string.
!
! Parameters:
!
!       string_with_quotes      String being processed - input

procedure eve$double_quotes (string_with_quotes)

local result_string,            ! Portion of string with quotes doubled
      rest_of_string,           ! Remainder of string yet to be processed
      quote_index;              ! Index of double-quote in rest_of_string

  result_string := eve$kt_null;
  rest_of_string := string_with_quotes;

  loop
    quote_index := index (rest_of_string, '"');

    if quote_index = 0 then
      result_string := result_string + rest_of_string;
      exitif 1;
    else
      result_string := result_string +
                       substr (rest_of_string, 1, quote_index) + '"';
      exitif quote_index = length (rest_of_string);
      rest_of_string := substr (rest_of_string, quote_index + 1,
                                length (rest_of_string));
    endif;
  endloop;

return (result_string);

endprocedure;

!*----------------------------------------------------------------------------*!

