Shiny Language Reference

Language Reference > Basic Functions


getselfname

string getselfname();

 

 

Returns the current filename of the plugin

This statement returns the current filename of the SSE plugin. This is useful if you want to load multiple instances of your plugin and any kind of persistant data is required. For example, if the plugin must download a random image from a website then there are no problems when one instance of the plugin is running. However if the plugin is duplicated and copied to the SSE directory, there will be 2 copies of the same plugin that may use the same destination filename for the download. If both plugins were loaded at the same time, one download would overwrite the other.

To prevent this issue, GETSELFNAME returns the current filename of the plugin. This name can then be used to make sure any temporary resources are unique to this instance of the plugin, for example by prefixing any files saved to disk with the filename of the plugin. This works because no 2 files can be named the same, and all SSE's must reside in the same directory, therefore GETSELFNAME is guaranteed to return a unique name.

This statement was intended for use with plugins that have multiple uses with minor changes. An example would be an RSS feed reader, which can read multiple feeds simply by changing the URL it retrieves the feed from. Rather than coding multiple, different versions of the RSS reader code, the same code can be used and GETSELFNAME can be used to ensure compatibility with any other plugin that uses the same code.

 

Parameters

None

 

Return Value

The current filename of this plugin instance, excluding the path.

 

Example Code

// Assuming this code is running inside Myplugin.sse,
// Filename will contain "Myplugin.sse"
string Filename = getselfname();

// Sample usage, image will be saved to "Myplugin.sse_image.gif"
webdlfile("http://some.site.com/image.gif", Filename + "_image.gif");