• Lucid Dreaming - Dream Views




    Results 1 to 9 of 9
    1. #1
      Member
      Join Date
      Jan 2008
      Gender
      Location
      Canada
      Posts
      63
      Likes
      0

      C++ Reality Checker

      Compile it if you want or download it here. Ive posted this before but I just though id put a copy of the script here. And I know the headers are messed.

      Code:
      // Lucid Dream
      #include <iostream>
      #include <string>
      #include <sstream>
      #include <cstdlib>
      #include <iostream>
      #include <time.h>
      #include <windows.h>
      #include <string>
      #include <fstream>
      #include <iostream>
      #include <windows.h>
      #include <stdio.h>
      #include <winuser.h>
      #include <iostream>
      #include <fstream>
      #include <iostream>
      #include <string>
      #include <sstream>
      #include <cstdlib>
      #include <iostream>
      #include <time.h>
      #include <windows.h>
      #include <string>
      #include <cstdlib> 
      #include <ctime>
      using namespace std;
      
      int main()
      
      {
          
        int value=0; 
        string reminder;
      
      system("title Reality Checker v1.0");
      cout << "Welcome to the Reality Checker v1.0\n\n" << endl;
      cout << "This program is freeware, so spread it around as much as you like." << endl;
      cout << "Happy deamin!" << endl;
      cout << "\nCreated by: David Seviour (virus.exe) in 2008" << endl; 
      
      
      
      system("pause");
      system("cls");
      cout << "How often do you want to be reminded to reality check?\nPlease type 15, 30, 60 or 120 (time in minutes)" << endl;
      cin >> value;
      
              
          HWND stealth; /*creating stealth (window is not visible)*/
          AllocConsole();
          stealth=FindWindowA("ConsoleWindowClass",NULL);
          ShowWindow(stealth,0);    
          
          
          if(value == 15) {goto loop15;} 
          if(value == 30) {goto loop30;} 
          if(value == 60) {goto loop60;}
          if(value == 120) {goto loop120;}
      
      return 0;    
          
          
         
      loop15:
             
             
      system("cls");
      
      MessageBox(0,"You will be reminded every 15 minutes!","Reality Check",MB_OK);
      
      loop15two:
      
      
      Sleep(900000);
      
      
      if (MessageBox(NULL, "Reality Check Now!!!\n\n Cancel  = close program\n Ok  = continue 15 minute reminders", "Reality Check", MB_OKCANCEL)
      == IDCANCEL)
      {
              
      goto end;
      
      }
          
      
      goto loop15two;
      
      
      
      
      
      loop30:
      
      system("cls");
              MessageBox(0,"You will be reminded every 30 minutes!","Reality Check",MB_OK);
      loop30two:
          
      Sleep(1800000);
      
      
      
      if (MessageBox(NULL, "Reality Check Now!!!\n\n Cancel  = close program\n Ok  = continue 30 minute reminders", "Reality Check", MB_OKCANCEL)
      == IDCANCEL)
      {
              
      goto end;
      
      }
          
      
          
      goto loop30two;
      
      
      
      
      loop60:
      
      system("cls");
              MessageBox(0,"You will be reminded every 60 minutes!","Reality Check",MB_OK);
      loop60two:
          
      Sleep(3600000);
      
      
      
      
      if (MessageBox(NULL, "Reality Check Now!!!\n\n Cancel  = close program\n Ok  = continue 60 minute reminders", "Reality Check", MB_OKCANCEL)
      == IDCANCEL)
      {
              
      goto end;
      
      }
          
      
      
      
      goto loop60two;
      
      
      loop120:
      
      system("cls");
              MessageBox(0,"You will be reminded every 120 minutes!","Reality Check",MB_OK);
      loop120two:
          
      Sleep(7200000);
      
      
      
      
      if (MessageBox(NULL, "Reality Check Now!!!\n\n Cancel  = close program\n Ok  = continue 120 minute reminders", "Reality Check", MB_OKCANCEL)
      == IDCANCEL)
      {
              
      goto end;
      
      }
          
      
      
      
      goto loop120two;
      
      end:
      return 0;
      
      
      }

    2. #2
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      dear lord....
      (\_ _/)
      (='.'=)
      (")_(")

    3. #3
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      **shudders @ gotos, unnecessary includes, gotos, choice of technology, gotos, and not to mention the gotos**

    4. #4
      Banned
      Join Date
      May 2007
      LD Count
      Loads
      Gender
      Location
      Digital Forest.
      Posts
      6,864
      Likes
      386
      #include <windows.h>

    5. #5
      Member
      Join Date
      Jan 2008
      Gender
      Location
      Canada
      Posts
      63
      Likes
      0
      Quote Originally Posted by Replicon View Post
      **shudders @ gotos, unnecessary includes, gotos, choice of technology, gotos, and not to mention the gotos**
      I can add a few more if you want

    6. #6
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      Quote Originally Posted by virusexe View Post
      I can add a few more if you want
      You've already used up your share of gotos, as well as your children's and their children's
      Last edited by Replicon; 03-08-2008 at 10:28 AM.

    7. #7
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points
      tyrantt23's Avatar
      Join Date
      Nov 2004
      Gender
      Location
      Bay Area, CA (USA)
      Posts
      848
      Likes
      1
      cout << "Happy deamin!" << endl;
      Also, there's a typo in there.

      Not a bad idea for a program, but I'd preferably want it to run on my Linux.

      Adopted: mystqjaq
      Raised by: Seeker
      My Dream Journal | My Aquarium | Myspace | Facebook Me | Stickam

    8. #8
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Ugh, Windows API. Use GLUT instead, it's cross platform and much easier to work with. You'll probably find it in OpenGL/GLUT.h

      What IDE are you using? It should be yelling at you that you have unused headers.

      Gotos , use methods instead. Let's write some pseudocode:

      Code:
      int main(void){
         Create GLUT window
         setup the GlutKeys() function
         setup the GlutIdleFunc() function
         Prompt for how often to do a reality check  'don't restrict to 15 min increments
         call GlutMainLoop()
      }
      
      idle(){
         long t = time + howoften
         while (true){
            if (time > t){
               RealityCheck();
               t = time + howoften;
            }
         }
      }
      
      keys(int key){
         select case(key){
            case 'x':
               exit(0);
               break;
         }
      }
      
      void RealityCheck(){
         Create new Glut window with RC message
      }
      There you go: no goto calls, no platform specific API, can set it for any time.

    9. #9
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      Or, it's trivial to just do something like this in javascript:

      Code:
      setInterval("doRC()", intervalMinutes * 60000);
      Where doRC does whatever you want it to do (opening a window for a few seconds to get your attention and auto-closing it is really easy to do).

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •