You can use $istok for those if statements to shorten the code.
/help $istok
Also use \"^*:OPEN:...\" & halt together so no need for the /close command.
/help On Open