<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.gnustep.org/index.php?action=history&amp;feed=atom&amp;title=Script_objects</id>
	<title>Script objects - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.gnustep.org/index.php?action=history&amp;feed=atom&amp;title=Script_objects"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.gnustep.org/index.php?title=Script_objects&amp;action=history"/>
	<updated>2026-04-20T17:56:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.7</generator>
	<entry>
		<id>https://mediawiki.gnustep.org/index.php?title=Script_objects&amp;diff=1907&amp;oldid=prev</id>
		<title>Stefan Urbanek at 12:26, 18 February 2005</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.gnustep.org/index.php?title=Script_objects&amp;diff=1907&amp;oldid=prev"/>
		<updated>2005-02-18T12:26:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Script object looks like ordinary object. However, it's behaviour is described by small scripts - methods written in some scripting language.&lt;br /&gt;
&lt;br /&gt;
They can be used for:&lt;br /&gt;
&lt;br /&gt;
* Custom application objects&lt;br /&gt;
* Event and notiication handlers&lt;br /&gt;
* Objects in servers with customisable behaviour&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
''NOTE: See TODO list at the end of this page.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using script objects ==&lt;br /&gt;
&lt;br /&gt;
Just send it a message as to any other object:&lt;br /&gt;
&lt;br /&gt;
 [object sayHi];&lt;br /&gt;
&lt;br /&gt;
== Creating script objetcs ==&lt;br /&gt;
&lt;br /&gt;
 object = [STScriptObject scriptObject];&lt;br /&gt;
 [object setEnvironment:someScriptingEnvironment];&lt;br /&gt;
&lt;br /&gt;
=== Adding methods ===&lt;br /&gt;
&lt;br /&gt;
Create a source:&lt;br /&gt;
 source = @&amp;quot;sayHi Transcript showLine: 'Hi.'. ^self&amp;quot;.&lt;br /&gt;
or&lt;br /&gt;
 source = [NSString stringWithContentsOfFile:@&amp;quot;SomeFile&amp;quot;];&lt;br /&gt;
&lt;br /&gt;
Get the the proper engine for a language used in the source:&lt;br /&gt;
&lt;br /&gt;
 engine = [STEngine engineForLanguageWithName:@&amp;quot;Smalltalk&amp;quot;];&lt;br /&gt;
&lt;br /&gt;
create a method:&lt;br /&gt;
&lt;br /&gt;
 method = [engine methodFromSource:source&lt;br /&gt;
                       forReceiver:object&lt;br /&gt;
                     inEnvironment:Environment];&lt;br /&gt;
&lt;br /&gt;
and finally add the method to the object:&lt;br /&gt;
&lt;br /&gt;
    [object addMethod:method];&lt;br /&gt;
&lt;br /&gt;
=== Methods with arguments ===&lt;br /&gt;
&lt;br /&gt;
Well, no difference to any other methods. If you have source:&lt;br /&gt;
&lt;br /&gt;
 source = @&amp;quot;sayHiTo:someone Transcript showLine: ('Hi ', someone). ^self&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
you can do:&lt;br /&gt;
&lt;br /&gt;
 [object sayHiTo:@&amp;quot;World&amp;quot;];&lt;br /&gt;
&lt;br /&gt;
=== Script object interface ===&lt;br /&gt;
&lt;br /&gt;
Script object understands following:&lt;br /&gt;
&lt;br /&gt;
* addMethod:aMethod&lt;br /&gt;
* removeMethod:aMethod&lt;br /&gt;
* removeMethodWithName:aString&lt;br /&gt;
* methodWithName:aString&lt;br /&gt;
* methodNames&lt;br /&gt;
* respondsToSelector:aSelector&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
&lt;br /&gt;
Here are unimplemented features of the Script Objects. Feel free to add them, if you have a bit of time. Please consult with the [[User:Stefan Urbanek|author of StepTalk]] and on the [[Contact|gnustep lists]].&lt;br /&gt;
&lt;br /&gt;
* object variables (this is high priority)&lt;br /&gt;
* inheritance of variables and methods (traits like in Self?)&lt;br /&gt;
* object archiving&lt;br /&gt;
* object cloning (copying)&lt;br /&gt;
&lt;br /&gt;
* integration with [[Scripting context|scripting contexts]]&lt;br /&gt;
&lt;br /&gt;
* script object builder application (it should be something simple)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
See also: [[StepTalk]], [[Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Stefan Urbanek</name></author>
	</entry>
</feed>