npStrs plugin

About this plugin

This plugin is an implementation of one of the most used classes in the Delphi world: TStringList. This class is useful in various ways and, basically, maintain string lists on memory that you can manipulate using the appropiate actions.

You can maintain strings list allowing duplicated or not, search for strings, add, append, insert, delete; use pairs of names and values, get or set the whole text delimited or not, saved and load strings to/from files, get advised when the strings changes...

You can sort the string lists, and maintain sorted in memory (even when add new items), can specify the delimiter and quote character, for example, in order to import/export information from CSV (Comma Separated Values) or similar files and many more.

Thirparty

This plugin are imposible without the aid of this people:

Thanks a lot!

Plugin actions index

npStrsCreate

Create a new Strs object instance. The result variable store the numeric object identifier wich you need to use with other plugin actions.

↑↑

npStrsDestroy

Destroy a previosly created Strs object instance. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsDestroyAll

Destroy all previosly created Strs object instances.

↑↑

npStrsGet

Get a string item from a Strs object based on the item index. The result variable store the string item if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsAdd

Add a new string item to a Strs object and get the inserted item index. If you dont need the item index as result, then use npStrsAppend. The result variable store the new string item index if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsAppend

Append a new string item to the end of a Strs object. If you need the inserted item index, use the npStrsAdd. The result variable store the string item if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsInsert

Insert a new string on a Strs object at the specified index position. You cannot use this action when deal with sorted string lists. Use npStrsAdd or npStrsAppend instead. See also npStrsSorted. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsCount

Retrieve the number of items currently stored on a Strs object. The result variable store number of items on the Strs object if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsClear

Clear all strings stored on a Strs object. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsDelete

Delete an string from an Strs object instance. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsExchange

Rearrange the strings of an Strs object. The strings are specified by their index values in the first index and second index arguments. Indexes are zero-based, so the first string in the list has an index value of 0, the second has an index value of 1, and so on. Do not use this action on a sorted list. Exchange does not check whether the list is sorted, and can destroy the sort order of a sorted list.

The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsGetText

Get the content of a Strs object as a whole text. The result variable store the Strs object strints as a whole text if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsSetText

Set the content of a Strs object as a whole text. Note that carriage returns plus line feed is taken as a new item for the Strs object. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsDuplicates

Determine how the Strs object deal with duplicates strings. Note that the duplicates behaviour only work with sorted Strs objects, see npStrsSorted. The possible values for the duplicates variable are:

Note also that you need to execute this action before add any string to the Strs object: the strings stored on the Strs object is not tested for duplicates. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsSort

Sort the strings of a Strs object. Just sort the strings containing on a Strs object. Dont get confuse with the npStrsSorted action. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsSorted

Set if a Strs object stored their items sorted or not. Determine if the strings list of a Strs object is maintained sorted or not. If you set this to "True", then, any strings that you add or append to the list is automatically sorted on the list. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsIsSorted

Find if the Strs object strings are sorted stored or not. See npStrsSorted. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsFind

Find if a sorted Strs object contain the provided string or not. The index variable store the strings item index if found. The result variable store "True" if the strings is found on the list, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsEquals

Find if a Strs object have the equals items than another. The result variable store "True" if the strings of one list are equals that another list, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsIndexOf

Get the index position of the first occurrence thas matches the provided string. The result variable store the index of the string item or "-1" if are not found on the Strs object, or "False" if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsIndexOfName

Find the first occurrence of a name in a Strs object that store names and values pairs. Then you save on a Strs object strings that are pairs of names and values (see npStrsPairsSep) you can use this action to find the index of a concrete name instead of npStrsIndexOf.

The result variable store the index of the name or "-1" if are not found on the Strs object, or "False" if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsName

Get a string name stored on a Strs object when use it to store names and value pairs. The result variable store the name when found or nothing when not, or "False" if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsGetValue

Get a string value stored on a Strs object when use it to store names and value pairs. The result variable store the appropiate string value if found or nothing when not, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsSetValue

Set a string value stored on a Strs object when use it to store names and value pairs. The result variable store "True" if everyhing is OK, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsPairsSep

Set the separator for names and values, for the case case you use the Strs object as a list of names and values. This separator must be only one char. By default the pairs of names and values separator is "=" (an equals sign). The result variable store "True" if everyhing is OK, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsQuoteChar

Set the quoted char used in Strs object to enclosed individual string when set delimited text. This quote must be only one char. By default the quoted char is " (a double quote). The result variable store "True" if everyhing is OK, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsDelimiter

Set the delimiter char used when get or set a Strs object delimiter text. This delimiter must be only one char. By default the delimiter "," (a comma). The result variable store "True" if everyhing is OK, or "False" if not, and if an error occur, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsGetDelimitedText

Get the text of a Strs object as delimited text. The result variable store the Strs text delimited if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsSetDelimitedText

Set the text of a Strs object as delimited text. If you dont want to use the default quoted char and delimited text separator, use the appropiate plugin actions to change this. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsToFile

Save the content of a Strs object to a file. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npStrsFromFile

Load the content of a file into an Strs object instance. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npOnStrsChange

Set a subroutine to be executed just after a Strs object has change. The Instance ID variable store the ID of the Strs object that fire the event. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also the [LastError] contain information about the error.

↑↑

npOnStrsChanging

Set a subroutine to be executed just before a Strs object has change. The Instance ID variable store the ID of the Strs object that fire the event. The result variable store "True" if everything is OK, or "False" if not, for example, if no one object is found with the provided ID. In this last case also 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.

↑↑