ID:1770128
 
Keywords: arguments, verbs, windows
(See the best response by Kaiochao.)
Code:
mob/verb/Close()
winset(usr,"Window[i]","is-visible="false"")
//and does some more stuff but are not relevant


Problem description:

I have multiple same windows created with winclone, and I've created a Close() verb that is triggered when a the Close button is pressed on these windows. The problem is how does Close() know which window to close?

How can Close() verb be supplied with a number that will state which window to close??
Can I at runtime do that??
winset(usr,"window[i].Close","command=Close(i)")

and pass argument i when button is pressed??
winset(src,"window[i].Close","command=[url_encode("Close \"[i]\"")]")


I believe this is what you want?
But with that I must define many Close procs right??
In response to Victorqr
Victorqr wrote:
But with that I must define many Close procs right??

mob/verb/Close(windowNumber as num)
//do stuff


If your verb takes parameters something like that (as num, as text.. whatever) then Close \"[i]\" is the same at typing Close i_variable_here. Ever noticed how when you type Say and press space a quotation pops up after it? That's what I did in the command.

Does the script work? I can't really tell you if you need to define many close procedures because I don't know what your procedure looks like.
Best response
You can set the command of the Close button to a .winset call:
winset(src, "window[i].Close", {"command=".winset \"window[i].is-visible=false\"""})

No verb required, and it's also processed client-side, so lag can't cause a delay between the button clicked and the window closing.
In response to Kaiochao
That's if the window has a user-defined close button. Otherwise you'd want to send the winset to the window itself, and set on-close instead of command. Otherwise it's the same deal.
I want more stuff to happen and I'm trying to achieve the thing Xirre mentions, but I try it and it doesn't work I'll check if I do something wrong.

I mean what I want to happen is that when Close button is pressed to call a Close(i) verb and not asking the user which number
Make the verb call a proc then?
Make a close verb that takes the parameter i and it performs winset is-visible false. Or try Kaio's method.
i as num right??
Ok guys thanks I finally did it as Xirre says I just did i as text cause i is passed as a string and not number so I'll convert it inside the verb
Thanks for your help
In response to Victorqr
Victorqr wrote:
Ok guys thanks I finally did it as Xirre says I just did i as text cause i is passed as a string and not number so I'll convert it inside the verb
Thanks for your help

Well, did my solution work.. or? If so, glad I could help.
Yeah your solution worked, thanks for the help ;) I wanted to do exactly the same thing but didn't knew the code for it.

At first it didn't work because of a bug in the rest of my code it has gotten quite bulky and tracing a bug is somewhat difficult lately, anyway thanks for the halp
You're welcome.