npFile plugin

About this plugin

This plugin allow you to work with files in an advanced mode, allowing, for example, to open share exclusive files, which can be only read or write from your publication and not for others while the file are in use.

You can create the File objects instances that you need. Every File instance allow you to create, read and write files, in a share exclusive mode or others. The plugin allow you to read or write the files byte by byte and more.

Thirparty

This plugin are imposible without the aid of this people:

Thanks a lot!

Plugin actions index

npFileCreate

Create a new File object instance. You need to specify the file path to associate to the File object instance, the open mode and the share mode. The result variable store the ID of the File object instance, or "False" if an error ocurr. In this last case the [LastError] contain information about the error.

The open mode argument can be one of the following values:

The share mode argument can be one of the following values:

↑↑

npFileDestroy

Destroy a previosly created File object instance. Specify the File object instance ID in order to free from the memory. This action also "close" the file handle, opened when create the File object instance. The result variable store "True" if everything is OK, or "False" if an error ocurr. In this last case the [LastError] contain information about the error.

↑↑

npFileDestroyAll

Destroy all previosly created File object instances.

↑↑

npFileRead

Read the count of bytes from the current cursor file position in a File object instance. Use this action to read data from the File object instance. Read transfers up to Count bytes from the stream, starting at the current position, and then advances the current position in the stream by the number of bytes actually transferred.

The Bytes Transferred variable store the number of bytes actually transferred, which may be less than Count if the end of file marker is encountered. The result variable store the content readed from the file stream or "False" if an error ocurr. In this last case the [LastError] contain information about the error.

↑↑

npFileWrite

Write content to a previously created File object instance. Use this action to write data to the File object instance, starting at the current position. After writing to the stream, this action advances the current stream position by the number of bytes written. The result variable store the number of bytes writen or "False" if an error ocurr. In this last case the [LastError] contain information about the error.

↑↑

npFileSeek

Move the current stream position of a File object instance. Use this action to move the indicated offset the current position within the stream associated with the specified File object instance. This allows an application to read from or write to a particular location within the File. The Origin argument indicates how to interpret the Offset argument. Origin should be one of the following values:

The result variable store the new value of the stream position, the new current position in the stream or "False" if an error ocurr. In this last case the [LastError] contain information about the error. See also npFileSetPos.

↑↑

npFileGetPos

Get the current stream position of a File object instance. The result variable store the current stream position of the specified File object instance or "False" if an error ocurr. In this last case the [LastError] contain information about the error.

↑↑

npFileSetPos

Set the current stream position of a File object instance. The result variable store the new position of the stream in the specified File object instance or "False" if an error ocurr. In this last case the [LastError] contain information about the error. See also npFileSeek.

↑↑

npFilePath

Get the file path associated with the specified File object instance. Remember you need to indicate a file path when you create a new File object instance. This action allow you to retrieve this path in the result variable, which can contain "False" if an error ocurr. In this last case the [LastError] contain information about the error.

↑↑

npFileBytes

Get the file bytes (size) associated with the specified File object instance. The result variable store the size in bytes of the current File object instance or "False" if an error ocurr. In this last case the [LastError] contain information about the error.

↑↑

Action errors subroutine

All the NeoPlugins deal with errors in the same way that NeoBook does: when the plugin found an action error the [LastError] variable store information about the error, so you can take care about this variable when execute an action.

But all the NeoPlugins also incorporate an advanced way to deal with possible action errors. You can define a subroutine named OnNeoPluginActionError in order to be executed when some action error are found and you can use this variables inside:

Note that this error handling subroutine are shared for all the NeoPlugins, so you no need to specify a subroutine for every plugin you use in your publication because the same subroutine are recognized and automagically used by every NeoPlugin. Below you can view a sample of this subroutine code:

:OnNeoPluginActionError
  AlertBox "NeoPlugin Error" "Error [LastError] in plugin: [PluginName]"
Return

Also note that the use of this NeoPlugins error handling subroutine is completelly optional. You can continue using the [LastError] variable as usual and even use the both methods at the same time.

↑↑