Author Topic: Inserting/removing and bumping array entries?  (Read 111 times)

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 376
  • Gender: Male
  • Creator of spells
Inserting/removing and bumping array entries?
« on: July 18, 2021, 08:40:44 AM »
Do we have any similar functionality? See pseudocode below: (code is longer than the code window)

Code: [Select]
OUTER_SPRINT $LIST ("0" "0") "ONE"
OUTER_SPRINT $LIST ("1" "0") "TWO"
OUTER_SPRINT $LIST ("2" "0") "THREE"

OUTER_SPRINT_INSERT ("2" "0") "THREE PLUS" (0) // number in parentheses indicates array slot/dimension. (0) is assumed by default if no number is given
// resulting entries will now read as:
// $LIST ("0" "0") "ONE"
// $LIST ("1" "0") "TWO"
// $LIST ("2" "0") "THREE PLUS"
// $LIST ("3" "0") "THREE"
OUTER_SPRINT_INSERT ("2" "0") "THREE PLUS PLUS" (1) // number in parentheses indicates array slot/dimension. (0) is assumed by default if no number is given
// resulting entries will now read as:
// $LIST ("0" "0") "ONE"
// $LIST ("1" "0") "TWO"
// $LIST ("2" "0") "THREE PLUS PLUS"
// $LIST ("2" "1") "THREE PLUS"
// $LIST ("3" "0") "THREE"

DELETE_ARRAY_ENTRY $LIST ("2" "0") (0) // number in parentheses indicates array slot/dimension. (0) is assumed by default if no number is given
// resulting entries will now read as:
// $LIST ("0" "0") "ONE"
// $LIST ("1" "0") "TWO"
// $LIST ("2" "0") "THREE"
// $LIST ("2" "1") "THREE PLUS"

DELETE_ARRAY_ENTRY $LIST ("2" "0") (1) // number in parentheses indicates array slot/dimension. (0) is assumed by default if no number is given
// resulting entries will now read as:
// $LIST ("0" "0") "ONE"
// $LIST ("1" "0") "TWO"
// $LIST ("2" "0") "THREE PLUS"

I guess such a feature isn't applicable for ASSOCIATIVE_ARRAYs only ones with numeric slots.

This function would be useful for example if one constructs arrays when adding/deleting entries of arrays created by OFFSET_ARRAY or if one decompiles a script and then stores/patches individual blocks as array entries.

Speaking of which, it would be convenient if WeiDU can internally construct arrays of decompiled scripts as strings of different IF ... END blocks. In that way, it would be easy to patch/insert/delete new blocks with this functionality.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1133
Re: Inserting/removing and bumping array entries?
« Reply #1 on: July 22, 2021, 05:15:19 AM »
I'll have to look further into this. DavidW has made a separate request for deleting variables and there's going to be interactions between this and that. On the subject of inserting, are you aware of (ACTION_)SORT_ARRAY_INDICES? Could possibly work instead.

 

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.

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)?: