summaryrefslogtreecommitdiff
path: root/ipl/gprocs/fetchpat.icn
blob: b2358d61a880ae9a236a90bf886ed080c76e52b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
############################################################################
#
#	File:     fetchpat.icn
#
#	Subject:  Procedure to fetch a pattern specification
#
#	Author:   Ralph E. Griswold
#
#	Date:     October 21, 1993
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This procedure fetches a pattern by number from a file of pattern
#  specifications.  It fails if the file does not exist or does not
#  contain that many pattern specifications.
#
#  The file is searched for in the current directory first, then using
#  DPATH.
#
############################################################################
#
#  Links:  io, patutils
#
############################################################################

link io
link patutils

procedure fetchpat(file, n)
   local input, pattern

   input := dopen(file) | fail

   every 1 to n do
      pattern := readpatt(input)

   close(file)

   return \pattern

end