More array functions

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

Locked
Tony Kroos
Posts: 419
Joined: Thu Oct 15, 2009 3:43 pm

More array functions

Post 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?
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: More array functions

Post 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"
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: More array functions

Post by Neosoft Support »

Good suggestions. I will print and add to the list.
NeoSoft Support
User avatar
dec
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain
Contact:

Re: More array functions

Post 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. ;)
Last edited by dec on Fri Aug 22, 2014 2:09 pm, edited 4 times in total.
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
Locked