EBNullDocTestImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Kenneth A. Pier, October 1, 1992 11:55 am PDT
Bier, September 29, 1992 4:24 pm PDT
DIRECTORY
Commander, EmbeddedButtons, EBTypes, EBNullDoc, List, IO, Rope;
EBNullDocTestImpl: CEDAR PROGRAM
IMPORTS Commander, EBNullDoc, EmbeddedButtons, IO = BEGIN
ActiveDoc: TYPE = EBTypes.ActiveDoc;
ActiveButton: TYPE = EBTypes.ActiveButton;
ROPE: TYPE = Rope.ROPE;
TestSig: SIGNAL = CODE;
Test: Commander.CommandProc = {
OPEN EBNullDoc;
bool: BOOL ¬ FALSE;
atom: ATOM;
real: REAL;
int: INT;
rope: Rope.ROPE;
doc: ActiveDoc ← Create["DuckDock"];
button: ActiveButton ← CreateBOOLButton[doc, "TestButton", TRUE];
AddBOOLVariable[button, "falseBOOL", FALSE];
AddATOMVariable[button, "dollarFoo", $Foo];
AddROPEVariable[button, "myRopeVar", "This is a rope"];
AddINTVariable[button, "int123", 123];
AddREALVariable[button, "real34point29", 34.29];
AddEnumeratedVariable[button: button, varName: "Niners", varVal: NEW[INT ← 9], type: LIST[ NEW[INT ¬ 7], NEW[INT ¬ 8], NEW[INT ¬ 9] ] ];
Instantiate[doc];
bool ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc], REF BOOL]^;
cmd.out.PutF1["trueBOOL = %g\n", [boolean[bool]]];
real ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc, $real34point29], REF REAL]^;
cmd.out.PutF1["real34point29 = %g\n", [real[real]]];
int ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc, $int123], REF INT]^;
cmd.out.PutF1["int123 = %g\n", [integer[int]]];
rope ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc, $myRopeVar], Rope.ROPE];
cmd.out.PutF1["myRopeVar = \"%g\"\n", [rope[rope]]];
atom ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc, $dollarFoo], ATOM];
cmd.out.PutF1["dollarFoo = %g\n", [atom[atom]]];
bool ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc, $falseBOOL], REF BOOL]^;
cmd.out.PutF1["falseBOOL = %g\n", [boolean[bool]]];
int ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc, $Niners], REF INT]^;
cmd.out.PutF1["Niners = %g\n", [integer[int]]];
};
ETest: Commander.CommandProc = {
OPEN List, EBNullDoc;
bool: BOOL ¬ FALSE;
boolE: LORA ¬ LIST[ NEW[BOOL ¬ FALSE], NEW[BOOL ¬ TRUE]];
atom: ATOM;
real: REAL;
int: INT;
rope: ROPE;
ropeA: ROPE ¬ "a";
ropeB: ROPE ¬ "B";
ropeE: LORA ¬ LIST[ ropeA, ropeB];
doc: ActiveDoc ← Create["Enumerations"];
button: ActiveButton ← CreateEnumeratedButton[doc, "ETestButton", ropeA, ropeE];
AddREALVariable[button, "real34point29", 34.29];
AddINTVariable[button, "int123", 123];
AddROPEVariable[button, "myRopeVar", "This is a rope"];
AddATOMVariable[button, "dollarFoo", $Foo];
AddBOOLVariable[button, "falseBOOL", FALSE];
AddEnumeratedVariable[button, "falseEBOOL", NEW[BOOL ¬ FALSE], boolE];
AddEnumeratedVariable[button, "trueEBOOL", NEW[BOOL ¬ TRUE], boolE];
AddEnumeratedVariable[button: button, varName: "Niners", varVal: NEW[INT ← 9], type: LIST[ NEW[INT ¬ 7], NEW[INT ¬ 8], NEW[INT ¬ 9] ] ];
Instantiate[doc];
rope ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $Value]];
cmd.out.PutF1["ropeA = \"%g\"\n", [rope[rope]]];
real ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $real34point29], REF REAL]^;
cmd.out.PutF1["real34point29 = %g\n", [real[real]]];
int ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $int123], REF INT]^;
cmd.out.PutF1["int123 = %g\n", [integer[int]]];
rope ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $myRopeVar], Rope.ROPE];
cmd.out.PutF1["myRopeVar = \"%g\"\n", [rope[rope]]];
atom ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $dollarFoo], ATOM];
cmd.out.PutF1["dollarFoo = %g\n", [atom[atom]]];
bool ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $falseBOOL], REF BOOL]^;
cmd.out.PutF1["falseBOOL = %g\n", [boolean[bool]]];
bool ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $falseEBOOL], REF BOOL]^;
cmd.out.PutF1["falseEBOOL = %g\n", [boolean[bool]]];
bool ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $trueEBOOL], REF BOOL]^;
cmd.out.PutF1["trueEBOOL = %g\n", [boolean[bool]]];
int ¬ NARROW[EmbeddedButtons.GetValue[$ETestButton, doc, $Niners], REF INT]^;
cmd.out.PutF1["Niners = %g\n", [integer[int]]];
};
VTest: Commander.CommandProc = {
OPEN List, EBNullDoc, EmbeddedButtons;
bool: BOOL ¬ FALSE;
boolE: LORA ¬ LIST[ NEW[BOOL ¬ FALSE], NEW[BOOL ¬ TRUE]];
atom: ATOM;
real: REAL;
int: INT;
rope: ROPE;
ropeA: ROPE ¬ "a";
ropeB: ROPE ¬ "B";
ropeE: LORA ¬ LIST[ ropeA, ropeB];
doc: ActiveDoc ← Create["ValueTest"];
button: ActiveButton ← CreateBOOLButton[doc, "VTestButton", TRUE]; -- variable: $Value
AddREALVariable[button, "real34point29", 1.0];
AddINTVariable[button, "int123", 333];
AddROPEVariable[button, "myRopeB", "Initial rope"];
AddATOMVariable[button, "dollarFoo", $InitialAtom];
AddBOOLVariable[button, "falseBOOL", TRUE];
Instantiate[doc];
SetValue[name: $VTestButton, variable: $real34point29, val: NEW[REAL ¬ 34.29], doc: doc ];
SetValue[name: $VTestButton, variable: $int123, val: NEW[INT ¬ 123], doc: doc];
SetValue[name: $VTestButton, variable: $myRopeB, val: ropeB, doc: doc];
SetValue[name: $VTestButton, variable: $dollarFoo, val: $Foo, doc: doc];
SetValue[name: $VTestButton, variable: $falseBOOL, val: NEW[BOOL ¬ FALSE], doc: doc];
bool ¬ NARROW[EmbeddedButtons.GetValue[$VTestButton, doc], REF BOOL]^;
cmd.out.PutF1["trueBOOL = %g\n", [boolean[bool]]];
real ¬ NARROW[EmbeddedButtons.GetValue[$VTestButton, doc, $real34point29], REF REAL]^;
cmd.out.PutF1["real34point29 = %g\n", [real[real]]];
int ¬ NARROW[EmbeddedButtons.GetValue[$VTestButton, doc, $int123], REF INT]^;
cmd.out.PutF1["int123 = %g\n", [integer[int]]];
rope ¬ NARROW[EmbeddedButtons.GetValue[$VTestButton, doc, $myRopeB], Rope.ROPE];
cmd.out.PutF1["myRopeVar = \"%g\"\n", [rope[rope]]];
atom ¬ NARROW[EmbeddedButtons.GetValue[$VTestButton, doc, $dollarFoo], ATOM];
cmd.out.PutF1["dollarFoo = %g\n", [atom[atom]]];
bool ¬ NARROW[EmbeddedButtons.GetValue[$VTestButton, doc, $falseBOOL], REF BOOL]^;
cmd.out.PutF1["falseBOOL = %g\n", [boolean[bool]]];
};
RTest: Commander.CommandProc = {
OPEN List, EBNullDoc, EmbeddedButtons;
rope: ROPE;
ropeA: ROPE ¬ "one";
ropeB: ROPE ¬ "two";
ropeC: ROPE ¬ "three";
ropeE: LIST OF ROPE ¬ LIST[ ropeA, ropeB, ropeC];
doc: ActiveDoc ← Create["RopeEnumTest"];
button: ActiveButton ← CreateRopeEnumerationButton[doc, "RTestButton", "two", ropeE]; -- variable: $Value
AddRopeEnumerationVariable[button: button, varName: "varOne", varVal: "one", type: ropeE];
AddRopeEnumerationVariable[button: button, varName: "varThree", varVal: "three", type: ropeE];
Instantiate[doc];
rope ¬ NARROW[EmbeddedButtons.GetValue[$RTestButton, doc, $Value], Rope.ROPE];
cmd.out.PutF1["value = \"%g\"\n", [rope[rope]]];
rope ¬ NARROW[EmbeddedButtons.GetValue[$RTestButton, doc, $varOne], Rope.ROPE];
cmd.out.PutF1["varOne = \"%g\"\n", [rope[rope]]];
rope ¬ NARROW[EmbeddedButtons.GetValue[$RTestButton, doc, $varThree], Rope.ROPE];
cmd.out.PutF1["varThree = \"%g\"\n", [rope[rope]]];
};
CTest: Commander.CommandProc = {
OPEN List, EBNullDoc, EmbeddedButtons;
atom: ATOM;
rope: ROPE;
ropeA: ROPE ¬ "one";
ropeB: ROPE ¬ "two";
ropeC: ROPE ¬ "three";
ropeE: LIST OF ROPE ¬ LIST[ ropeA, ropeB, ropeC];
doc: ActiveDoc ← Create["AtomTest"];
button: ActiveButton ← CreateATOMButton[doc, "CTestButton", $CTestAtom]; -- variable: $Value
Instantiate[doc];
SetValue[name: $CTestButton, variable: $dollarFoo, val: $Foo, doc: doc];
atom ¬ NARROW[EmbeddedButtons.GetValue[$CTestButton, doc, $CTestAtom], ATOM];
cmd.out.PutF1["CTestAtom = %g\n", [atom[atom]]];
atom ¬ NARROW[EmbeddedButtons.GetValue[$CTestButton, doc, $dollarFoo], ATOM];
cmd.out.PutF1["dollarFoo = %g\n", [atom[atom]]];
};
BTest: Commander.CommandProc = {
OPEN List, EBNullDoc, EmbeddedButtons;
bool: BOOL ¬ FALSE;
doc: ActiveDoc ← Create["DuckDock"];
button: ActiveButton ← CreateBOOLButton[doc, "TestButton", TRUE];
AddBOOLVariable[button, "falseBOOL", FALSE];
Instantiate[doc];
bool ¬ NARROW[EmbeddedButtons.GetValue[$TestButton, doc], REF BOOL]^;
cmd.out.PutF1["trueBOOL = %g\n", [boolean[bool]]];
};
Commander.Register["NullDocTest", Test, "Tests NullDocs"];
Commander.Register["NullDocETest", ETest, "Tests enumerations in NullDocs"];
Commander.Register["NullDocVTest", VTest, "Tests SetValue in NullDocs"];
Commander.Register["NullDocRTest", RTest, "Tests RopeEnumeration in NullDocs"];
Commander.Register["NullDocCTest", CTest, "Tests Atoms in NullDocs"];
Commander.Register["NullDocBTest", BTest, "Tests BOOLS in NullDocs"];
END.
­­­­­
&1 ← bdRope
"Poppy1\nClass: MultiStateButton\nVariables: (Value: BOOL = TRUE; falseBOOL: BOOL = FALSE )\n"