[Done] PB alpha3: problem with nesting maps and procedures

All bugs related to new C backend
Geert
User
User
Posts: 31
Joined: Thu Aug 16, 2012 3:17 pm
Location: Belgium
Contact:

[Done] PB alpha3: problem with nesting maps and procedures

Post by Geert »

There is a problem with nesting maps and procedures when using MapKey and ReplaceString.

Code: Select all

Global NewMap m.s()

m("a")="1"
m("b")="2"
m("c")="3"
m("d")="4"

Procedure.s Value()
 ProcedureReturn m()
EndProcedure 

Procedure.s Test1(s$)
 ForEach m()
  s$=ReplaceString(s$,MapKey(m()),Value())
 Next 
 ProcedureReturn s$
EndProcedure

Procedure.s Test2(s$) ;this works
 ForEach m()
  k$=MapKey(m())
  s$=ReplaceString(s$,k$,Value())
 Next 
 ProcedureReturn s$
EndProcedure

Procedure.s Test3(s$) ;this works
 ForEach m()
  v$=Value()
  s$=ReplaceString(s$,MapKey(m()),v$)
 Next 
 ProcedureReturn s$
EndProcedure

Procedure.s Test4(s$) ;this works
 ForEach m()
  s$=ReplaceString(s$,MapKey(m()),m())
 Next 
 ProcedureReturn s$
EndProcedure

Debug Test1("abcdabcdabcd")
Debug Test2("abcdabcdabcd")
Debug Test3("abcdabcdabcd")
Debug Test4("abcdabcdabcd")
C backend output:
a23dab2dab2d
123412341234
123412341234
123412341234
ASM backend output (no problem):
123412341234
123412341234
123412341234
123412341234
Fred
Administrator
Administrator
Posts: 14422
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB alpha3: problem with nesting maps and procedures

Post by Fred »

Fixed.
Post Reply