Can someone help me with this Program.......? Pretty-please.....?? :3

B

blackneos940

Guest
*Throws C Code at your face.* :3
Code:
/*This Program is released under the GNU GPL Version 2, or, at your option, any later version. See https://www.gnu.org/licenses/gpl-2.0.html for more details. However, I will condense it for you. You can modify this Program HOWEVER you want. You are encouraged to share it with others. There's more to this License, but that's the crux of it.*/

#include <stdio.h>

#include <windows.h>

#include <stdlib.h>

int main(void)

{
  printf ("Welcome to the bastardized wannabe GUI for Redshift on Windows!\nSelect from 1-6, to adjust the Color Temperature. (Hint: The more Red it is, the easier it will be on your Eyes at Night [or if you've stayed up all night and it's day]. Y'know, those balls in your Head? Yeah, don't be a a Sociopath to them. [Make it TOO Red, however, and you'll be seeing... Red. But you just might like it.]) Also, Blue Moon is SO Blue, it'll have you downing a bottle of Aspirin pretty quickly. But hey, at least you won't feel anything anymore..... Isn't that what you wanted, Senpai?\n\n1: Red Moon\n2: Ember\n3: Salmon\n4: Diabetic Blood\n5: Day\n6: Blue Moon\n>>>");

  int choice;

  choice = scanf("Pick a Number.", &choice);

  if (choice == 1)

    system("redshift -O 1000k");

  if (choice == 2)

    system("redshift -O 1200k");

  if (choice == 3)

  system("redshift -O 1360k");

  if (choice == 4)

    system("redshift -O 1700k");

  if (choice == 5)

    system("redshift -O 6500k");

if (choice == 6)

  system("redshift -O 25000k");

  return 0;

}

Basically, as you can see, like the Terminal, the system() Function is used to, well, run Redshift..... :) I know most of you guys don't run Windows, but, since Redshift on the Linux Terminal probably takes the same Arguments, I think maybe you can see where I'm heading with this Program..... :) My problem is this: It won't run Redshift this way, though in CMD and Powershell, these same Commands DO work..... :\ Also, in an earlier version of the Program, I passed in "bash" to the system() Function, just to see if it DID register, and..... It did..... :( Why, oh why, won't it call up Redshift though.....? :'( I wrote this Program so I could automate the Color Temp calibration easier..... :( Also, there's a Hurricane coming through the East Coast..... Better get this question out there before I lose all Internet.....! :O Thanks for any help, guys!..... ^^ *The Admins look on with dismay, as blackneos940's Topic is created on their Server, taking up yet more space. Arochester sighs, and changes blackneos' Profile name to Gimpy.*
 


Redshift is executing normally outside your program call, via command line?
 
There was an error with the scanf() statement. You should always check the return valuse from scanf().

In addition, I have altered the code as you will see. A switch statement works better here than multiple if() statements.
Code:
/* This Program is released under the GNU GPL Version 2, or, at your option,
  any later version.

  See https://www.gnu.org/licenses/gpl-2.0.html for more details.

  However, I will condense it for you. You can modify this Program
  HOWEVER you want. You are encouraged to share it with others. There's more
  to this License, but that's the crux of it.
*/

#include <stdio.h>
#include <stdlib.h>

/* I am compiling on Linux. */
/* #include <windows.h> */

