home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
kpwdemo.zip
/
DEMO.HYP
< prev
next >
Wrap
Text File
|
1990-06-28
|
12KB
|
355 lines
//Features
Point and click for information on the following features:
#mScreen Design#m
#mHypertext#m
#mGraphics#m
#mText Handling#m
#mCalling Other Programs#m
#mObject-Oriented Programming#m
#mList Manipulation#m
#mExpert Systems#m
#mDDE#m
#mDLL#m
//Screen Design
Using KnowledgePro (Windows), all Windows screen objects can
be created with a single line of code. For example:
button (Print, goPrint, 10, 5).
creates a button with the text Print at column 10 row 5.
When the button is selected, the topic goPrint is called.
Perhaps goPrint may print the contents of a file:
topic goPrint.
print (read (myfile)).
end.
The tool DESIGN is included to help you design
attractive screen displays. Screen objects can be created,
moved and edited on screen. The code to create the screen is
produced and can be copied directly into your application.
Select HELP in DESIGN for a description of how to use the
application and how to link screen objects to topics.
//Text Handling
A full set of string handling and text file searching functions
makes KnowledgePro adept at handling text.
Text files can be read by characters, lines or beginning and
ending with a specified search string. For example, consider
the command:
text (read (myfile, ##n##n, ##n##n, PRESIDENT)).
This will display the first paragraph in MYFILE which contains
the word PRESIDENT. ##n is a line feed so ##n##n means that a
paragraph ends with a blank line.
Text can also be replaced. This command replaces PRESIDENT
with CHAIRMAN in the entire text file:
newText is read (MYFILE,,,PRESIDENT,CHAIRMAN).
If you want to over-write the old file you can use WRITE:
new_file (MYFILE).
write (MYFILE, ?newText).
Once text is read in it can be manipulated using the string
handling functions. You can search for certain characters
within a string:
x is 'this is a sample string'.
find is string_where (?x, am).
The topic FIND is assigned the value 12 which is the
starting position of the string.
You can concatenate strings:
x is TOM.
y is concat ('HELLO ',?x).
y is assigned the new string 'HELLO TOM'.
Characters in strings can be replaced by others:
x is 'THIS IS A TEST'.
y is string_replace (?x,IS, 'IS NOT').
The value of x is changed to 'THIS IS NOT A TEST'.
Strings can be changed into lists of words or characters for
added flexibility.
Using the string handling functions, KnowledgePro can create
files, code, and DDE commands to front end other programs. For
example, we've heard from several users who have used
KnowledgePro as a front end for neural net programs, databases
and statistical analysis programs. At the back end,
KnowledgePro can read the output from other programs, interpret
it and present it to the user intelligently based on other
information gathered in the application.
#mString Handling and File Access Functions#m
//Calling Other Programs
Using KnowledgePro you can load, run and interact with
other Windows applications. #mDDE#m is supported, allowing
you to exchange data with windows programs.
You can also run DOS programs and Dynamic Link Libraries (#mDLL#m)
from within KnowledgePro.
//Object-oriented Programming
A topic is a type of object. It can inherit values from one or
more other topics and commands. For example, if the topic A has
the following structure:
topic A.
text (hello).
topic B.
end.
topic C.
end.
end.
We can create a new topic D which inherits all of topic A's
properties:
new (D,A).
Topic D can be called an instance of topic A. When topic D is
created, all of the sub-topics of A along with their properties,
values and attached commands are copied into the hierarchy
of D. Next, the commands attached to A are copied into D
and executed.
A sub-class of a topic can also be executed:
topic E.
im_a (A).
topic (B).
end.
end.
When E is executed the im_a makes it a sub-class of A. This
means that all of A's sub-topics which do not already exist in
E are copied. Since E already has a sub-topic B, that is not
copied. This permits sub-classes to have certain behaviors
that are unique from the general class. Next, the commands
attached to A are copied to the end of the commands already in
E and are performed when they are reached.
Object-oriented programming puts a twist on the way you think
about programs but, if you're doing complicated programs it's
worth the effort. It is especially helpful in programs where
certain procedures are performed repetitively but with a slight
difference each time.
On those occasions when you find yourself trying to decide
whether to duplicate code or to put in flags to signify special
cases, think about a switch to an object oriented approach.
Chapter 6 of the user's manual contains two detailed examples
of object-oriented programs and, for you experienced
programmers, DESIGN, which is included with this demo,
is almost entirely based on object-oriented techniques.
//DDE
KnowledgePro can be used to send DDE messages to other
applications or, in the development environment, can receive
DDE messages to execute any knowledge base commands.
If you have Microsoft Excel in a directory which is included in
your path you can #mclick here#m to see an example of DDE
which is provided in the application DDESHOW.SRC.
Here's a simple example of the use of DDE to install an icon on
the Windows 3.0 program manager:
channel is dde_open (dde_topic, progman, progman).
command1 is '[ShowGroup(Windows Applications,2)]'.
command2 is '[ShowGroup(Windows Applications,1)]'.
command3 is '[AddItem(\kpwin\kpwin.exe,KnowledgePro,\kpwin\kpwin.ico)]'.
dde_execute (?channel,[?command1,?command2,?command3]).
topic dde_topic.
end.
The format of the information passed to dde_open depends
on the server application, in this case the Program Manager.
The handle of the channel is stored here in the topic channel.
This handle is used to refer to the open channel. We execute
one command to show the Program Group and then install the
icon. The syntax of the information is provided by the server
application.
Since Windows applications can be run from KnowledgePro,
their windows manipulated and data passed using DDE,
KnowledgePro can be used to seamlessly link together any
Windows applications which support DDE.
DOS applications can be run from KnowledgePro and data
exchanged via text files, allowing them to be included as need.
//DLL
KnowledgePro supports dynamic link libraries, enabling you to
directly extend its functionality. Included with the full system
are a collection of source files for creating user-defined functions.
These are contained in the files LIBINIT.ASM, KPDEFS.H,
KPUTIL.C, KPUSER.C, KPUSER.DEF and KPUSER.MAK. These
are discussed in detail in Chapter 8 of the user's manual.
We have used DLL libraries to create KnowledgePro functions
for accessing full-motion video, and integrating the code supplied
by vendors was accomplished in just a few hours.
As Windows toolkits proliferate, DLL libraries will become an
exciting way to enhance the system.
//List Manipulation
Lists are an important part of KnowledgePro. They let you
compare, match and keep track of information. For example:
choices is [DESIGN,FONT,COLOR].
kbs is ['DESIGN.KB','FONT.KB','COLOR.KB'].
ask ('Which would you like to see?', want,?choices).
new_kb (element (?kbs, where (?choices, ?want))).
Here, ASK puts a question on the screen along with a list box
of possible answers which are defined in the topic CHOICES. The
answer selected is saved in the topic WANT.
We search the list of choices to find where the user's selection
occurred and load the knowledge base that matches that choice.
Many things that can be done to one item can also de done to a
list of items:
message is read ([FILE1, FILE2]).
This reads the contents of each of the named files into the
topic MESSAGE. In the next example, each topic in the first
list is assigned the corresponding value from the second list:
[a,b,c,d] is_c [1,2,3,4].
Lists can also be turned into strings of text and characters and
strings can be turned into lists. This is very powerful for
analyzing and manipulating text files.
#mList handling commands#m
//List handling commands
Lists
Find:
First item #x40first
Last item #x40last
Specific item #x40element
All except #x40rest
Length of a list #x40list_length
Where an item is on a list #x40where
If an item is on a list #x40one_of
Sort:
Alphabetic #x40sort
Numeric #x40numeric_sort
New lists From old:
Remove an item #x40remove
Replace matching items #x40replace
Replace specific elements #x40replace_elements
Items not shared by lists #x40different
Items on all lists #x40intersect
Sublist #x40sublist
Combine lists #x40combine
Combine lists, no doubles #x40union
//String Handling and File Access Functions
Find:
Length #x40string_length
Location of a substring #x40string_where
Concatenate #x40concat
Copy part of a string #x40string_copy
Replace part of a string #x40string_replace
Conversion between Lists and Strings
ASCII Values to characters #x40number_to_char
Characters to ASCII values #x40char_to_number
String to list of characters #x40list_of_char
String to lower case #x40lower
String to upper case #x40upper
String to list #x40string_to_list
List to string #x40list_to_string
Text Files
Read:
Paragraph #x40read
Line #x40read_line
Character #x40read_char
Write #x40write
Open #x40new_file
Close one or more #x40close
Close all #x40close_all
Set file pointer #x40set_file_pos
Get file pointer #x40get_file_pos
//Code Included
The code is included for all the knowledge bases shipped with
the system. This can be a good source of ideas for your own
applications.
Code files always end with .KB for stand alone applications
and .SRC for knowledge bases which are called by another
application.
The code for this application is in DEMO.KB.
The code for the tools is in .SRC files.
//Ordering Information
KnowledgePro (Windows) is available for $695 plus
shipping and handling from:
Knowledge Garden Inc.
473A Malden Bridge Road
Nassau, NY 12123
Phone: #x14 518-766-3000
Fax: #x14 518-766-3003
EMail:#x14 Compuserve 72470,3032
Call for educational discounts, site license information
and dealer inquiries.
//Expert Systems
KnowledgePro is an ideal language for creating
stand-alone expert systems and for applications
with embedded expert system capabilities. Both
backward chaining and frame-based systems can
be constructed.
//