Not much has been happening
| February 5th, 2009Which is why I haven’t posted. I have, however, decided I will once again try to learn how to program, this time C# through Mono.
Here is what I have so far:
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
using System;
using System.IO;
namespace ToDoList
{
class MainClass
{
public static void Main(string[] args)
{
var numberof = 0;
var usage = “Usage: –list | –add | –del | –reset”;
var counter = 1;
var contents = File.ReadAllLines(“todo.txt”);
if(args.Length == 0) {
Console.WriteLine(usage);
return;
}
if (args.Length == 1 && args[0]==”–add”){
Console.WriteLine(usage);
return;
}
if (args.Length == 1 && args[0]==”–del”){
Console.WriteLine(usage);
return;
}
if (args.Length == 1 && args[0]!=”–list” && args[0]!=”–reset”){
Console.WriteLine(usage);
return;
}
if (args[0] == “–add”) {
File.AppendAllText(“todo.txt”, args[1] + “\n”);
} else if(args[0] == “–del”) {
File.Delete(“todo.txt”);
var deleteme = int.Parse(args[1]);
foreach (var item in contents){
if(counter != deleteme){
File.AppendAllText(“todo.txt”, item +”\n”);
}
counter++;
}
}
else if (args[0]==”–reset”){
File.Create(“todo.txt”);
}
else if (args[0]==”–list”) {
foreach(var number in contents){
numberof++;
}
Console.WriteLine(“Number of items: ” + numberof);
foreach(var item in contents){
Console.WriteLine(counter + “: ” + item);
counter++;
}
}
}
}
}
On other matters, I am considering removing Linux from the blog’s title. Maybe if I restrict my topic choice less I will post some more stuff :P