int main(void)
{
  int choice = 0;                /* Holds the choice number.  */
  int retval = 0;                /* Return values from scanf() */

  /* You need to clean up the instructions. This is a start.    */

  printf("Welcome to the bastardized wannabe GUI for Redshift on Windows!\n\n");
  printf("Select from 1-6, to adjust the Color Temperature. (Hint: The more Red\n");
  printf("it is, the easier it will be on your Eyes at Night [or if you've stayed\n");
  printf("up all night and it's day]. Y'know, those balls in your Head? Yeah, don't\n");
  printf("be a a Sociopath to them. [Make it TOO Red, however, and you'll be seeing...\n");
  printf("Red. But you just might like it.]) Also, Blue Moon is SO Blue, it'll have\n");
  printf("you downing a bottle of Aspirin pretty quickly. But hey, at least you won't\n");
  printf("feel anything anymore..... Isn't that what you wanted, Senpai?\n\n");
  printf("1: Red Moon\n2: Ember\n3: Salmon\n4: Diabetic Blood\n5: Day\n6: Blue Moon\n>>>");


  /*  You need to split this into two function calls            */
  /*  choice = scanf("Pick a Number.", &choice);                */

  printf("Pick a number. ");      /* Prompt the user.          */
  retval = scanf("%d", &choice);  /* Input "choice"            */

  if(retval == 0)                  /* Unknown scanf() error      */
  {
      printf("\nIncorrect input.\n");
      return EXIT_FAILURE;          /* Better than "return 1;"    */
  }

  /* Instead of multiple "if" statements, use switch instead.    */

  switch(choice)
  {
      case 1:
        system("redshift -O 1000k");
        break;
      case 2:
        system("redshift -O 1200k");
        break;
      case 3:
        system("redshift -O 1360k");
        break;
      case 4:
        system("redshift -O 1700k");
        break;
      case 5:
        system("redshift -O 6500k");
        break;
      case 6:
        system("redshift -O 25000k");
        break;
      default:
        printf("\nIllegal entry: %d\n", choice);
        break;
  }

  return EXIT_SUCCESS;            /* Better than "return 0;"    */
}
 
