|
echo $fn ?>
|
|
../code/tripplan.orx/var/www/html/ooRexx/wip
-- stdout and trace output will go to a separate window
prevTrace = .traceoutput~destination(.streamclient~new("localhost",726578))~~open(.context~name "- ooRexx Trace Output")
prevOut = .output~destination(.streamclient~new("localhost",726576))~~open(.context~name "- ooRexx Standard Output")
-- let's start in Rotterdam and go to Dublin
planner = .planner~new
planner~from = .location~new("From","Rotterdam")
say 1 planner~route?~makeString('L','-')
trace i
planner~to = .location~new("To","Dublin")
say 2 planner~route?~makeString('L','-')
-- add listeners for city changes for "from" and "to"
planner~from~addEventListener(address_changed,planner)
planner~to~addEventListener(address_changed,planner)
--say "Enter departure address:"
--parse pull fromAddress
--planner~from = fromAddress
-- on second thought begin in Amsterdam
planner~from~address = "Amsterdam"
say 3 planner~route?~makeString('L','-')
trace o
--say "Enter destination address:"
--parse pull toAddress
--planner~to = toAddress
-- and end in Rome
planner~to~address = "Rome"
say 4 planner~route?~makeString('L','-')
-- add listener for added midway city
planner~via~addEventListener(via_appended,planner)
-- with a stopover at Oslo
index = planner~via~append(.location~new("Via_"planner~via~items+1,"Oslo"))
say 5 planner~route?~makeString('L','-')
-- add listener for changed city of a midway location
planner~via[index]~addEventListener(address_changed,planner)
-- or rather Barcelona instead of Oslo
planner~via[index]~address = "Barcelona"
say 6 planner~route?~makeString('L','-')
-- and Palermo after Barcelona
via = .location~new
via~objectname = "Via"planner~via~items+1
via~addEventListener(address_changed,planner)
planner~via~append(via)
via~address = "Palermo"
say 7 planner~route?~makeString('L','-')
exit
::class planner public
::method init
expose via
via = .via~new
::attribute from get
::attribute from set
expose from
use arg from
self~plan
::attribute to get
::attribute to set
expose to
use arg to
self~plan
::attribute via get
::attribute via set private
::method plan
expose from to via route
--trace i
route = .array~new
if from~isA(.location) then do
route~append(from~address)
end
if via~isA(.array) then do v over via
route~append(v~address)
end
if to~isA(.location) then do
route~append(to~address)
end
::method route?
expose route
return route
::method address_changed
self~plan
return .false -- in case there are more event handlers/listeners waiting
::method via_appended
say arg(1,'A')~makeString('L',',')
self~via~makeString
self~plan
return .false
::class location public inherit eventable
::attribute address get
::attribute address set
expose address
--trace i
use arg address
self~triggerEvent(address_changed,.array~of(arg1,arg2))
return .false
::method init
--trace i
self~init:super
use strict arg name=.nil, address=.nil
if (name\==.nil) then self~objectname = name
if (address\==.nil) then self~address = address
self~events[address_changed] = .array~new
::class via subclass array inherit eventable
::method init
self~init:super(via_appended)
--self~events[via_appended] = .array~new
::method append
use strict arg item
--trace i
index = self~append:super(item)
say self[index] item
self~triggerEvent(via_appended,.array~of(self[index]))
return index
::requires 'eventable.cls'
::requires 'streamclient.cls'
If you feel inclined to make corrections, suggestions etc.,
please mail me any.
| |
All content © Ruurd Idenburg, 2007– echo date('Y');?>,
except where marked otherwise. All rights reserved. This page is primarily for non-commercial use only.
The Idenburg website records no personal information and sets no ‘cookies’.
This site is hosted on a VPS(Virtual Private System) rented from Transip.nl, a Dutch company, falling under Dutch (privacy) laws (I think).
This page updated on echo date("r", filemtime("./index.php"));?> by Ruurd Idenburg.
|
|