![[Images/tutorial.gif]](Images/tutorial.gif)
Introduction to Khoros Programming
Table of Contents - Index
Previous: Introduction
Next: Program 1 - A simple kroutine to convert from a specific (simple) format to KDF
![[bar]](Images/rule.gif)
A program for Khoros must be created under the suite of tools that Khoros provides. This makes software development easier and assures that every program can use the Khoros libraries for data manipulation, basic routines and more. Just adding existing C programs cannot use all functionality of Khoros, but converting existing C programs to work with Khoros is straightforward.
In this section we will explain some of the terms used in Khoros programming. The words "program" and "software object" or "object" are used with the same meaning here.
![[bar2]](Images/rule2.gif)
Programs that will work under Khoros must be associated with a Toolbox. A toolbox is a container of objects that share something in common. As an example, check the Image Toolbox (if you installed it when you installed Khoros): there are several image processing programs with functions in its libraries, all related to image processing.
Before creating any object in Khoros you must create a toolbox to contain these objects. After creating a toolbox you can change several parameters of it, and move objects from one toolbox to another, add more programs to a toolbox or delete programs from a toolbox, but a little planning before creating the toolbox could save some time later.
Even if you have the right permissions, it is not advisable to use an existing Khoros or third-party toolbox to add your objects. Doing this will complicate things when you need to upgrade your Khoros system or distribute a toolbox. Creating a toolbox to hold your own objects is safer and more fun, and the step-by-step information on how to do it will be explained in
Creating a new Toolbox
.
![[bar2]](Images/rule2.gif)
Kroutines are non-interactive programs that will get an input data and manipulate it to create an output data. Before the program runs the user can select several parameters which will be used by the program, but after the program is running the user has no control and can take five minutes (or just some seconds or several hours, depending on the program and data) to get some coffee.
Kroutines can have associated library calls (called
lkroutines ) which contains all functionality for the program. The advantage to do this is that your program functionality could be called from other programs as a function. Another non-official advantage is that when
Khoral Researchcreates the workspace-to-single-program thingie, it will probably use this approach.
![[bar2]](Images/rule2.gif)
Xvroutines are visual-oriented, interactive programs that will display or manipulate data. Xvroutines are easier to program than programs with X library calls from scratch - there are several visual objects that are ready to use with Khoros programs that will simplify tasks like display of images and graphs, annotations,
ROI extraction and much more.
![[bar2]](Images/rule2.gif)
Libraries are parts of code that can be put together and used in programs. Under Khoros you could think of three kinds of functions in libraries: lkroutines which are functions associated with kroutines,
public functions and
private functions . The main difference between public and private functions is that a manual page will be created automatically for the public ones and not for the private ones.
The nice thing about libraries is that you can reuse code - write a library for basic image manipulation, for example, and you will be able to call it from all programs in the toolbox that contains this library. Additionally if you create another toolbox and make it dependent on the first toolbox (more about this in
Making a toolbox dependent on other
) and voila, the second toolbox will be able to access the functions on the first. This alone is a good reason to design your programs with separate modules that can be added in libraries.
![[bar2]](Images/rule2.gif)
Panes are different interfaces for already existing programs. They can be used as "shortcuts" to avoid passing many parameters to kroutines.
![[bar2]](Images/rule2.gif)
Scripts are usually created in one of the Unix shells (csh, sh, ksh) or in Perl. Scripts are usually programs that will do some manipulation of software objects - there aren't functions for scripts to manipulate data.
![[bar]](Images/rule.gif)
Every kroutine, xvroutine and pane must have an
user interface so they can run under
cantata and the code generator can create parameter checking routines for the programs so they can run outside cantata. The
UIS (
user interface specification ) file serve to define the
CLUI (
command line user interface ) for the program - which determines the parameters for the program when it is called from the command line and the
GUI (
graphical user interface ) which will be used when the program is called from within cantata.
Xvroutines
will also have an user interface for the interaction with the program.
Khoros has the functions to visually create these user interfaces, and skeleton programs can be created based on the user interfaces. Later the user must add functionality to the programs. We will see all these steps in the programming examples.
![[bar]](Images/rule.gif)
To create software objects in Khoros you must first create a toolbox or activate an existing toolbox. To do this, you need to run
craftsman . It will show the following window:
![[Images/craftsman.gif]](Images/craftsman.gif)
Craftsman's window (1)
(the list of Toolboxes will depend on which toolboxes you have installed, the window appearance will depend on your window manager and widget set)
On the left list box, we have the currently installed toolboxes, on the right (if a toolbox is selected) we have the list of objects on that toolbox.
To create a toolbox, click on the "Toolbox operations" menu button and select "Create Toolbox". The following window will appear:
![[Images/craftsman-createnewtoolbox.gif]](Images/craftsman-createnewtoolbox.gif)
Craftsman: creating a new toolbox
Fill the fields of this window with the toolbox information:
- Toolbox Name: enter a single-string name for the toolbox, avoid names already existing.
- Toolbox Path: enter the path for the toolbox. You must have full write permissions on that path. It will be a good idea to use the path exclusively for the toolbox so the
klint program can be used to check if the files under that directory are related to the toolbox. If the directory of the toolbox is not empty craftsman will give an error message when you try to create the toolbox.
- Toolbox Title (optional): enter a string with the title of the toolbox
- Toolbox Author Name: your name (will be obtained from the file
.khoros_env
)
- Toolbox Author E-mail: your e-mail (will be obtained from the file
.khoros_env
)
- Toolbox Status: Set to Development. If you set to Scratch or Work its components will not appear on Cantata's menus.
For the programs in this tutorial we will create a new toolbox called... tutorial. The window filled with the data for this new toolbox will look like:
![[Images/craftsman-createnewtoolbox-filled.gif]](Images/craftsman-createnewtoolbox-filled.gif)
Craftsman: creating a new toolbox (filled)
(of course with your data instead of the ones in the fields of the image above).
To create the toolbox, press the "Create Toolbox" button. After some seconds, the toolbox will be created and you can press the "Close" button to close the Create Toolbox Window.
The next step would be creating a new software object in the toolbox. This will depend on which kind of software object we will be creating, so it will be covered in the tutorials for each software object.
![[bar]](Images/rule.gif)
Table of Contents - Index
Previous: Introduction
Next: Program 1 - A simple kroutine to convert from a specific (simple) format to KDF
![[bar]](Images/rule.gif)
These pages copyright ©
Rafael Santos (e-mail valid until March 1998). Please let me know if this tutorial is useful for you, I need to justify the time I used to develop it. Comments, requests and bug reports are also welcome, but please see the section
Before you e-mail me...
![[bar2]](Images/rule2.gif)
Khoros copyright © Khoral Research, Inc. (KRI) - run klicense for more information.
Khoral Research Inc. is not responsible for or is supervising these pages.
![[bar2]](Images/rule2.gif)
The latest version of this document can be found at
Ejima Lab Khoros Pages at Kyushu Institute of Technology, Japan (until March 1998).
Mirrors for this tutorial can be found at Universidade do Vale do Paraíba, Brasil and PUC/RS, Brasil.
![[bar2]](Images/rule2.gif)
Generated with StructHTML, 14:18 August 30, 1997