Page 1 of 1

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

Posted: Tue Jul 13, 2021 9:56 am
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

Re: PB alpha3: problem with nesting maps and procedures

Posted: Tue Sep 07, 2021 9:17 am
by Fred
Fixed.