Redshift is executing normally outside your program call, via command line?
Yes..... :) Honestly, after I created this Thread, I had a thought..... :) What if system() only accepts standard POSIX and NT Commands.....? :) But wait..... :\ I was able to run BASH from CMD, as I have Cygwin...... Maybe there's something I'm missing here.....? :(
 
There was an error with the scanf() statement. You should always check the return valuse from scanf().

In addition, I have altered the code as you will see. A switch statement works better here than multiple if() statements.
Code:
/* This Program is released under the GNU GPL Version 2, or, at your option,
  any later version.

  See https://www.gnu.org/licenses/gpl-2.0.html for more details.

  However, I will condense it for you. You can modify this Program
  HOWEVER you want. You are encouraged to share it with others. There's more
  to this License, but that's the crux of it.
*/

#include <stdio.h>
#include <stdlib.h>

/* I am compiling on Linux. */
/* #include <windows.h> */

int main(void)
{
  int choice = 0;                /* Holds the choice number.  */
  int retval = 0;                /* Return values from scanf() */

  /* You need to clean up the instructions. This is a start.    */

  printf("Welcome to the bastardized wannabe GUI for Redshift on Windows!\n\n");
  printf("Select from 1-6, to adjust the Color Temperature. (Hint: The more Red\n");
  printf("it is, the easier it will be on your Eyes at Night [or if you've stayed\n");
  printf("up all night and it's day]. Y'know, those balls in your Head? Yeah, don't\n");
  printf("be a a Sociopath to them. [Make it TOO Red, however, and you'll be seeing...\n");
  printf("Red. But you just might like it.]) Also, Blue Moon is SO Blue, it'll have\n");
  printf("you downing a bottle of Aspirin pretty quickly. But hey, at least you won't\n");
  printf("feel anything anymore..... Isn't that what you wanted, Senpai?\n\n");
  printf("1: Red Moon\n2: Ember\n3: Salmon\n4: Diabetic Blood\n5: Day\n6: Blue Moon\n>>>");


  /*  You need to split this into two function calls            */
  /*  choice = scanf("Pick a Number.", &choice);                */

  printf("Pick a number. ");      /* Prompt the user.          */
  retval = scanf("%d", &choice);  /* Input "choice"            */

  if(retval == 0)                  /* Unknown scanf() error      */
  {
      printf("\nIncorrect input.\n");
      return EXIT_FAILURE;          /* Better than "return 1;"    */
  }

  /* Instead of multiple "if" statements, use switch instead.    */

  switch(choice)
  {
      case 1:
        system("redshift -O 1000k");
        break;
      case 2:
        system("redshift -O 1200k");
        break;
      case 3:
        system("redshift -O 1360k");
        break;
      case 4:
        system("redshift -O 1700k");
        break;
      case 5:
        system("redshift -O 6500k");
        break;
      case 6:
        system("redshift -O 25000k");
        break;
      default:
        printf("\nIllegal entry: %d\n", choice);
        break;
  }

  return EXIT_SUCCESS;            /* Better than "return 0;"    */
}

Brilliant!!..... :3 I had thought of using Switch Statements, but I felt too intimidated by them..... :( I guess I'm more perceptive than I thought!..... :3 I thought to myself that Switch Statements would be better than If Statements..... :D Ok, I'll Pasted that into the C File, un-comment the #include Preprocessing Directive for Window, and Compile and Run it!..... (Of course, I'll use GCC..... :) That is simply the BEST way to do this....... ;))
 
There was an error with the scanf() statement. You should always check the return valuse from scanf().

In addition, I have altered the code as you will see. A switch statement works better here than multiple if() statements.
Code:
/* This Program is released under the GNU GPL Version 2, or, at your option,
  any later version.

  See https://www.gnu.org/licenses/gpl-2.0.html for more details.

  However, I will condense it for you. You can modify this Program
  HOWEVER you want. You are encouraged to share it with others. There's more
  to this License, but that's the crux of it.
*/

#include <stdio.h>
#include <stdlib.h>

/* I am compiling on Linux. */
/* #include <windows.h> */

int main(void)
{
  int choice = 0;                /* Holds the choice number.  */
  int retval = 0;                /* Return values from scanf() */

  /* You need to clean up the instructions. This is a start.    */

  printf("Welcome to the bastardized wannabe GUI for Redshift on Windows!\n\n");
  printf("Select from 1-6, to adjust the Color Temperature. (Hint: The more Red\n");
  printf("it is, the easier it will be on your Eyes at Night [or if you've stayed\n");
  printf("up all night and it's day]. Y'know, those balls in your Head? Yeah, don't\n");
  printf("be a a Sociopath to them. [Make it TOO Red, however, and you'll be seeing...\n");
  printf("Red. But you just might like it.]) Also, Blue Moon is SO Blue, it'll have\n");
  printf("you downing a bottle of Aspirin pretty quickly. But hey, at least you won't\n");
  printf("feel anything anymore..... Isn't that what you wanted, Senpai?\n\n");
  printf("1: Red Moon\n2: Ember\n3: Salmon\n4: Diabetic Blood\n5: Day\n6: Blue Moon\n>>>");


  /*  You need to split this into two function calls            */
  /*  choice = scanf("Pick a Number.", &choice);                */

  printf("Pick a number. ");      /* Prompt the user.          */
  retval = scanf("%d", &choice);  /* Input "choice"            */

  if(retval == 0)                  /* Unknown scanf() error      */
  {
      printf("\nIncorrect input.\n");
      return EXIT_FAILURE;          /* Better than "return 1;"    */
  }

  /* Instead of multiple "if" statements, use switch instead.    */

  switch(choice)
  {
      case 1:
        system("redshift -O 1000k");
        break;
      case 2:
        system("redshift -O 1200k");
        break;
      case 3:
        system("redshift -O 1360k");
        break;
      case 4:
        system("redshift -O 1700k");
        break;
      case 5:
        system("redshift -O 6500k");
        break;
      case 6:
        system("redshift -O 25000k");
        break;
      default:
        printf("\nIllegal entry: %d\n", choice);
        break;
  }

  return EXIT_SUCCESS;            /* Better than "return 0;"    */
}
Hot Dog, it WORKED!!..... ^^ Thank you good sir, THANK YOU!!..... ^^ Hmm...... Maybe there IS something to this FOSS thing AFTER all..... ;) ..... :3
 
Hot Dog, it WORKED!!..... ^^ Thank you good sir, THANK YOU!!..... ^^ Hmm...... Maybe there IS something to this FOSS thing AFTER all..... ;) ..... :3
You doubt my abilities? ;^)

