You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 7Sharp/Intrerpreter/Sysfunctions.cs
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ namespace _7Sharp.Intrerpreter
7
7
{
8
8
internalclassSysFunctions
9
9
{
10
+
[ManualDocs("double","{\"title\":\"double(o)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"double(<object>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Convert \"},{\"text\":\"o\",\"color\":\"Green\"},{\"text\":\" to a double (64-bit floating-point number)\"}]}]}")]
10
11
publicstaticdoubleDouble(objectvalue)
11
12
{
12
13
try
@@ -27,6 +28,27 @@ public static double Double(object value)
27
28
}
28
29
}
29
30
31
+
[ManualDocs("int","{\"title\":\"int(o)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"int(<object>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Convert \"},{\"text\":\"o\",\"color\":\"Green\"},{\"text\":\" to an int (32-bit integer)\"}]}]}")]
32
+
publicstaticintInt(objectvalue)
33
+
{
34
+
try
35
+
{
36
+
returnConvert.ToInt32(value);
37
+
}
38
+
catch(OverflowException)
39
+
{
40
+
thrownewInterpreterException("int: Number is too big!");
[ManualDocs("write","{\"title\":\"write(value)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"Outputs \"},{\"text\":\"value\",\"color\":\"Green\"},{\"text\":\" to the console, followed by a newline.\"}]}]}")]
[ManualDocs("sqrt","{\"title\":\"sqrt(x)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"sqrt(<number>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Takes the square root of\"},{\"text\":\"x\",\"color\":\"Green\"},{\"text\":\".\"}]}]}")]
127
150
publicstaticdoubleSqrt(doublex)=>Math.Sqrt(x);
128
151
152
+
[ManualDocs("pow","{\"title\":\"pow(x, n)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"pow(<number>, <number>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Raise \"},{\"text\":\"x\",\"color\":\"Green\"},{\"text\":\" to the power of \"},{\"text\":\"n\",\"color\":\"Green\"}]}]}")]
[ManualDocs("fgColor","{\"title\":\"fgColor(color)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"fgColor(<color number or name>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Set the text color to \"},{\"text\":\"color\",\"color\":\"Green\"}]},{\"header\":\"Valid colors\",\"text\":[{\"text\":\"BLACK BLUE CYAN DARK_BLUE DARK_CYAN DARK_GRAY DARK_GREEN DARK_MAGENTA DARK_RED DARK_YELLOW GRAY GREEN MAGENTA RED WHITE YELLOW\",\"color\":\"Cyan\"}]}]}")]
131
156
publicstaticvoidFgColor(intcolor)
132
157
{
133
158
if(color<0||color>15)
@@ -137,6 +162,7 @@ public static void FgColor(int color)
137
162
Console.ForegroundColor=(ConsoleColor)color;
138
163
}
139
164
165
+
[ManualDocs("bgColor","{\"title\":\"bgColor(color)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"bgColor(<color number or name>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Set the background color to \"},{\"text\":\"color\",\"color\":\"Green\"},{\"text\":\". call \"},{\"text\":\"clear()\",\"color\":\"Yellow\"},{\"text\":\"to if you want to set the background color of the whole screen, because \"},{\"text\":\"bgColor(color)\",\"color\":\"Yellow\"},{\"text\":\" only affects the background color of new printed text.\"}]},{\"header\":\"Valid colors\",\"text\":[{\"text\":\"BLACK BLUE CYAN DARK_BLUE DARK_CYAN DARK_GRAY DARK_GREEN DARK_MAGENTA DARK_RED DARK_YELLOW GRAY GREEN MAGENTA RED WHITE YELLOW\",\"color\":\"Cyan\"}]}]}")]
140
166
publicstaticvoidBgColor(intcolor)
141
167
{
142
168
if(color<0||color>15)
@@ -146,6 +172,7 @@ public static void BgColor(int color)
146
172
Console.BackgroundColor=(ConsoleColor)color;
147
173
}
148
174
175
+
[ManualDocs("resetColor","{\"title\":\"resetColor()\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"resetColor();\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Reset the console colors back to their defaults.\"}]}]}")]
0 commit comments