Author Topic: New ARRAY commands  (Read 975 times)

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
New ARRAY commands
« on: October 10, 2021, 04:32:54 PM »
Hi. I would like a few more commands for working with arrays, to the tune of:

MERGE_ARRAYS newarray array1 array2 etc
> Creates newarray from the contents of the listed arrays.

APPEND_ARRAY array value
> Adds the specified value(s) to the specified array.

COUNT_ARRAY_VALUES array variable
> Counts the number of values in the specified array and stores the result in the variable.

If existing functionality covers this, please point me to it. I've been away from modding a while. I realize (ACTION_)PHP_EACH may cover some of this (particular the latter if augmenting a variable in the process), but it has been suboptimal at best so far. I haven't looked into RET_ARRAY much, but as I read it, it seems to be only usable within a function. And in any case, it seems to have a separate purpose.

Incidentally, GET_DIRECTORY_ARRAY seems to regard "." and ".." as the first two entries in that array; is there a way to opt out of this? It also seems to throw an unspecified unix bug if the current mod's folder is one of those directories.

Cheers.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: New ARRAY commands
« Reply #1 on: October 26, 2021, 03:18:26 PM »
The new actions/patches should be feasible, but probably won't make it into next version. As hard as it may be to believe, I'm hoping to release a new version at some point, but mainly with bug-fixes.

Incidentally, GET_DIRECTORY_ARRAY seems to regard "." and ".." as the first two entries in that array; is there a way to opt out of this?
Conditionals and string matching? They are valid directory entries.

Quote
It also seems to throw an unspecified unix bug if the current mod's folder is one of those directories.
Would you be able to provide some kind of test case for this? I have a hard time understanding how the mod folder could be either "." or "..", at least not a valid one.

Offline Salk

  • Planewalker
  • *****
  • Posts: 873
Re: New ARRAY commands
« Reply #2 on: November 03, 2021, 04:17:14 AM »
I, for one, would love a 248 version taking care of the most critical bugs.

There will be (hopefully) time for new functionalities after that...

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: New ARRAY commands
« Reply #3 on: November 16, 2021, 10:36:35 AM »
APPEND_ARRAY array value
> Adds the specified value(s) to the specified array.
This one does not check out. To add something to an array you do
Code: [Select]
SPRINT $array(key1 ... keyN) value
or the integer equivalent. If the keys are unique, the array grows, otherwise the old value is overwritten. There's nothing within the array framework I could (or would) add to allow duplicate keys.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: