Checklist 1.0

BruceJohnJennerLawso

Dread Lord of the Idiots
Addon Developer
Joined
Apr 14, 2012
Messages
2,585
Reaction score
0
Points
36
Hello Everyone,

Im proud to release the first working version of Checklist, a command line program that allows you to create and execute Checklists from a text file; pretty much what it sounds like :lol:

View attachment 12117

Ive attached an example of a checklist file, based on the ground startup sequence for the DGIV. Feel free to create more if you like and post them here.

Not sure how useful this may be, but it could be handy when running Orbiter on a second screen. Suggestions on how to improve it are welcome.

Instructions for use: If you dont know what to do, just enter 'help' ;)
The program will explain things for you.

Current Source Code:

Code:
// Checklist 1.0
// A checklist program for checking things off of lists. Well what did you want me to write? Im a programmer not a poet!
#include <iostream>
#include <math.h>
#include <string>
#include <new>
#include <vector>
#include <exception>
#include <fstream>
#include "Task.h"
#include <algorithm>
#include <cctype>
#define NEWLINE '\n'
#define TAB '\t'
#define VTAB '\v'
#define BEEP '\a'
#define BACK '\b'
using namespace std;

void MainMenu();
void FileMenu();
void FileSelectMenu();
void OutputLine(int a, string Filename);
void InitTasks(string Filename);
int InputFile(string Filename);
void OutputTasklist ();
void RunTasklist ();
void OutputTask(int fidx);
void OutputTaskState(int fidx);
void CreateTask(int fidx);
int GiveameINPUTint ();
int data;
string FName;

vector<CTask> Tasklist;
vector<CTask>::iterator it;

void MainMenu()
{
		cout << "------------------------Checklist 1.0 by John Lawson---------------------------" << endl;
		cout << NEWLINE;
		cout << "--Main Menu--" << NEWLINE << endl;

		while (true) 
		{	string i;
			cin >> i;
			cout << NEWLINE;
			transform (i.begin (), i.end (), i.begin (), toupper);
			if (i == "ESC")
			{	cout << NEWLINE << endl;
				break;		}
			else if ((i == "QUIT") || (i == "EXIT"))
			{	break;		}
			else if ((i == "SELECT") || (i == "SELECT_FILE"))
			{	FileSelectMenu();
				cout << "--Main Menu--" << NEWLINE << endl;						}
			else if (i == "HELP")
			{	cout << NEWLINE;
				cout << "Enter Select File to load a Tasklist" << endl;	//Either Read Tasks, Run Tasks, or Add Tasks (future idea)
				cout << "Enter Quit, Exit, or Esc to end program" << NEWLINE << endl;		}
			else
			{	cout << NEWLINE << endl;		}	}	}

void FileSelectMenu()
{	int e;	
	cout << "--File Select Menu--" << NEWLINE << endl;
	while (true)
	{	string FSelect;
		cin >> FSelect;
		cout << NEWLINE << endl;
		string FCompare = FSelect;
		transform (FCompare.begin (), FCompare.end (), FCompare.begin (), toupper);
		if (FCompare == "ESC")
		{	cout << NEWLINE;
			break;	}
		else if (FCompare == "HELP")
		{	cout << "Enter File name to read or ESC to go to the Main Menu" << NEWLINE << endl;		}
		else
		{	e = InputFile(FSelect);
			if (e == 0)
			{	cout << "File " << FName << " Selected." << NEWLINE << endl;
				InitTasks(FName);
				FileMenu();		}
			else if (e != 0)
			{	cout << "Unable to open file. Error # " << e << NEWLINE << endl;	}	}	}	}

void FileMenu()
{	cout << "--File Menu--" << NEWLINE << endl;	
	while(true)
	{	string FSelect;
		cin >> FSelect;
		cout << NEWLINE;
		transform (FSelect.begin (), FSelect.end (), FSelect.begin (), toupper);
		if (FSelect == "READ")
		{	OutputTasklist();
			cout << NEWLINE;	}
		else if (FSelect == "RUN")
		{	cout << "((RUN mode WIP))" << NEWLINE << endl;
			RunTasklist();
			cout << NEWLINE;	}
		else if (FSelect == "ESC")
		{	cout << NEWLINE << endl;
			cout << "--File Select Menu--" << NEWLINE << endl;
			break;		}
		else if (FSelect == "HELP")
		{	cout << NEWLINE;
			cout << "Enter Read to view tasks or Run to work on the selected tasklist" << endl;	//Either Read Tasks, Run Tasks, or Add Tasks (future idea)
			cout << "Enter Esc to go back to the File Select Menu" << NEWLINE << endl;		}	}	}

int InputFile(string Filename)
{		string Fstring = Filename;
		Fstring.insert (Fstring.end(), 1, '.');		//All together now...
		Fstring.insert (Fstring.end(), 1, 't'); 
		Fstring.insert (Fstring.end(), 1, 'x'); 
		Fstring.insert (Fstring.end(), 1, 't');
		ifstream readfile (Fstring);
		if (readfile.is_open())
		{	readfile.close();
			FName = Fstring;
			return 0;	}
		else if (readfile.fail())
		{	return 1;	}
		else
		{	return 99;	}	}	// 99 would indicate something is reaally wrong here. 
								// Just inserted to shut the compiler up about unfulfilled control paths & destiny, or whatever.
void InitTasks(string Filename)
{	int n = 0;
	ifstream readfile (Filename);
	if (readfile.is_open())
	{	while (!readfile.eof())
		{	n++;
			string line;
			getline (readfile, line);
			transform (line.begin (), line.end (), line.begin (), toupper);
			if (line == "ITEM")
			{	CreateTask(n);	}		}
			readfile.close();	}	}

void RunTasklist ()
{	for (vector<CTask>::iterator it = (Tasklist.end()-1); it != (Tasklist.begin()-1); --it)
	{	OutputTask(it->TAddress);
		while (true)
		{	cout << NEWLINE;
			string vftask;
			cin >> vftask;
			cout << NEWLINE << endl;
			transform (vftask.begin (), vftask.end (), vftask.begin (), toupper);	
			if (vftask == "EXE")
			{	it->ExecutionTrue();
				break;	}
			else if (vftask == "SKIP")
			{	it->ExecutionFalse();
				break;	}
			else if (vftask == "HELP")
			{	cout << NEWLINE;
				cout << "Enter 'Exe' to verify task execution." << endl;
				cout << "Enter 'Skip' to jump to the next task while incomplete." << NEWLINE << endl;	}	}	}
			cout << "End Tasklist" << endl;	}

void CreateTask(int fidx)
{	Tasklist.emplace(Tasklist.begin(), (fidx));		}

void OutputTask(int fidx)
{	int lholder = fidx;
	lholder++;
	cout << NEWLINE;
	OutputLine(lholder, FName);
	lholder++;
	cout << NEWLINE;
	OutputLine(lholder, FName);
	lholder++;
	OutputLine(lholder, FName);
	lholder++;
	OutputLine(lholder, FName);		}	

void OutputTaskState(int fidx)
{	int lholder = fidx;
	lholder++;
	cout << NEWLINE;
	OutputLine(lholder, FName);
									}	

void OutputLine(int a, string Filename)
{	int n = 0;
	ifstream readfile (Filename);
	if (readfile.is_open())
	{	while (!readfile.eof())
		{	string line;
			getline (readfile, line);
			n++;
			if (a == n)
			{	cout << line << endl;	}	}
				readfile.close();	}	}

void OutputTasklist()
{	for (vector<CTask>::iterator it = (Tasklist.end()-1); it != (Tasklist.begin()-1); --it)
	{	OutputTask(it->TAddress);	}	}

int GiveameINPUTint ()
{	while(true)
	{	cin >> data;
		if (!cin.fail())
			{	return data;	}
			cin.clear();
			cin.ignore();	}	}

int main ()
{	try
	{	MainMenu();		}
	catch (exception& e)
	{	cout << "Standard Exception: " << e.what() << endl;	}
	cout << "Hail The Probe!!!";
	return 0;
}



Class CTask:

Code:
#pragma once
#include <iostream>
#include <string>
#include <new>
#include <vector>
using namespace std;

class CTask
{	public:
	CTask(void);
	CTask(int Descindex);
	int TAddress;
	bool Executed;
	void ExecutionTrue();
	void ExecutionFalse();
	~CTask(void);	};

Code:
#include "Task.h"
#include <iostream>
#include <string>
#include <new>
#include <vector>
#define NEWLINE '\n'
using namespace std;

CTask::CTask(void)
{	Executed = false;	}

CTask::CTask(int Descindex)
{	TAddress = Descindex;
	Executed = false;	}

void CTask::ExecutionTrue()
{	Executed = true;	}

void CTask::ExecutionFalse()
{	Executed = false;	}

CTask::~CTask(void)
{						}

:hailprobe:
 
Last edited:
Top