fsmName: Rope.ROPE;
shortName: Rope.ROPE;
iconName: Rope.ROPE;
-- Get name of source and target
IF selected=NIL THEN RETURN;
fsmName ← CDDirectory.Name[selected.ob, comm.design];
IF fsmName.IsEmpty[]
THEN
{TerminalIO.PutF["*** Selected schematic has no name.\n"]; RETURN};
IF ~Rope.Match["*.fsm", fsmName]
THEN
TerminalIO.PutF["*** Convention for FSM schematics is to suffix them with '.fsm'.\n"];
shortName ← TerminalIO.RequestRope["Type icon short name: "];
IF shortName.IsEmpty[]
THEN shortName ← fsmName.Substr[0, fsmName.Index[0, "."]]
ELSE shortName ← shortName.Substr[0, shortName.Index[0, "."]];
iconName ← shortName.Concat[".icon"];
IF CDDirectory.Fetch[comm.design, iconName]#
NIL
THEN
{TerminalIO.PutF["*** The icon %g already exists!\n", IO.rope[iconName]]; RETURN};
-- Build the object, instantiate it & return
shell ← SchCDUtils.NewShell[shortName, nms, comm.design];
shell.grid ← CDOps.GetGrid[comm.design, comm]; -- default might not be perfect...
icon ← SchCDUtils.ShellObject[shell];
CDProperties.PutObjectProp[icon, Sisyph.mode.extractProcProp, $SisyphExtractCellIcon];
codeLine ← IO.PutFR["FSM.SchMachine[cx, \"%g\"]", IO.rope[fsmName]];
CDProperties.PutObjectProp[icon, $CodeFor, codeLine];
CDCells.SetSimplificationTreshhold[cell: icon, val: 30, inPixels: TRUE];
IF NOT CDDirectory.Include[comm.design, icon, iconName] THEN ERROR; -- Abnormal
[] ← CDOps.IncludeObjectI[comm.design, icon, comm.pos];
TerminalIO.PutF["%g generated\n", IO.rope[iconName]]};