Slow string value

Hi, I used javascript component in Xojo. When I have 7.000 items then reading from the Database and fill items class and calculating things takes cca 45 sek., but generating string items for js component takes more than 3 minutes. Is any way, how can I make it faster? During for cycle I see in task manager that RAM for Chrome(with my app) jump so fast from 50MB to 80MB and back to 50MB and again and again so fast. Can that this: Jscript = Jscript + “…” slow do?
This for cycle with 7000 repetition takes more than 3 minutes:

dim Jscript as string
dim items() as myItems
...
for i = 0 to 7000
      Jscript = Jscript +"{ content: """ +  items(i).KompArtikelNr  +""", indentation: "+ items(i).level+",    start: new Date("+str(dateend.year)+", "+str(dateend.month-1)+", "+str(dateend.day)+", "+str(dateend.hour)+", "+str(dateend.minute)+", 0), finish: new Date("+str(datestart.year)+", "+str(datestart.month-1)+", "+str(datestart.day)+", "+str(datestart.hour)+", "+str(datestart.minute)+", 0), id: """+str(i)+""", "
      Jscript = Jscript +"assignmentsContent: """+ items(i).KompArtikelNr +""", artnr: """+  items(i).ArtikelNr+""", pos: """+  items(i).posnr+""", nazev: """+ items(i).bezeichnung1 +""",  nazev2: """+ items(i).bezeichnung2 +""",  kompart: """+ items(i).KompArtikelNr +""", pdv: """+ str(items(i).dlz) +""", pdvsk: """+ str(items(i).dlzbg) +""", ep: """+items(i).ep+""", hl: """+items(i).hl+""", mpp: """+items(i).mpp+""", bp: """+items(i).bp+""", ohnebe: """+items(i).ohnebe+""", vlz: """+items(i).vlz+""", fixa: """+items(i).isFixiert+"""}," + EndOfLine
 next
...
me.ExecuteJavaScript(Jscript)

Using an array should speed it up…

dim Jscript() as string
dim items() as myItems

Jscript.Append "{ content: """
Jscript.Append items(i).KompArtikelNr
Jscript.Append """, indentation: "
....

me.ExecuteJavaScript(Join(Jscript, ""))

I found in my programs that the above approach usually speeds up things significantly.

Thanks you very much. I tried it and then I write feedback how faster it is.

Glad to hear it made a difference :wink:

OMG. That is now rapidly faster. It takes all under 30 seconds. Thank you again Alwyn. You helped me. Have a nice day :slight_smile: