Using Default Interface Descriptions
If there is no public_description object defined in the scriptlet, the scriptlet container object exposes properties and methods using variables and functions in the scriptlet that follow certain naming conventions. To expose scriptlet properties and methods, use these conventions:
- Use the prefix public_ to indicate that a variable or function should be exposed by the scriptlet.
- To create a read/write property, declare a variable scoped at the page level (that is, not defined inside a function) and give it a public_ prefix.
- To create a method, define a function with the prefix public_.
- To create a readable property as a function, define a function with the prefix public_get_.
- To create a writable property as a function, define a function with the prefix public_put_.
Note When a property or method is exposed, its name in the host application does not have the public_ prefix. For example, if you define a property called public_MyTitle in the scriplet, its name in the host application is MyTitle.
The following table shows examples of variables and functions in a scriptlet and the resulting interface that they expose in the host application.
Example | Exposed As | Used in container |
var public_Color = "red" | Property | vColor = SC1.Color SC1.Color = "blue" |
function public_look(param) | Method | SC1.look(param) |
function public_get_C() | Property (read) | x = SC1.C |
function public_put_C(param) | Property (write) | SC1.C = "test" |
function look() | Not available (no public_ prefix) | |
function get_C() | Not available (no public_ prefix) | |
var Color = red; | Not available (no public_ prefix) | |
var get_Color = red; | Not available (no public_ prefix) |
The following example shows a portion of a page containing a paragraph named "P1". The script block following the paragraph exposes a property called P1Text and a method called SetText.
<P ID=P1>This is a paragraph of text.</P> <SCRIPT LANGUAGE="JavaScript"> <!-- public_P1Text = P1.innerText function public_SetText(newText){ P1.innerText = newText; } // --> </SCRIPT>
The scriptlet reserves the function name prefixes public_get_ and public_put_ to define properties. For example, if the scriptlet contains a function named public_get_MyText, it will be treated as a property called MyText. If you attempt to call the function public_get_MyText as a method using the syntax SC1.get_MyText(), an error will result, because the function itself is exposed only as if it were a property named MyText.
See Also
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.