Page 1 of 1

More array functions

PostPosted: Fri Aug 22, 2014 1:13 am
by Tony Kroos
It would be nice to have more array functions, such as Insert, Delete items, Clone (duplicate) array, Set upper|lower bounds, ReDim, etc... It would be looking like this:

ArrayInsert "[ArrVariable]" "[Index]" "[Data]" - insert item and shift array indexes
ArrayDelete "[ArrVariable]" "[Index]" - delete item and shift array indexes
ArrayErase "[ArrVariable]" - deletearray
ArrayCopy "[ArrVariable]" "[NewArrVariable]" - copy array into new array
ArrayGet "[ArrVariable]" "[UppBound]" "[LowBound]" "[ArrCount]" - getarrayinfo
ArraySet "[ArrVariable]" "[UppBound]" "[LowBound]" "[ArrCount]" - some kind of redim with preserving data
ArraySort "[ArrVariable]" "ASCEND / DESCEND" - sort array (as string data)
ArrayFind "[ArrVariable]" "[DataToSearch]" "[ItemIndex]" - returns item index (0 if no hits) or array of indexes (if multiple hits)

and (imho) it looks more "professional" and comfortable than manipulating with hidden listbox and additional plugins, isn't it?

Re: More array functions

PostPosted: Fri Aug 22, 2014 10:09 am
by Gaev
Tony Kroos:

1) Not sure if HPW, dec or David de Argentina already have such functionality within one their plugins.

2) Javascript has a rich set of "array processing methods" ... so one could build a NeoBook Function Library whose functions (written in Javascript) can be Call'ed from any of your publications.

However, since I don't see a method of passing NeoBook Array Variable to such Functions, one would have to do an "Array to Delimiter Separated String" conversion ... and pass the String to the (javascript) Functions.

This can be done with native NeoBook Actions inside a Loop/EndLoop block ... but might take long for huge arrays.

Would be nice to have a native NeoBook command for this ... like ...
Code: Select all
ArrayToString "array name" "start index" "end index" "item delimiter" "string variable"

ArrayToString "[country]" "1" "999999" "!@#$%^" "[countryList]"

... a kind of reverse of StrParse ... could have an "option" parameter to indicate whether "empty/missing array items should be ignored or not"

Re: More array functions

PostPosted: Fri Aug 22, 2014 12:09 pm
by Neosoft Support
Good suggestions. I will print and add to the list.

Re: More array functions

PostPosted: Fri Aug 22, 2014 2:00 pm
by dec
Hello,

Gaev wrote:1) Not sure if HPW, dec or David de Argentina already have such functionality within one their plugins.


My npUtil plugin is the "swiss knife" of my plugins, and, can be a good place to count with some Array related actions, in the same way than other categories like "Strings utils", "File utils", etc., etc. However, the NeoBook SDK do not provide too much stuff in order to deal with Arrays, as I can remember right now. Anyway I will to investigate this in the near future.

On the other hand maybe an interesting option is to use my npStrs plugin, which allow you to work with objects which contains "list of strings" (similar to Arrays) in various ways, allowing add, append, insert, delete, copy, find, locate, sort, avoid duplicates, deal with keys/values, load/save to/from file, etc., etc., etc.. ;)

Tony Kroos wrote:ArrayErase "[ArrVariable]" - deletearray


You can use the "DeleteArray" action to do this. ;)