
The cT Programming Language Version 3.0 Created by David Andersen, Bruce Sherwood, Judith Sherwood, and Kevin Whitley Center for Innovation in Learning Carnegie Mellon University Pittsburgh http://cil.andrew.cmu.edu/ct.html 1 Contents 1. THE CT PROGRAMMING LANGUAGE.................................................... 4 cT Menu Options............................................................................................ 11 Additional Language Aspects ............................................................................. 17 2. GRAPHICS & TEXT.............................................................................. 3 2 Basic Graphics & Text Commands....................................................................... 34 Describing the Screen................................................................................................................... 34 Displaying Text and Variables......................................................................................................... 39 Lines, Circles, Boxes, Etc. ............................................................................................................. 52 Mode, Pattern, Thick, Cursor, & Clip.................................................................. 60 Inhibit and Allow in Graphics............................................................................ 65 Color.......................................................................................................... 71 Images......................................................................................................... 88 Animations................................................................................................... 98 Making a Graph ............................................................................................102 Relative Graphics Commands............................................................................112 3. VIDEO & SOUND............................................................................... 117 Video Commands...........................................................................................117 4. MOUSE & KEYSET INTERACTIONS.................................................. 124 Mouse, Single Key, & Timed Pause....................................................................125 Pull-down Menus...........................................................................................136 Buttons, Dialog Boxes, Sliders, & Edit Panels ......................................................142 Scrolling Text Panels .....................................................................................149 Word & Number Input.....................................................................................158 Basic Judging Commands.............................................................................................................159 Modifying Judging Defaults...........................................................................................................169 Inhibit and Allow in Judging...........................................................................................................177 Specialized Judging Commands ...................................................................................................181 2 5. CALCULATIONS................................................................................ 187 Defining Variables.........................................................................................190 Basic Calculational Operations..........................................................................200 Array Operations ...........................................................................................208 IF, CASE, and LOOP .....................................................................................215 Random Variables..........................................................................................221 6. CONNECTING UNITS & PROGRAMS ................................................ 223 Units -- Program Subdivisions ..........................................................................223 Moving between Main Units.............................................................................237 Connections to Other Programs .........................................................................241 7. CHARACTER STRINGS..................................................................... 246 Basic Marker Operations..................................................................................248 Marker Commands .........................................................................................259 Marker Functions ..........................................................................................264 Some Examples with Markers ...........................................................................277 8. FILES, SERIAL PORT, & SOCKETS .................................................. 285 File Handling Commands.................................................................................289 Socket Commands..........................................................................................311 9. SYSTEM VARIABLES........................................................................ 318 System Variables for Graphics and Mouse ............................................................321 Other System Variables...................................................................................329 INDEX.................................................................................................... 338 3 INTRODUCTION 1. The cT Programming Language Purpose of cT This is a print version of the on-line help for cT 3.0 (August 1999). See the on-line help on the Window menu for updated information, and a history of previous versions. Also see http://cil.andrew.cmu.edu/ct.html. The cT programming language is an algorithmic language like C, Pascal, Fortran, and Basic, but greatly enhanced by multimedia capabilities, including easy-to-use support for color graphics, mouse interactions, and even movies in QuickTime or Video for Windows format. The cT programming language offers easy programmability of multimedia programs, with portability across Macintosh, Windows, and Unix. The cT programming environment offers on-line help with executable program examples, a graphics editor for automatic generation of graphics commands, incremental compiling to provide rapid turnaround, and detailed error diagnosis. When is cT the right tool? There are many excellent applications available for creating pictures and diagrams, and for making multimedia presentations, without having to write your own computer program. However, it is sometimes the case that doing something really new and different is hard to do with these nonprogramming applications, because they often don't provide enough control of interactions and enough calculational capability to do what you really want to do. cT offers the open-ended flexibility and power associated with programming languages but eliminates many of the difficulties and complexities usually associated with using a programming language. Credits cT has been developed in the Center for Innovation in Learning at Carnegie Mellon University in Pittsburgh by David Andersen, Bruce Sherwood, Judith Sherwood, and Kevin Whitley. cT is a trademark of Carnegie Mellon University. Special thanks to: Andrew Appel, Bill Arms, Steven Bend, Ruth Chabay, Preston Covey, Andy van Dam, Ken Friend, Fred Hansen, Stacie Hibino, Chris Koenigsberg, Peter Kornelisse, Jay Laefer, Jill Larkin, Michael LoBue, David Madden, Gregg Malkary, Ben McCurtain, Jim Morris, Tom Neuendorffer, Tom Peters, Carol Scheftic, and David Trowbridge. License information cT is a copyright © Carnegie Mellon University, 1989, 1992, 1995, 1999. Permission to reproduce and use cT for internal use is granted provided the copyright and "No Warranty" statements are included with all reproductions. cT may also be redistributed without charge provided that the copyright and "No Warranty" statements are included in all redistributions. 4 NO WARRANTY. cT IS FURNISHED ON AN "AS IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY OF RESULTS OR RESULTS OBTAINED FROM USE OF cT. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK OR COPYRIGHT INFRINGEMENT. An Example Program Given below is a short program written in cT. This program illustrates graphics, rich text, animation, and mouse interactions. Copy the example into the start of the program window (after the $syntaxlevel line). Execute the program by choosing "Run from beginning" on the Option menu. Click the button; draw in the box; use the pull-down menu to clear the box. Change the size of the window and see how the program starts all over again. (On a Macintosh, drag the lower-right corner of the window; no drag box is shown.) To stop, choose "Quit running" from the Option menu, which does not quit cT. After running the program, read through the program carefully, one line at a time, to see how the effects are achieved. You may want to look up detailed information on individual commands. Try changing the program and running it again. Be sure to read the next topic, "Further Discussion". Example program to be copied, down to "End of example program": unit cTexample * (An asterisk * at the
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages351 Page
-
File Size-