| Did you know ... | Search Documentation: |
| class obtain |
Class ? is (pronounced as obtainer) is a template for the virtual machine instruction get in the same fashion as a message object is a template to the send operation. Obtainers are the most commonly used function objects.
Obtainers add a very powerful mechanism to PCE. Understanding them is critical for writing readable and fast PCE programs. Please study the examples. In the example below, an obtainer is used to combine dialog_item selections to create a single call to the application:
?- new(D, dialog),
send(D, append, new(label)), % for feedback
send(D, append, new(Name, text_item(name, ''))),
send(D, append, new(Age, int_item(age))),
send(Age, hor_stretch, 100), % stretch to right of D
send(D, append,
button(create, message(@prolog, create_person,
Name?selection,
Age?selection))),
send(D, open).
Of course, the application must define a predicate create_person/2.
<-_slot <-_references <-_inspect <-_flags <-_class_name <-_class <-_arity <-_arg ->_inspect ->_free
?- send(@pce, writeln, ?(@prolog,current_prolog_flag,version)). 100109
|function,
selector=name|function, argument=any|function
...?- new(B, box(100,100)), send(@pce, writeln, B?center?x). 50
See also class message.
<-receiver, obtain<-selector
or obtain<-arguments are evaluated first,
after which the XPCE virtual machine operation
get(<-receiver, <-selector, <-arguments ..., Value)
is performed and the resulting Value is the result of the obtainer.