DIRECTORY Commander USING [ CommandProc, Register ], CommandTool USING [ NumArgs, ArgN ], NamesGV USING [ GVGetAttribute ], NamesGVImpExp, NamesGVRpcControl USING [ ImportInterface ], IO, Rope USING [ Equal ], RPC USING [ ImportFailed, ShortROPE ], UserProfile USING [ Token ], VoiceUtils USING [ Problem, Report ] ; NamesGVImportImpl: CEDAR PROGRAM IMPORTS Commander, CommandTool, IO, VoiceUtils, Rope, RPC, NamesGV, NamesGVRpcControl, UserProfile EXPORTS NamesGVImpExp = { OPEN IO; ROPE: TYPE= RPC.ShortROPE; imported: BOOL_FALSE; importInstanceName: ROPE_NIL; importInstanceValue: ROPE_NIL; GVImport: PUBLIC PROC [instance: ROPE_NIL] RETURNS [success: BOOL_FALSE] = { ENABLE RPC.ImportFailed => { VoiceUtils.Problem["Couldn't import NamesGV.Lark", $Finch]; CONTINUE; }; [] _ DoImport[instance]; success _ TRUE; }; DoImport: PROC [instance: ROPE_NIL] RETURNS [newInstance: ROPE_NIL] = { IF instance=NIL THEN instance _ UserProfile.Token[key: "NamesGVInstance", default: "Strowger.Lark"]; UnGVImport[]; IF importInstanceValue#NIL AND instance.Equal[importInstanceName, FALSE] THEN instance _ importInstanceValue ELSE { importInstanceName _ instance; importInstanceValue _ NIL; }; imported _ TRUE; NamesGVRpcControl.ImportInterface [[ -- try with real name or explicit instance value type: "NamesGV.Lark", instance: instance ]!RPC.ImportFailed => IF importInstanceValue#NIL THEN { imported_FALSE; importInstanceValue _ NIL; CONTINUE; }]; IF ~imported THEN -- try again with real name NamesGVRpcControl.ImportInterface [[ type: "NamesGV.Lark", instance: importInstanceName]]; imported _ TRUE; newInstance _ importInstanceName; IF importInstanceValue=NIL THEN importInstanceValue _ NamesGV.GVGetAttribute[importInstanceName, $connect, NIL]; }; UnGVImport: PUBLIC PROC = { imported _ FALSE; }; CmdGVImport: Commander.CommandProc = { ENABLE RPC.ImportFailed => { VoiceUtils.Problem["Couldn't import NamesGV.Lark", $System]; CONTINUE; }; instance: ROPE= DoImport[IF CommandTool.NumArgs[cmd]#0 THEN CommandTool.ArgN[cmd,1] ELSE NIL]; VoiceUtils.Report[IO.PutFR["ImportInterface[NamesGV.Lark, %s]", rope[instance]], $System]; }; Commander.Register["GVImport", CmdGVImport, "Connect to remote NamesGV."]; }. ~NamesGVImportImpl.Mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last modified by Swinehart, November 25, 1985 12:33:31 pm PST Data Import Procedure $Finch until $System can be made much cleverer! Defaults to $System when there's no Finch. If instance is the same as last time, first try the associated explicit value (a rope representing the host address of the machine that implements the NamesGV interface -- e.g., "173#270#). When that fails or isn't there yet, try the name directly. On success, compute the explicit value. User command Initialization Swinehart, May 14, 1985 12:59:49 pm PDT Cedar 6.0 Κ3˜šœ™Icodešœ Οmœ1™