NamesGVImportImpl.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last modified by Swinehart, November 25, 1985 12:33:31 pm PST
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;
Data
ROPE: TYPE= RPC.ShortROPE;
imported: BOOL←FALSE;
importInstanceName: ROPE←NIL;
importInstanceValue: ROPE←NIL;
Import Procedure
GVImport:
PUBLIC
PROC [instance:
ROPE←
NIL]
RETURNS [success:
BOOL←
FALSE] = {
ENABLE
RPC.ImportFailed => { VoiceUtils.Problem["Couldn't import NamesGV.Lark", $Finch]; CONTINUE; };
$Finch until $System can be made much cleverer! Defaults to $System when there's no Finch.
[] ← DoImport[instance];
success ← TRUE;
};
DoImport:
PROC [instance:
ROPE←
NIL]
RETURNS [newInstance:
ROPE←
NIL] = {
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.
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;
};
User command
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];
};
Initialization
Commander.Register["GVImport", CmdGVImport, "Connect to remote NamesGV."];
}.
Swinehart, May 14, 1985 12:59:49 pm PDT
Cedar 6.0