Skip to content

Commit 2b578a6

Browse files
committed
A radical change to simplify
1 parent 2aba620 commit 2b578a6

File tree

1 file changed

+41
-52
lines changed

1 file changed

+41
-52
lines changed

Function.cs

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22
{
33
public class Function
44
{
5-
static string Path = "";
6-
public Function(string path, string contents = "")
5+
public string Path = "";
6+
public List<string> Body { get; set; }
7+
public Function(string path, List<string> body)
78
{
89
Path = FileOrganizer.GetFunctionPath(path);
9-
if (!File.Exists(path))
10-
{
11-
FileOrganizer.CreateFullDirectory(Path, true);
12-
Displays.NewFunction(path);
13-
} else
14-
{
15-
Displays.ExtendedFunction(path);
16-
}
17-
Thread.Sleep(10);
18-
File.WriteAllText(Path, contents);
19-
Thread.Sleep(10);
10+
Body = body;
11+
Displays.NewFunction(path);
12+
// if (!File.Exists(path))
13+
// {
14+
// FileOrganizer.CreateFullDirectory(Path, true);
15+
// Displays.NewFunction(path);
16+
// } else
17+
// {
18+
// Displays.ExtendedFunction(path);
19+
// }
20+
// Thread.Sleep(10);
21+
// File.WriteAllText(Path, contents);
22+
// Thread.Sleep(10);
2023
}
2124
public void PrependCommands(string[] commands)
2225
{
@@ -50,15 +53,6 @@ public bool WriteAllCommands(string[] commands)
5053
return false;
5154
}
5255
}
53-
public static void WriteAllFunctions(Function[] functions){
54-
try {
55-
foreach(Function f in functions){
56-
f.WriteAllCommands(new string[] { f.GetAllCommands(Path) });
57-
}
58-
} catch(IOException e) {
59-
Console.WriteLine(e);
60-
}
61-
}
6256
public string Return(int i)
6357
{
6458
return "return " + i;
@@ -67,35 +61,30 @@ public string Call(string function)
6761
{
6862
return "function " + function;
6963
}
70-
public string GetAllCommands(string path)
71-
{
72-
Thread.Sleep(10);
73-
return File.ReadAllText(path);
74-
}
75-
public string Extend(string function, string[] commands, bool createFunction = false)
76-
{
77-
try
78-
{
79-
Thread.Sleep(10);
80-
string path = FileOrganizer.GetFunctionPath(function);
81-
string origin = Path;
82-
if(createFunction == false)
83-
{
84-
Function ExtendedFunction = new Function(function, GetAllCommands(function) + "\n## Extended from " + origin + "\n");
85-
ExtendedFunction.PrependCommands(commands);
86-
} else
87-
{
88-
Function ExtendedFunction = new Function(function, "## Created from " + origin + "\n");
89-
ExtendedFunction.PrependCommands(commands);
90-
}
91-
Displays.ExtendedFrom(path, origin);
92-
Thread.Sleep(10);
93-
return "function " + function;
94-
} catch(IOException e)
95-
{
96-
Console.WriteLine(e.Message);
97-
return "";
98-
}
99-
}
64+
// public string Extend(string function, string[] commands, bool createFunction = false)
65+
// {
66+
// try
67+
// {
68+
// Thread.Sleep(10);
69+
// string path = FileOrganizer.GetFunctionPath(function);
70+
// string origin = Path;
71+
// if(createFunction == false)
72+
// {
73+
// Function ExtendedFunction = new Function(function, GetAllCommands(function) + "\n## Extended from " + origin + "\n");
74+
// ExtendedFunction.PrependCommands(commands);
75+
// } else
76+
// {
77+
// Function ExtendedFunction = new Function(function, "## Created from " + origin + "\n");
78+
// ExtendedFunction.PrependCommands(commands);
79+
// }
80+
// Displays.ExtendedFrom(path, origin);
81+
// Thread.Sleep(10);
82+
// return "function " + function;
83+
// } catch(IOException e)
84+
// {
85+
// Console.WriteLine(e.Message);
86+
// return "";
87+
// }
88+
// }
10089
}
10190
}

0 commit comments

Comments
 (0)