// This chaims program runs the transportation demo. // It utilizes the Air, Ground, RouteInfo, BestRoute, and IO megamodules transportationdemo BEGINCHAIMS am = SETUP("AirMM") gm = SETUP("GroundMM") br = SETUP("BestRouteMM") ri = SETUP("RouteInfoMM") io = SETUP("io") // First, we'll get the default city pair from routeinfo cp = ri.GETPARAM("GetRoutes", "b_CityPair") // Now ask the user which cities ioask = io.INVOKE("ask", label="which cities", data=cp) WHILE(ioask.EXAMINE() != DONE) {} cities = ioask.EXTRACT() // Now, we'll get the list of routes between these cities getroutes = ri.INVOKE("GetRoutes", b_CityPair = cities) WHILE(getroutes.EXAMINE() != DONE) {} routes = getroutes.EXTRACT() // Now, we'll get the list of possible city pairs between these 2 cities // This will be used to determine the Air and Ground costs getcpl = ri.INVOKE("GetCityPairList", b_Routes = routes) WHILE(getcpl.EXAMINE() != DONE) {} cpl = getcpl.EXTRACT() // Now, get the Air travelcost atravcost = am.INVOKE("GetTravelCost", CityPairList = cpl) WHILE(atravcost.EXAMINE() != DONE) {} travcostair = atravcost.EXTRACT() // Now, get the Ground travelcost gtravcost = gm.INVOKE("GetTravelCost", CityPairList = cpl) WHILE(gtravcost.EXAMINE() != DONE) {} travcostgrnd = gtravcost.EXTRACT() // Now, get the best route from the bestroute module getbr = br.INVOKE("PickBestRoute",b_Routes=routes, TravelCostGround=travcostgrnd, TravelCostAir=travcostair) WHILE(getbr.EXAMINE() != DONE) {} best = getbr.EXTRACT() iohndl = io.INVOKE("write", Data = best) // terminate the invocations getroutes.TERMINATE() getcpl.TERMINATE() atravcost.TERMINATE() gtravcost.TERMINATE() getbr.TERMINATE() ENDCHAIMS