I've made a function that swaps the positions of two characters in a string.
It works fine, but I want to know if there's any way to simplify it.
Here's the code:function swapChar(%input, %p1, %p2)
{
%pt1 = %p1; %pt2 = %p2;
%p1 = Min(%pt1, %pt2);
%p2 = Max(%pt1, %pt2);
%c1 = getSubStr(%input, %p1, 1);
%c2 = getSubStr(%input, %p2, 1);
%b1 = %p1 > 0 ? getSubStr(%input, 0, %p1) : "";
%b2 = %p1+1 != %p2 ? getSubStr(%input, %p1+1, %p2-1) : "";
%f = %p2 < strLen(%input)-1 ? getSubStr(%input, %p2+1, strLen(%input)) : "";
return %b1 @ %c2 @ %b2 @ %c1 @ %f;
}