Use $mid instead of calculating each time to get the character. Also use the correct syntax for /var which is /var %var = data.