/*----------------------------------------------------------------------------
Copyright © 1998 Object International Software Ltd
----------------------------------------------------------------------------*/
package oisoft.togetherx.scripts;
import java.io.*;
import oisoft.togetherx.scriptapi.Script;
import oisoft.togetherx.scriptapi.ScriptResources;
import oisoft.togetherx.scriptapi.APIManager;
//------------------------------------------------------------------------------
/**
* Simple example for Script - write "Hello World!" to output stream
* @version 2.1.02 28.04.1998
* @author Andrei Ivanov
*/
public class Hello_World implements Script, ScriptResources
{
//------------------------------------------------------------------------------
public String getMenuItem() {
return "Hello World...|E";
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
public void doIt (APIManager apiManager) {
try {
if (!apiManager.customize(this, "Hello World")) return;
if (myWriteToStream) {
String outputStreamName = apiManager.getOutputStream(".txt");
if (outputStreamName == null) return;
PrintWriter outputStream =
new PrintWriter( new FileOutputStream(outputStreamName));
outputStream.println(myMessage);
outputStream.close();
apiManager.openExternalViewer(outputStreamName);
}
else {
System.out.println(myMessage);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
public String getMessage() {
return myMessage;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
public void setMessage(String value) {
myMessage = value;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
public boolean isWriteToStream() {
return myWriteToStream;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
public void setWriteToStream(boolean value) {
myWriteToStream = value;
}
//------------------------------------------------------------------------------
private boolean myWriteToStream = true;
private String myMessage = "Hello World!";
};
//------------------------------------------------------------------------------
|