If you don't care about uppercase letters (capitals), you might want to consider this simple solution which bypasses the problem:

/alphainvert {
/var %ainv.temp $upper($1-)
/var %ainv $replacecs(%ainv.temp,A,z,B,y,C,x,D,w,E,v,F,u,G,t,H,s,I,r,J,q,K,p,L,o,M,n,N,m,O,l,P,k,Q,j,R,i,S,h,T,g,U,f,V,e,W,d,X,c,Y,b,Z,a)
}

Since $replacecs is case sensitive, I turned all pre-code letters into uppercase.
The conversion turns them into lowercase letters, and because the script leaves lowercase letters alone, the system won't try to convert the same letter twice.

Hope this helps