home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Between Heaven & Hell 2
/
BetweenHeavenHell.cdr
/
garden
/
textpro.src
< prev
next >
Wrap
Text File
|
1988-01-06
|
7KB
|
222 lines
(* TEXTPRO.SRC DECEMBER 28, 1987
This is the engine that lets you read and write hypertext documents.
Written in the KnowledgePro development environment by Bev and Bill Thompson.
Copyright 1987 Knowledge Garden Inc.
TextPro may be freely copied and distributed but may not be modified
or used for commercial purposes. *)
do (setup).
do (menu).
topic menu.
ask ('What would you like to do with hypertext?',want,['Read a hypertext document',
'Create or Edit a hypertext document',Quit]).
if ?want <> Quit
then do (?want) and
do (menu).
topic 'Read a hypertext document'.
file_name (input).
if ?file <> ?ESC
then do (read_hyper).
topic read_hyper.
text is read (?file,concat ('/page',?current),'/end').
if ?text <> ?EOF
then say (?text) and
current = ?current + 1 and
do (read_hyper)
else if ?current = 1
then text is read (?file,,'/end') and
say (?text)
else close (?file) and
current = 1.
end. (* read_hyper *)
end. (* Read a hypertext document *)
topic 'Create or Edit a hypertext document'.
file_name ().
if ?file <> ?ESC
then do (create_hyper).
topic create_hyper.
window ('',white,yellow,black,1,20,78,1).
write ('con:','
Press F4 if you want an #mexplanation#m of how to create a hypertext document.').
edit_file (?file,,,,1,1,78,17).
close_window ().
close (?file).
finding is user_file.
end. (* create_hyper *)
end. (* Create or Edit a hypertext document *)
topic file_name (check).
write (con:,#e,'
Type the name of the file you want to use.
File names use DOS file conventions.
File names entered using a #fyellow *#d will display a menu of all matching files.
Press #fyellow ESC#d to return to the opening menu.').
window ('',,,,1,9,78,3).
read_response ('#s#nName of file ',file,?last_file).
close_window ().
if ?file is ?ESC
then exit ().
if string_where (?file,*) <> 0
then do (show_files).
if ?file <> ?new
then do (?check) and
(if ?file <> ?new
then last_file is ?file
else file_name (?check) )
else file_name (?check).
topic show_files.
list is dir (?file).
list gets ?new.
if ?list is ?new
then message is ['
There are no files with the description #fred
',?file,#d,'
Enter a new file name.'] and
error (?message)
else ask ('Which file would you like to select ?',file,?list).
end. (* show_files *)
topic input.
text is read_char (?file).
if ?text is ?EOF
then message is ['
The file #s',#fred,?file,#d,#l,'
does not exist. Enter a new file name.'] and
error (?message).
end. (* input *)
topic error (message).
window ('',black,lightcyan,lightcyan,15,7,51,7) and
say (?message).
close_window ().
file is ?new.
end.
end. (* file_name *)
topic mark (find_string) .
new_string is concat ('/',?find_string).
text is read (?file,?new_string,'/end') .
if ?text is ?EOF
then say ('Sorry, I can''t find that thread')
else do (print).
topic print.
item is ?item + 1.
if ?item > ?colors
then item = 1.
text_color is element (?fore,?item).
window (?find_string,?text_color,element (?back,?item),white).
say (?text) .
close_window ().
end. (* print *)
end . (* mark *)
end. (* menu *)
(* ======================== Hypertext for explanation =============== *)
topic explanation.
window (Explanation).
say ('
In TextPro, information is broken up into units called
#fyellow messages#d. A message is a section of text that is
made up of a label, the text of the message, and an ending.
The label depends on the type of message. The ending is
simply a line containing #fyellow /end#d. There are two
different types of messages; page and thread.
... PgDn
Page messages are labeled with the name #fyellow /page#d followed by the
number of the page. These messages are displayed sequentially
to provide a context for your information. The page messages
should be formatted with a #mright margin#m of 78. The length of
the display window is 19 rows but longer messages will be
automatically formatted so that PgUp and PgDn can be used.
Within a page message you can mark important concepts by
enclosing the words with the symbols #fyellow ##m#d. These concepts are
called hypertext threads. Each thread will be linked to
another message which will be displayed when the #mreader selects#m
the thread. ... PgDn
Thread messages are labeled with the name #fyellow /#d followed by the
name of the hypertext thread to which it''s related. These
messages are displayed only when the #mreader selects#m the
hypertext thread in its label. Threaded messages should be
formatted with a right margin of 65. The length of the display
window is 11 rows but longer messages will be automatically
formatted so that PgUp and PgDn can be used. Threaded messages
can contain other threaded messages. ... PgDn
If you would like to see an example of a hypertext file, you
can copy the file SAMPLE.HYP into the text editor as soon as
you are finished with this message. To do this use the editor
command ^KR and when you''re asked for the name of the file type
in SAMPLE.HYP. The text read in will appear in inverse video.
To return to the normal video type ^KH.').
close_window ().
end. (* explanation *)
topic 'reader selects'.
window ('',white,magenta,white).
say ('
The reader can select a hypertext message by pointing to its
highlighted thread with the mouse or, by pressing the F3 key to
move the cursor. Once a thread has been selected, the message
is displayed when the mouse button is clicked or, the F4 button
is pressed.').
close_window ().
end. (* reader selects *)
topic 'right margin'.
window ('',black,green,white).
say ('
To change the margin press ^OR while in the text editor. A
window will appear which asks you the new value for the right
margin.').
close_window ().
end. (* right margin *)
topic setup.
no_edit_key ().
no_debug ().
EOF = number_to_char(26).
ESC = number_to_char(27).
colors is 5.
if monitor_type () is mono
then fore is [white,white,white,white,white] and
back is [black,black,black,black,black]
else fore is [white,black,red,black,white] and
back is [red,green,lightcyan,white,magenta].
item = 0.
current = 1.
new is 'Enter a new file name.'.
last_file is ''.
end. (* setup *)