How do I make a line blink, as if it were an alert?? I know the getch() bit to stop the blink, I just don't know how to mak eit blink???
Ilan
How do I make a line blink, as if it were an alert?? I know the getch() bit to stop the blink, I just don't know how to mak eit blink???
Ilan
getch()
Presto, a blinking line.
Are you trying to do something with visual appeal? Something that looks like it's pulsating?
P.S more code, with tags, what compiler
The world is waiting. I must leave you now.
ok...so I want the program to alert the user if a certain event happens....
if(amount[count] <= optimal[count]/4)
printf("Warning. Supply of %s is getting low.", products[count]);
getch();
something in the lines of that, but instead of just printf...I want a blinking affect??
Ilan
This is implementation specific. You could use ANSI escape codes, a Borland compiler and some of their functions (I believe so anyway), ncurses in linux will do this I think, or some Windows programming.
Again, this all depends on your specific application / implementation.
Quzah.
Hope is the first step on the road to disappointment.
I was personally thinking that he might've wanted to do something you could only do with graphics / allegro ( animated text ).
The world is waiting. I must leave you now.
That very well may be. It's not like he was pinpoint specific on his requirements or problem description.Originally posted by Shadow
I was personally thinking that he might've wanted to do something you could only do with graphics / allegro ( animated text ).
Quzah.
Hope is the first step on the road to disappointment.
This is all very ell and good and I understand the idea, but practically, how do you write it out?? like printf....or something along those lines?
First, you will need to position your printf's. You need to have a header file that will allow you to do this (I know VC++ has one, I use a school made one). After this, you put your code in a loop.
keep in mind I'm doing this off the top of my head
This will loop it, you'll need to make something to stop the loop obviously, and something to slow it down. As it is like this, it will blink, but probably so fast it will just look grey.Code:while(1) { xya(1,1);//cursor positioning printf("Your blinking message); cls();//premade clearscreen in my header file }
Does this help?Code:/* Program: AnimText.c Purpose: Demonstrates how to make text "flash". */ #include <stdio.h> #include <time.h> #include <windows.h> void clrscr(void); int main(void) { while(1) { printf("Warning. Supply of %s is getting low.", products[count]); sleep(150); clrscr(); sleep(150); clrscr(); } return 0; } void clrscr(void) { COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); }
Did you get this figured out even?
The world is waiting. I must leave you now.
you could try this:
you might need to modify it a bit.Code:#include <stdio.h> #include <string.h> #include <time.h> void warning(char *string, int flash, long speed); void sleep(long milli); int main(void) { warning("coffee", 50, 90); return 0; } void warning(char *string, int flash, long speed) { char warningMsg[50]; int bspace; int i; sprintf(warningMsg, "Warning. Supply of %s is getting low.", string); bspace = strlen(warningMsg); speed /=2; while(flash--) { printf("%s", warningMsg); sleep(speed); for(i = 0; i < bspace; ++i) { printf("\b \b"); } sleep(speed); } printf("%s", warningMsg); } //thanks Prelude for this void sleep(long milli) { //djgpp clocks per sec 91 //msvc++ clocks per sec 1000 clock_t current = clock(); clock_t end; for(end = current + milli; current < end; current = clock()); }
Last edited by CtrlAltKick; 05-16-2002 at 02:10 PM.
50 milliseconds. Fast.
The world is waiting. I must leave you now.
yeah, kind of slow when compiled with djgpp. just bring it up a notch if using msvc or something else.