" *****************************************************************************************************
*
* block1.txt
*
*   This examples shows how to define a block in a type
*
*
******************************************************************************************************"

| aModel aTextDisplay sectionType courseType attributesDict courseSections anOrb courses|
aTextDisplay := TextWindow  windowLabeled: 'LPC Brokers - block 1'
                           frame: (0 @ 0 corner: 500 @ 500).
aTextDisplay cr. 
 
" let's get our model"
aModel := LPCModel getName: #LpcSample.
 

"let's retrieve our Course type"
courseType := aModel typeNamed: #Course.

"add the attribute for the block to the course type"
courseType addAttribute: 'creditPerHour'.

"add the block now to the course type attribute creditPerHour"
courseType addBlock: '[ :c | c credit * c hours ]' forAttribute: 'creditPerHour'.

"now let's test this block"
anOrb := LPCObjectRequestBroker new.

anOrb driverConnectWindow: aTextDisplay. 

courses := anOrb lookUpAllWithType: courseType.

courses do: [ :c |
    aTextDisplay
          nextPutAll: 'Course: ', c course asString; cr
        ; nextPutAll: 'Hours: ', c hours asString; cr
        ; nextPutAll: 'Credit: ', c credit asString; cr
        ; nextPutAll: 'Credit per hour: ', c creditPerHour asString; cr
        ; nextPutAll: 'Description: ' , c description asString; cr .
].

anOrb disconnect.
                     
                                                                                    
    

 







































































































































































































































































































































































 
