954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

C.L.O.S.E - Text Editor

0
By anuragcoder on May 31st, 2010 9:24 am

Hi guys,
Here's my project finally.
It's name is C.L.O.S.E - The Command Line Open Source Editor
Please review and comment.

Mention errors if any,
Also, for this code to work.
Please download open.cpp, find.cpp, new.cpp, append.cpp, compile them and place all of them including the main source in a single directory. Now compile main source and run.

Anurag.

#include <iostream>
#include <string>
#include <fstream>
#include <time.h>
#include <windows.h>

using namespace std;
char input[256];

void cls(){
     system("cls");
     }

void pause(){
     system("PAUSE");
     }

void help(){
     cout << "\t _________________________\t" << endl;
     cout << "\t|         HELP INFO       |\t" << endl;
     cout << "\t---------------------------\t" << endl;
     cout << "\t| CLS - Clear Screen      |\t" << endl;
     cout << "\t| OPEN - Open File        |\t" << endl;
     cout << "\t| NEW - New File          |\t" << endl;
     cout << "\t| FIND - Find in file     |\t" << endl;
     cout << "\t| APP - Append To File    |\t" << endl;
     cout << "\t| HELP - Show this text   |\t" << endl;
     cout << "\t| QUIT - Quit the program |\t" << endl;
     cout << "\t---------------------------\t" << endl;
     }
void splash(){
     system("title C.L.O.S.E V3 Enhanced.");
    int i = 4; //replace to 6
    while (i > 0)
    {
          if (i == 0, 2, 4,6)
          {
                system("color 2A");
                cout << "\n\n\n\n\n\n\n\n\n\n\t\t        C.L.O.S.E\t\t";
                  cout << "\n\t\tThe Command Line Open Source Editor. VERSION 3 ALPHA\t\t";
    cout << "\n\t\t   Inanimate Studios 2010. (C)Envy Inc. 2010\t\t";
    Sleep(500);
    system("cls");
 i--; 
             }
             if (i == 1, 3, 5) {
                  system("color 1A");
                  cout << "\n\n\n\n\n\n\n\n\n\n\t\t        C.L.O.S.E\t\t";
                  cout << "\n\t\tThe Command Line Open Source Editor. VERSION 3 ALPHA\t\t";
    cout << "\n\t\t   Inanimate Studios 2010. (C)Envy Inc. 2010\t\t";
    Sleep(500);
    system("cls");
 i--; 
                  }  
        }
}

void cmdline(){
     cout << "\tC.L.O.S.E -- THE NEW COMMAND LINE INTERFACE\t" << endl;
     string inp;
     do
     {
          cout << "|=>";
          cin >> inp;
          if(inp == "open"){
            system("open.exe");
            }
          if(inp == "new"){
            system("new.exe");
            }
          if(inp == "cls"){
            cls();
            }
          if(inp == "help"){
            help();
            }
          if(inp == "app"){
            system("append.exe");
            }
          if(inp == "find"){
            system("find.exe");
            }
          }while(inp != "quit");
     
     
     
          

}

int main(){
    splash();
    cmdline();
}

Personally I'm all against system() calls.

nbaztec
Posting Pro in Training
475 posts since May 2010
Reputation Points: 57
Solved Threads: 60
 

I have that itself on windows.
Can you please throw light on the topic?

anuragcoder
Junior Poster in Training
78 posts since May 2010
Reputation Points: 4
Solved Threads: 0
 

Also, a review of the program?
Suggestions
Comments.
Please

anuragcoder
Junior Poster in Training
78 posts since May 2010
Reputation Points: 4
Solved Threads: 0
 

Well for they tend to make your application slower & inefficient. It's like using your furniture to produce heat, or calling a bull-dozer to open your front door.
The events taking place upon calling system() are roughly the foll:
1. Suspends your program.
2. Calls the OS Shell. (Slowest Step)
3. OS Shell finds the command.
4. Allocates memory to execute it.
5. Executes it.
6. Deallocates memory
7. Exits the shell.
8. Resumes your program.

You can try using ShellExecute() or ShellExecuteEx(), clrscr() & getch()
for their respective purposes of opening a executable, clearing screen & pausing.

nbaztec
Posting Pro in Training
475 posts since May 2010
Reputation Points: 57
Solved Threads: 60
 

Yep.. thanks...
Okay.. lets see C.L.O.S.E V4....

clrscr() and gotoxy() aren't common/recognized functs i think
(Coz i use Dev C++)

anuragcoder
Junior Poster in Training
78 posts since May 2010
Reputation Points: 4
Solved Threads: 0
 

Anyway.... I Dont See any delay in my prog when I use system()

anuragcoder
Junior Poster in Training
78 posts since May 2010
Reputation Points: 4
Solved Threads: 0
 
Anyway.... I Dont See any delay in my prog when I use system()


That's because it's in milliseconds.

nbaztec
Posting Pro in Training
475 posts since May 2010
Reputation Points: 57
Solved Threads: 60
 

Haha hell yeah!

anuragcoder
Junior Poster in Training
78 posts since May 2010
Reputation Points: 4
Solved Threads: 0
 

What would you want in V4?

anuragcoder
Junior Poster in Training
78 posts since May 2010
Reputation Points: 4
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You