Hi again Denis 😉
The problem is I'm trying to combine the following code from a for loop to one string and execute it once. To booste performance by only calling Execute once with the concatenated string.
Code below is part of a for loop:
nameSwatch = "swatch_" + (counter as string)
nameBmp = "bmp_" + (counter as string)
element_ss = stringstream ""
format "rci.addText \"local % = bitmap % % color:%\"" nameBmp swatch_width swatch_height (col_line[2] as point3) to:element_ss
execute(element_ss as string)z
free element_ss
param_ss = stringstream ""
format "bitmap:% tooltip:\"%\" iconSize:[%,%] pos:[%,%]" \
nameBmp col_line[1] swatch_width swatch_height swatch_x swatch_y to:param_ss
rci.addControl #imgTag nameSwatch "" paramstr:param_ss as string
rci.addHandler nameSwatch #click \
codeStr:("RoFn.processSelected @" + col_line[1] as string +"-" + col_line[2] as string + "-" + col_line[3] as string + "@") filter:on
free param_ss
I tried the code below but there are issues with the paramStr and codeStr. Because they are 2 levels deep nested in the string and there is a problem with the string literal indication. I tried to apply your suggestion but got stuck.
nameSwatch = "swatch_" + (counter as string)
nameBmp = "bmp_" + (counter as string)
element_ss = stringstream ""
format "rci.addText \"local % = bitmap % % color:%\"" nameBmp swatch_width swatch_height (col_line[2] as point3) to:element_ss
param_ss = stringstream ""
format "bitmap:% tooltip:\"%\" iconSize:[%,%] pos:[%,%]" nameBmp col_line[1] swatch_width swatch_height swatch_x swatch_y to:param_ss
ui_ss_01 = stringstream ""
format "rci.addControl #imgTag % \"\" paramstr:\"%\"" nameSwatch (param_ss as string) to:ui_ss_01
ui_ss_02 = stringstream ""
format "rci.addHandler % #click codeStr:(\"RoFn.processSelected @\" + % +\"-\" + % + \"-\" + % + \"@\") filter:on" nameSwatch col_line[1] col_line[2] col_line[3] to:ui_ss_02
--Final execute string
format "% \n % \n % \n" (element_ss as string) (ui_ss_01 as string) (ui_ss_02 as string) to:main_ss
The output is as follow:
This is one part from the 1500 outputs in the concatenated string =>
rci.addText "local bmp_21 = bitmap 44 20 color:[47,23,26]"
rci.addControl #imgTag swatch_21 "" paramstr:"StringStream:"bitmap:bmp_21 tooltip:"RAL 010 40 15 " iconSize:[44,20] pos:[0,60]""
rci.addHandler swatch_21 #click codeStr:("RoFn.processSelected @" + RAL 010 40 15 +"-" + [47,23,26] + "-" + [118,85,91] + "@") filter:on
As you can see there is a string indication problem at the paramStr and codeStr