[Gambas-user] Idea for arrays: .SWAP function

Rolf-Werner Eilert rwe-sse at osnanet.de
Fri Oct 9 09:55:37 CEST 2020


Hi Benoit and all,

Just had this one in a current project. To enable the user to push an 
entry in a list one up or down, I have to swap the related values in 
several arrays. There seems to be no swap function, so I have to write 3 
lines of codes for it, like this:

  t$ = klName[po]
  klName[po] = klName[po + 1]
  klName[po + 1] = t$

I have to use these 3 lines for each array. How much easier it would be 
if I could use a function like for this:

klName.Swap(po, po+1)

This would also make sense in ListBox etc.

I think this would enhance code and readability a lot.

Regards
Rolf


More information about the User mailing list