You can add and remove a character for your party by using the ID of the hero according to the database.
You could have, for example, an array of variables where the first four (or six, depending on the length of your team) have the ID of the ones which are currently in the party and the following, would have the IDs of the reserve pokémon in the order they appear on the list.
When you catch a new pokémon, add 1 to a variable with the number of pokémon you have so far, get that value and modify the hero in that slot giving it the stats, name, graphic and more of the new pokémon (you just need to do this once for each new pokémon).
That way, if you want to switch a pokémon with another, you just need to check the ID of the pokémon in the slot you want to release, and then add the ID of the pokémon you want on the team, and of course, modify the values of the variables with the order of the pokémon so it can be consistent.
For example, you have 20 pokémon, and you have D, L, C and A on the team, with IDs 4, 12, 3 and 1 respectively.
Spoiler: Variables
Pkm1: 4
Pkm2: 12
Pkm3: 3
Pkm4: 1
---out of the party---
Pkm5: 5
Pkm6: 2
...
Pkm20: 20
Pkm21: 0
...
No.Pkm: 20
When you catch a new pokémon, U, add 1 to No.Pkm (=21), and modify hero no. 21 with the stats of U.
Also set Pkm21 to 21 (the slot where U is stored).
If position variables start at, for example, number 100 on the list of variables of your game, just use 100 + 21 as the variable reference in Control Variables to identify the variable you want to modify and set the new value.
Spoiler: Variables
Pkm1: 4
Pkm2: 12
Pkm3: 3
Pkm4: 1
---out of the party---
Pkm5: 5
Pkm6: 2
...
Pkm20: 20
Pkm21: 21
Pkm22: 0
...
No.Pkm: 21
Then in order to switch members, show the list to the player so they can choose.
If the player decided to switch A (#4) with U (#21), use the ID stored in Pkm4 to remove A and add the ID stored in Pkm21 to put U into the party. Then switch the values of Pkm4 and Pkm21 for consistency:
Spoiler: Variables
Pkm1: 4
Pkm2: 12
Pkm3: 3
Pkm4: 21
---out of the party---
Pkm5: 5
Pkm6: 2
...
Pkm20: 20
Pkm21: 1
Pkm22: 0
...
No.Pkm: 21
And that's all.
😀