Yes! FOSS is a great thing! ;^)

Cheers!
 
Here's the Code, with some minor tweaks..... :D I had removed the Comment about Compiling on Linux, as this was for Windows..... Is that ok, Mr. Penguin.....? :3 Also, I (of course) un-Commented the #include Pre-Processor Directive for windows.h..... :)

Code:
/* This Program is released under the GNU GPL Version 2, or, at your option,
  any later version.

  See https://www.gnu.org/licenses/gpl-2.0.html for more details.

  However, I will condense it for you. You can modify this Program
  HOWEVER you want. You are encouraged to share it with others. There's more
  to this License, but that's the crux of it.
*/

/*RStanley helped me with this Program's revisions!.....  ^^ Without him, it might not have been so AWESOME!..... :3 Thank you buddy!..... :3*/

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

int main(void)

{
  int choice = 0;                /* Holds the choice number.  */

  int retval = 0;                /* Return values from scanf() */

  /* You need to clean up the instructions. This is a start.    */

  printf("Welcome to the bastardized wannabe GUI for Redshift on Windows!\n\n");

  printf("Select from 1-6, to adjust the Color Temperature. (Hint: The more Red\n");

  printf("it is, the easier it will be on your Eyes at Night [or if you've stayed\n");

  printf("up all night and it's day]. Y'know, those balls in your Head? Yeah, don't\n");

  printf("be a a Sociopath to them. [Make it TOO Red, however, and you'll be seeing...\n");

  printf("Red. But you just might like it.]) Also, Blue Moon is SO Blue, it'll have\n");

  printf("you downing a bottle of Aspirin pretty quickly. But hey, at least you won't\n");

  printf("feel anything anymore..... Isn't that what you wanted, Senpai?\n\n");

  printf("1: Red Moon\n2: Ember\n3: Salmon\n4: Diabetic Blood\n5: Day\n6: Blue Moon\n>>>");


  /*  You need to split this into two function calls            */
  /*  choice = scanf("Pick a Number.", &choice);                */

  printf("Pick a number. ");      /* Prompt the user.          */

  retval = scanf("%d", &choice);  /* Input "choice"            */

  if(retval == 0)                  /* Unknown scanf() error      */

  {
      printf("\nIncorrect input.\n");

      return EXIT_FAILURE;          /* Better than "return 1;"    */
  }

  /* Instead of multiple "if" statements, use switch instead.    */

  switch(choice)

  {
      case 1:

        system("redshift -O 1000k");

        break;

      case 2:

        system("redshift -O 1200k");

        break;

      case 3:

        system("redshift -O 1360k");

        break;

      case 4:

        system("redshift -O 1700k");

        break;

      case 5:

        system("redshift -O 6500k");

        break;

      case 6:

        system("redshift -O 25000k");

        break;

      default:

        printf("\nIllegal entry: %d\n", choice);

        break;

  }

  return EXIT_SUCCESS;            /* Better than "return 0;"    */

}

I also used more Enters, since I find it easier to read Code that way..... :3
 
You doubt my abilities? ;^)

Yes! FOSS is a great thing! ;^)

Cheers!
No, I would NEVER doubt your abilities..... :D You're like a Black Belt when it comes to Programming..... :) And I NEVER doubt my Senpais in Karate..... :D
 
You doubt my abilities? ;^)

Yes! FOSS is a great thing! ;^)

Cheers!
Ah yes...... Here's the finished product!..... :) I doubt you would be able to use it, but if you download Redshift for Windows, put it in a WINE Folder, and THEN run this from WINE's CMD, then it MIGHT work..... :3
 
... I also used more Enters, since I find it easier to read Code that way..... :3
I know you do, but most programmers including myself use whitespace, especially blank lines, conservatively. Plus it can easily hide errors in coding..
 
I like to use blank lines only to separate logic related blocks of code.
 
