home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
OL.LZH
/
PROCS.LZH
/
GETKEYS.ICN
< prev
next >
Wrap
Text File
|
1991-09-05
|
2KB
|
75 lines
############################################################################
#
# Name: getkeys.icn
#
# Title: get keys for a gettext file
#
# Author: Richard L. Goerwitz
#
# Version: 1.1
#
# Date: June 1, 1991
#
############################################################################
#
# getkeys(FNAME) generates all keys in FNAME in order of occurrence.
# See gettext.icn for a description of the requisite file structure
# for FNAME.
#
############################################################################
#
# Links: adjuncts.icn
#
# Requires: UNIX (may work under MS-DOS; untested there)
#
# See also gettext.icn
#
############################################################################
link adjuncts
# declared in adjuncts.icn
# global _slash, _baselen
procedure getkeys(FNAME)
local line, intext, start_unindexed_part
initial {
if /_slash then {
if find("UNIX", &features) then {
_slash := "/"
_baselen := 10
}
else if find("MS-DOS", &features) then {
_slash := "\\"
_baselen := 8
}
else stop("getkeys: OS not supported")
}
}
/FNAME & stop("error (getkeys): null argument")
# Try to open index file (there may not be one).
if intext := open(Pathname(FNAME) || getidxname(FNAME)) then {
# If there's an index file, then just suspend all the keys in
# it (i.e. suspend every line except the first, upto the tab).
# The first line tells how many bytes in FNAME were indexed.
# save it, and use it to seek to unindexed portions later on.
start_unindexed_part := integer(read(intext))
while line := read(intext) do
line ? suspend tab(find("\t")) \ 1
close(intext)
}
intext := open(FNAME) | stop("getkeys: ",FNAME," not found")
seek(intext, \start_unindexed_part | 1)
while line := read(intext) do
line ? { suspend (="::", tab(0)) \ 1 }
# Nothing left to suspend, so fail.
fail
end