コマンドの処理 1 APPEND,DELETE
2016-03-14


c ckp.for -- check for "p" after command integer function ckp(lin,i,pflag,stats) integer*1 lin(82) ! MAXLINE(82) integer i,j,pflag,status j = i if (lin(j) .eq. 112) then ! PRINT(100,'p') j = j + 1 pflag = 1 ! YES(1) else pflag = 0 ! NO(0) end if if (lin(j) .eq. 10) then ! NEWLINE(10) status = -2 ! OK(-2) else status = -3 ! ERR(-3) end if ckp = status return end

DELETEコマンドは、指定された行を削除するわけだが、 実際には行と行のつなぎ情報を操作するだけである。

RATFOR版。

# delcmd.r4 -- delete lines from though to
      integer function delcmd(from,to,status)
      integer from,to,status

      integer getind,nextln,prevln
      integer k1,k2

      include clines.ri

      if (from <= 0)
          status = ERR
      else {
          k1 = getind(prevln(from))
          k2 = getind(nextln(to))
          lastln  = lastln - (to - from + 1)
          curln = prevln(from)
          call relink(k1,k2,k1,k2)
          status = OK
          }
      delcmd = status
      return
      end

WATCOM Fortran77版。

c delcmd.f -- delete lines from though to
      integer function delcmd(from,to,status)
      integer from,to,status

      integer getind,nextln,prevln
      integer k1,k2

      include clines.fi

      if (from .le. 0) then
          status = -3                   ! ERR(-3)
      else
          k1 = getind(prevln(from))
          k2 = getind(nextln(to))
          lastln  = lastln - (to - from + 1)
          curln = prevln(from)
          call relink(k1,k2,k1,k2)
          status = -2                   ! OK(-2)
      end if
      delcmd = status
      return
      end

戻る
[コンピューター]
[RATFOR]

コメント(全50件)
※コメントの受付件数を超えているため、この記事にコメントすることができません。


記事を書く
powered by ASAHIネット