Ah yes...... Here's the finished product!..... :) I doubt you would be able to use it, but if you download Redshift for Windows, put it in a WINE Folder, and THEN run this from WINE's CMD, then it MIGHT work..... :3
That's the great thing about releasing under the GPL. I can take your code, and adapt it for Linux, so I can run it natively! No need for WINE! ;^)

Redshift is available as a native Linux application. I installed it using the package manager of my Debian Distro. I don't need it but installed it to fully test your application.

One thing though, You name the product, "Redshift-GUI-Wanaibe.exe". This is not a GUI application. It is designed as a CLI (Command Line Interface) application, for both Windows or Linux. You would need a lot more code to run it as a true GUI app. Users might be confused when they see the "GUI" part of the name.
 
I know you do, but most programmers including myself use whitespace, especially blank lines, conservatively. Plus it can easily hide errors in coding..
Oh..... :( Hmm.... I'd follow your advice, but the Autism in me won't allow for less Whitespace..... WHY?!!..... D':
 
That's the great thing about releasing under the GPL. I can take your code, and adapt it for Linux, so I can run it natively! No need for WINE! ;^)

Redshift is available as a native Linux application. I installed it using the package manager of my Debian Distro. I don't need it but installed it to fully test your application.

One thing though, You name the product, "Redshift-GUI-Wanaibe.exe". This is not a GUI application. It is designed as a CLI (Command Line Interface) application, for both Windows or Linux. You would need a lot more code to run it as a true GUI app. Users might be confused when they see the "GUI" part of the name.
Oh yeah!..... :D If you did..... I would be honored..... :3 SO honored.... :D And I would be even MORE honored if you shared it!..... ^^ HONOR!!...... :3 :D Also, I use it Linux, too..... Well, on my Inspiron 1420, I have to use F.lux, because Redshift won't run..... :( F.lux is Proprietary, but it IS good..... Still, I'd rather get Redshift running on there..... :( But it runs GREAT on my Chromebook, with Kubuntu!..... ^^ (P.S., Kubuntu is God-awful, at LEAST on the Acer Chromebook C720..... Open Firefox and Clementine, and you're in trouble..... :( I have had similar results with Chrome and Firefox running at once in Windows, so I think it's a matter of Netbooks..... :)) Also, I named the Program that because it's, well..... A GUI wannabe...... :D But it ISN'T a GUI....... :3 Also, thank you for testing it, Good Penguin Sir!!..... ^^ And, as I said, it works FLAWLESSLY on my end, and it was all thanks to you!..... (Well, I DID Compile it and Run it, but that's Child's Play..... :))
 
Oh..... :( Hmm.... I'd follow your advice, but the Autism in me won't allow for less Whitespace..... WHY?!!..... D':
I had a feeling that might have been the case. As long as it will compile correctly then whatever works for you is fine. You might want to mention that in the comments of the source file.

I look forward to seeing future code!
 
I had a feeling that might have been the case. As long as it will compile correctly then whatever works for you is fine. You might want to mention that in the comments of the source file.

I look forward to seeing future code!
'K!..... :3 ^^ Also, I was thinking about Writing a Geolocator for my Mom, so that she knows where I am..... I'm thinking I could study Redshift, as that DOES deal with Geography..... :) It'll be written in C, so she can run it without installing anything else..... :D What do you think.....? Wanna join in on the Project....? :3
 
If Kubuntu is running heavy on your netbook you can try Lubuntu or Xubuntu, lightweight distributions. I've tried Lubuntu and it's nice and smooth, even with MATE desktop environment.
 
If Kubuntu is running heavy on your netbook you can try Lubuntu or Xubuntu, lightweight distributions. I've tried Lubuntu and it's nice and smooth, even with MATE desktop environment.
Yeah, but I kinda LIKE the Plasma Desktop..... :3 Wobbly Windows..... YUM.....! :3 But, if I can get Kubuntu on a more-suitable Machine, then I'll look into it..... :D It does all right if I don't have TOO many Programs open..... :) But the Charger is damaged, so I can't use it right now..... :( (Read: I'm stuck with WINDOWS...... :()
 

Staff online


Top