-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmarkulie-xCalc-v0.1.mel
127 lines (109 loc) · 3.26 KB
/
markulie-xCalc-v0.1.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
xCalc
Author: Markulie
Created on: 18 December 2014
Version: 0.1
Description: Simple Calculator for Maya
*/
global float $gnumber1 = 0;
global float $gnumber2 = 0;
global float $ganswer = 0;
global string $goperator = "";
global string $gfieldAnswer = "";
global proc equals (float $number1, string $operator)
{
float $answer;
float $number2;
string $fieldAnswer;
$number2 = `textField -q -text display`;
switch ($operator)
{
case "+":
$answer = $number1 + $number2;
break;
case "-":
$answer = $number1 - $number2;
break;
case "*":
$answer = $number1 * $number2;
break;
case "/":
$answer = $number1 / $number2;
break;
}
textField -e -text "" display;
$fieldAnswer = $answer;
textField -e -text $fieldAnswer display;
}
global proc xcalc ()
{
global string $goperator;
global float $gnumber1;
global float $gnumber;
global float $ganswer;
if (`window -exists calculatorWindow`) { deleteUI calculatorWindow; }
window -widthHeight 150 153
-title "xCalc"
calculatorWindow;
columnLayout;
textField -width 125 -height 30
-insertionPosition 0
display;
gridLayout -numberOfColumns 5 -cellWidthHeight 25 25;
button -label "7"
-command "textField -e -insertText \"7\" display";
button -label "8"
-command "textField -e -insertText \"8\" display";
button -label "9" -annotation "Help for C"
-command "textField -e -insertText \"9\" display";
text " ";
button -label "C"
-command "textField -e -text \"\" display;\
$goperator = \"\";\
$gnumber1 = 0;\
$gnumber2 = 0;\
$ganswer = 0;\
";
button -label "4"
-command "textField -e -insertText \"4\" display";
button -label "5"
-command "textField -e -insertText \"5\" display";
button -label "6"
-command "textField -e -insertText \"6\" display";
button -label "*"
-command "$gnumber1 = `textField -q -text display`;\
textField -e -text \"\" display;\
$goperator = \"*\";\
";
button -label "/"
-command "$gnumber1 = `textField -q -text display`;\
textField -e -text \"\" display;\
$goperator = \"/\";\
";
button -label "1"
-command "textField -e -insertText \"1\" display";
button -label "2"
-command "textField -e -insertText \"2\" display";
button -label "3"
-command "textField -e -insertText \"3\" display";
button -label "+"
-command "$gnumber1 = `textField -q -text display`;\
textField -e -text \"\" display;\
$goperator = \"+\";\
";
button -label "-"
-command "$gnumber1 = `textField -q -text display`;\
textField -e -text \"\" display;\
$goperator = \"-\";\
";
text -label "info" -annotation "xCalc 0.1";
button -label "0"
-command "textField -e -insertText \"0\" display";
button -label "."
-command "textField -e -insertText \".\" display";
text " ";
button -label "="
-command "equals $gnumber1 $goperator;";
window -e -widthHeight 127 130 calculatorWindow;
showWindow;
}