Notifications
Clear all

[Closed] RolloutCreator codeStr: syntax question

Ok I’m coming back from a long vacation and brain hasn’t seemed to arrived yet

I am creating a dynamic rollout (rolloutCreator) and am trying to get the codeStr: in a .addHandler to pass a string to a function. I have an array of folder names.


rci.addHandler ("btn_" + sFolderName as name) #pressed codeStr:("thisIsMyFunction " + (aFolders[Folder]) as string)

so right now the event handler writes as ThisIsMyFunction SomeFolderName, which when the fn is called SomeFolderName is undefined, where I need it just to be a string…

My Q:
what the proper syntax so I can pass the folder name from the array, to the function as a string in the codeStr:?

wrapping @@ around the array doest extract it…
I’m sure over thinking this & I’m missing some really simple here…
Cheers

3 Replies

of sfoldername is an array, you have to specify the element, as in sfoldername[i]

1 Reply
(@headsmell)
Joined: 10 months ago

Posts: 0

somefoldername IS the element in the array… I posted a piece of code above. Normally you would wrap @@ around a string, when using the codestr: this doesn’t work with an array.

Ok I found a work around, I compiled the string using a StringStream and formatted the letters

If anyone has a more elegant way please share!


try (destroyDialog Test)catch()

aRootDirs = #("FolderOne","FolderTwo","FolderThree")
rci = rolloutCreator "Test" "Test" 
rci.begin()
rci.addText "
fn createMenu theString =
(
	print @Called@
	print theString 
)"
for Folder = 1 to aRootDirs.count do 
(
	FolderName =  aRootDirs[Folder]
	ssTheStream = stringstream  ""
	format "createMenu " to:ssTheStream
	format "@" to:ssTheStream
	format FolderName to:ssTheStream
	format "@" to:ssTheStream
	rci.addControl #button ("btn_" + (FolderName) as name) FolderName
	rci.addHandler ("btn_" + FolderName as name) #pressed codeStr:( ssTheStream as string  ) 
	print ssTheStream 
)
createDialog (rci.end())	

Cheers