Procedure

Q:

I’ve a form, with a new container, with a button.

On the “cick” event, I call a procedure “sp_close_handler”

Code:
oContBottom.addObject("sp_close", "commandbutton")
sp_close.move(1, 1, 60, 20)
sp_close.text = "Close"
sp_close.click = sp_close_handler
Code:
proc sp_close_handler()
	p_myform.close()
endproc

can I send a parameter on the call?
for example:

Code:
oContBottom.addObject("sp_close", "commandbutton")
sp_close.move(1, 1, 60, 20)
sp_close.text = "Close"
sp_close.click = sp_close_handler with "aaa"
Code:
proc sp_close_handler(m_text)
	lianja.showmessage(m_text)
	p_myform.close()
endproc

naturally, this code not work.. 🙂

A:

Lianja objects are dynamically extensible so you can define your own properties on the command button,

Code:
sp_close.myvar = "something"

then in the sp_close_handler() just reference this.myvar.

Note that in Lianja 3.4 you can associate objects with UI components too.

Code:
mydataobj = object()
mydataobj.hello = "world"
sp_close.mydata = mydataobj

or

Code:
sp_close.mydata = object()
sp_close.mydata.hello = "world"

Notice how objects are dynamically extensible.

then later you can reference the members of objects like this.

Code:
sp_close.mydata.hello

 

etc.

and as it turns out you can attach arrays to UI objects also, and arrays can contain objects or other arrays

Code:
declare myarray[10,10]
myarray[1,1] = "hello"
btn.myarray = myarray
? btn.myarray[1,1]
? btn.myarray

So this allows you to attach business objects to UI controls as all objects and arrays in Lianja are reference counted so going out of scope does not affect them.

So with some creative thinking you can save and restore business objects and attach them to the UI controls of your apps in the “ready” delegate.



Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s