JSP-Generator
To use JSP-Generator you need a basic knowledge about the syntax of the Javasketchpad applet.
You can get this information at Key Curriculum Press
It is advised that you get yourself a copy of the JSP Construction Grammar that can be found at this website.
How to use JSP-Generator to generate JSP-files
Consider the following example from Key Curriculum Press' website.
For instance, the following text specifies a dynamic triangle with vertices initially positioned at (144, 130), (24, 130), and (84, 20) in the coordinate plane:
{1} Point (144,130);
{2} Point (24,130);
{3} Point (84,20);
{4} Segment (3,1) [thick];
{5} Segment (1,2) [thick];
{6} Segment (2,3) [thick];
In JSP-Generator this becomes:
a=Point(144,130,'')
b=Point(24,130,'')
third=Point(84,20,'')
Segment(third,a,'thick')
Segment(a,b,'thick')
Segment(b,third,'[thick]')
In JSP you reference by number to an element in your construction. This number is the line number of that element. When you are editing your construction you may not insert a line: all references have to be updated. In JSP-Generator you reference by a unique name, a variable (a variable name starts with a character, after that character are allowed: more characters, digits or underscores _). The optional format string ([thick] in this case) is moved inside the brackets. JSP-Generator allows you to leave out the square brackets but you may also use them. When you don't need a construction to be referenced by another construction it is not necessary to use a variable.
A list of construction names can be found in the file help.htm
Special cases
- Some JSP constructions need a list of variable length. Such a list of variable length should be placed inside square brackets. For instance
ShowButton(5,10,'Show Triangle')(1,2,3)
In JSP-Generator this becomes:
ShowButton(5,10,'Show Triangle',[1,2,3],'')
Constructions involved are Buttons, Locus and Polygon.
- The name of some JSP constructions contains characters that make the name an invalid Javascript identifier. For instance: Point on object, Origin&Unit, Ratio/Points.
If the invalid character is a space character it is replaced with an underscore(_), otherwise it is simply omitted: Point_on_object, OriginUnit, RatioPoints.
Predefined extensions
Besides the existing JSP constructions there are a number of predefined extensions that generate a sequence of JSP constructions: PerpendicularBisector, Circle3Points, InscribedCircle,AngleBisector and AngleBisector2,Arc and Arc2, Parabola, Ellipse_Hyperbola,Bezier, graph and graph2,pie.
More information can be found in the file help.htm
Technical information
All JSP constructions are defined in the external Javascript file common.js. All extensions are defined in the external Javascript file extensions.js. Both JSP constructions and extensions are defined as Javascipt functions that generate the necessary strings to generate the construction (they provide a variable construction and a variable line number) and return the line number of that construction.
Those two external files make it possible to write a Javascript program that generates the construction.
Two such programs are provided: Bezier and JSP-Generator itself. Bezier shows the construction of Beziercurves. JSP-Generator allows you to make constructions by means of scripts. Those scripts are edited in the upper window. By pressing Convert the JSP-construction is generated. By pressing Show the construction can be made visible.
Advanced features of JSP-Generator
The scripts you write in the upper window of JSP-Generator may contain pure Javascript. You can even define new functions, use conditional (if) statements, use loops in these scripts. All features of Javascript are allowed. Example 3 and Example 4 show some of the possibilities.
Browser dependent features
- Automatic code checking.
Consider the following script:
a=Point(100,100,"[label('A')]")
goal=Point(200,200,"[label('goal')]")
MoveButton(10,10,10,"'Move'",[goal,a],'[green]')
Dependent on the possibilities of your browser this can be shortened to:
a=Point(100,100,"label(A)")
goal=Point(200,200,'label(goal)')
MoveButton(10,10,10,'Move',[goal,a],'green')
Even some "errors" are corrected:
a=Point(100,100,"[label('A)") might be corrected.
Try and see what your browser allows.
- Saving and loading scripts to your hard disk
Recent versions of Internet Explorer (5 and better) allow Javascript to access your harddisk. In Explorer buttons will show that offer that possibility. If those buttons do not work (you get an error message) it might be helpful to change the settings in the safety tab of the internet options. Look for ActiveX elements. Change the setting to "Ask". In Netscape those buttons will not appear.