# Ranko Bojanic's Home Page

The main purpose of this page is to make available to interested people programs and source code for Macintosh PPC computers I have written using CodeWarrior Pro 4 Pascal and Fantasm 6.0 FC3 programming languages. CodeWarrior Pro 4 can be obtained from Metrowerks. Note that CodeWarrior Pro 5 does not support Pascal programming. Fantasm can be obtained from Lightsoft.

Most of my Pascal programs deal with user-friendly, inter-active, versions of various classical approximation-theoretical algorithms. For more Macintosh Pascal programs see the Pascal Central web site.

Fantasm programs were written while I was trying to learn Macintosh PPC assembly language. Invaluable help of people who have created Fantasm, especially Stuart Ball's, is gratefully acknowledged. In these projects beginners can find a lot of information about Macintosh tool-box based PPC assembly language programming. For more information about Fantasm see Lightsoft's web site.

Warning: ALL the files here are for Macs. IBM people should not download anything. IBM people should get a Mac.

#### CodeWarrior Pro 4 Pascal programs

• Remez Algorithm program implements the well known Remez Algorithm for the construction of polynomials of best approximation to a continuous function on a finite interval [a,b].
• General Chebyshev Polynomials program provides a simple algorithm for the solution of the following problem: Find x(1),....x(n) in [a,b] and a polynomial P of degree <= n-1 such that P(x(i)) = y(i) for i = 1,...,n, P'(x(i)) = 0 for i = 2,...,n-1. The problem was formulated in a 1956 issue of the American Mathematical Monthly by C.Davis (Problem 4714).It was solved in 1960 by J.Mycielski and S.Paszkowsky. When y(k) = (-1)^(n-k) the polynomial P is clearly the Chebyshev polynomial of the first kind of degree n-1 for the interval [a,b].

#### CodeWarrior Pro 7 Carbon Pascal programs

• My List is a simple list demo application. It shows how list updates are handled in Carbon Pascal.

#### Fantasm projects

• Hello World. This is a classical Hello World program with the addit ion of the date and time display. My Demo Alert Box and My Demo Dialog Box have been copied from the original Fantasm demo Chapter 7 . Actually, most of this program, as well as a large number of other Fantasm programs I wrote, have been copied or adapted from the Chapter 7 project. This program may be useful to people who wish to display the current date and time in their programs.
• Mini Plotter program draws graphs of mathematical functions. In addition to components of a standard Macintosh application such as windows, edit fields, buttons, menus and dialogs, it shows how a string defining a function can be converted to Reverse Polish Notation and how that representation can be used for the evaluation of the function.
• Hide Menu Bar This project is based on Bill Catambay's Pascal program Hide Menu Bar which can be found at Pascal Central web site. Routines hide_mbar and restore_mbar handle not only hiding and restoring of the menubar, but also of the control strip if it is visible.
• Screen Saver. A variant of the two dimensional random walk is used as a first step in the design of a true screen saver. A useful routine in this project is the one which shows how to hide and show menu bar. For a simpler environment for that routine see the project Hide Menu Bar. To maintain a constant speed of drawing of random paths on machines with different speeds, precise delay loops have been inserted in drawing routines.
• True Screen Saver is an application that runs in two different modes. It starts in a passive mode, without opening a window, and starts counting time. If a key is pressed or the mouse moved, it restarts the count. After a certain period of inactivity the program jumps into the active, screen saving mode. It opens a window and draws random paths until a key is pressed or the mouse moved. Then it hides the window and goes into the passive mode and starts counting time again.
• OSA Runner program shows how to run a compiled AppleScript program from within a Fantasm application. See Read Me file for more details.
• Micros Overhead program shows how to measure time intervals using Microseconds and TickCount. It can be used to measure time in microseconds necessary for the execution of any tool-box command. It also shows how to design loops of constant time length, independent of the computer's speed.
• Evaluation of Sines illustrates the use of MathLib shared library and floating point registers for the evaluation of mathematical functions. It also illustrates the use of edit fields and buttons. It contains routines for the conversion of strings into floating point numbers and routines for the display of floating point numbers on the screen.
• Edit Field and Buttons Demo shows how to set up edit fields and buttons in an application. Any text can be typed into the edit field. When Print Text button is pressed, the program reads the content of the edit field into a string and prints it below the edit field. The Clear button erases the printed text.
• GWorld Demo is a simple project which shows how to create and use gworlds and CopyBits in your Fantasm programs. It is very similar to a program posted by Ian Mann on the Future Basic list.
• The world of RGB colors. This page contains Fantasm programs related to color of geometric objects in the RGB cube. To each point (x,y,z) of the RGB cube we assign the RGB color ([65535*x],[65535*y], [65535*z]). In this way the color of any segment can be determined. Once the color of a segment is available, it is possible to find the color of any geometric object generated by segments. As special cases the color of any traingle and the colors of 6 faces of the RGB cube are displayed. One can look at problems of this type as linear color interpolation problems:
(i) Given the colors of the end-point of a segment, find the color of any point on that segment.
(ii) Given the colors of three points A,B,C of a triangle, find the color of any point inside the triangle.

#### Carbon Fantasm projects

• Traffic Lights demo shows how to construct windows and menus in Carbon Fantasm. It shows also how to write the transition vector and the universal procedure pointer for the Apple Event "quit" routine and how to install the corresponding Apple Event handler. For the handling of Apple Events in Fantasm I am grateful to Mr. Ajay Nath and his demo SimpleCarbonApp. The handling of events in the project Traffic Lights is based on the classical WaitNextEvent loop.

#### My favorite links:

 National Debt Clock

Please send comments or questions to Ranko Bojanic ( bojanic@math.ohio-state.edu).
Number of visits since April 24, 2001: