===============================================================================

Sleipnir built-in Script Reference

                                            Copyright (C) 2005-2009 Fenrir Inc.
                                                                     2006/05/28
                                                                                                                                   Anglicized by S.K.  08/03/07
===============================================================================

You can use built-in Script to mount UserAction Extension or Sleipnir functions.
Sleipnir built-in Script doesn't use WSH and work at main thread; so, it run
very fast and it's safe.

You need to install UserAction Extension to run your Script.
You can run your Script as action if you put your script at plugins/script
folder.


-------------------------------------------------------------------------------
* Grobal Variable
-------------------------------------------------------------------------------

ISleipnir sleipnir;
IHTMLWindow2 _window;
IHTMLDocument2 _document;


-------------------------------------------------------------------------------
* Interface
-------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////
// Sleipnir Interface

interface ISleipnir {
	/// Sleipnir.API (Need to register registry.)
	IAPI API;

	/// Database Interface(R)
	IDatabaseManager Database;

	///  Interface(R)
	IOutput Output;

	/// States Bar Message(W)
	string Status;

	/// ScriptnameR(Full Path)(R)
	string ScriptFullName;

	/// Scriptname(R)
	string ScriptName;

	/// User Setting Folder
	string UserFolder;

	/// Version Number(R)
	long BuildVersion;

	/// Version Number(R)
	string Version;

	/// Language Setting(R)
	string Language;

	/// Script invoker(R)
	string Sender;

	/// Generate Referemce Object
	IByRef ByRef();

	/// Create automation object
	IUnknown CreateObject( string ProgID );

	/// Sleep
	void Sleep( long ms );

	/// Beep
	void Beep();

	/// Display Alert dialog
	void Alert( string prompt );

	/// Output
	void Echo( string text );

	/// Run Built-in Script
	bool RunScript( string file );

	/// Run Built-in Script with function (One argument)
	bool RunScriptEx( string file, string function[, VARIANT arg] );

	/// Open File (mode="r" | "w") (2.4x or higher)
	IFile OpenFile( string fileName, string mode );

	/// Load letter string from StringTable of resource (2.4x or higher)
	string LoadString( string filename, string key );
};


///////////////////////////////////////////////////////////////////////////////
// Output Interface

interface IOutput {
	/// Visible or unvisible (R/W)
	bool Visible;

	/// selected position (R/W)
	long Selection;

	/// Clear
	void Clear();

	/// Add string
	void Print( string text );
};


///////////////////////////////////////////////////////////////////////////////
// Call by reference Interface

interface IByRef {
	/// Prorate Data
	void PutObject( VARIANT var )

	/// Get Data
	VARIANT GetObject();
};


///////////////////////////////////////////////////////////////////////////////
// Database Interface

interface IDatabaseManager {
	/// Open Database
	IDatabase Open( string name );

	/// Delete Database
	bool Delete( string name );
};


///////////////////////////////////////////////////////////////////////////////
// Database Object Interface

interface IDatabase {
	/// Run SQL sentence
	/// Return IResult When SELECT
	IResult Query( string strSQL );
};


///////////////////////////////////////////////////////////////////////////////
// SQL Result Interface

interface IResult {
	/// Return linage
	long NumRows();

	/// Return covey and go forward reference position.
	IArray FetchArray();

	/// Return covey
	IArray Current();

	/// Return Field name
	string FieldName( long column );

	/// Check next data is available or not.
	bool HasMore();

	/// Return Field numbers
	long NumFields();

	/// Rewind reference position to head.
	void Rewind();

	/// Change reference position
	long Seek( long index );
};


///////////////////////////////////////////////////////////////////////////////
// Array Interface

interface IArray {
	/// Get Array Data
	VARIANT At( long index );

	/// Return Array size.
	long Size()
};


///////////////////////////////////////////////////////////////////////////////
// File Interface(2.4x or higher)

interface IFile {
	/// Write string to File
	void Write( string str );

	/// Read one line from file (delete line break.)
	string ReadLine();

	/// Close
	void Close();
}

