Question: Why are the effective statements invalid when put them in a proc?

Hi,the following is my confused problem

the effective statements 
   restart;
   with(group):with(StringTools):with(Maplets[Examples]):
   a:=GetInput("Input the moves.");#input: IMIM10IM2IM9IM7IM8IM10
   i:=0:b:=Explode(a):
   M10:=[[2, 12, 7, 4, 11, 6, 10, 8, 9, 5, 3]]:
   M2:=[[2, 5, 8, 6, 4, 12, 3, 9, 10, 11, 7]]:
   M8:=[[2, 4, 10, 5, 12, 11, 8, 3, 7, 6, 9]]:
   M6:=[[2, 6, 3, 11, 5, 4, 9, 7, 8, 12, 10]]:
   M7:=[[2, 11, 9, 12, 6, 5, 7, 10, 3, 4, 8]]:
   M:=[[2, 3, 5, 9, 8, 10, 6, 11, 4, 7, 12]]:
   M9:=[[2, 7, 11, 10, 9, 3, 12, 4, 6, 8, 5]]:
   M3:=[[2, 9, 6, 7, 3, 8, 11, 12, 5, 10, 4]]:
   M4:=[[2, 8, 4, 3, 10, 7, 5, 6, 12, 9, 11]]:
   M5:=[[2, 10, 12, 8, 7, 9, 4, 5, 11, 3, 6]]:
   X:=[[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]:
   for d in b do 
     i:=i+1;
     if d>"0" and d<="9" then i:=i-1;s[i]:=Join(["M",d],"");
       elif d="0" then i:=i-1;s[i]:="M10";
       elif d="I" then s[i]:="X";
       else s[i]:="M";
     end if;
   end do:
   s:=convert(s,list);
   i:=0:for d in convert(s,list) do i:=i+1;s[i]:=convert(s[i],symbol);end do:
   s:=op(s);
   foldl(`mulperms`,s);

but this is invalid!Why?

   restart;
   with(group):with(StringTools):with(Maplets[Examples]):
IM:=proc()
   a:=GetInput("Input the moves.");#input: IMIM10IM2IM9IM7IM8IM10
   i:=0:b:=Explode(a):
   M10:=[[2, 12, 7, 4, 11, 6, 10, 8, 9, 5, 3]]:
   M2:=[[2, 5, 8, 6, 4, 12, 3, 9, 10, 11, 7]]:
   M8:=[[2, 4, 10, 5, 12, 11, 8, 3, 7, 6, 9]]:
   M6:=[[2, 6, 3, 11, 5, 4, 9, 7, 8, 12, 10]]:
   M7:=[[2, 11, 9, 12, 6, 5, 7, 10, 3, 4, 8]]:
   M:=[[2, 3, 5, 9, 8, 10, 6, 11, 4, 7, 12]]:
   M9:=[[2, 7, 11, 10, 9, 3, 12, 4, 6, 8, 5]]:
   M3:=[[2, 9, 6, 7, 3, 8, 11, 12, 5, 10, 4]]:
   M4:=[[2, 8, 4, 3, 10, 7, 5, 6, 12, 9, 11]]:
   M5:=[[2, 10, 12, 8, 7, 9, 4, 5, 11, 3, 6]]:
   X:=[[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]:
   for d in b do 
     i:=i+1;
     if d>"0" and d<="9" then i:=i-1;s[i]:=Join(["M",d],"");
       elif d="0" then i:=i-1;s[i]:="M10";
       elif d="I" then s[i]:="X";
       else s[i]:="M";
     end if;
   end do:
   s:=convert(s,list);
   i:=0:for d in convert(s,list) do i:=i+1;s[i]:=convert(s[i],symbol);end do:
   s:=op(s);
   foldl(`mulperms`,s);
end proc:
 

 

Please Wait...