Paging Purevl
is this true?
If so can I ask you a few questions??
Last edited by lilstephsls1; Oct 19, 2005 at 10:58 PM. Reason: retarded

sub prompt_phase {
my ( $ans, $subr );
print "\n--------------------------------\n";
print "Please select a phase to execute\n";
print "--------------------------------\n";
print "0. Run steps 1,2,3\n";
print "1. Generate the list of streams for Depot: $::depot\n";
print "2. Examine the contents of each stream\n";
print "3. Scan the stream contents for evil twins\n";
print "Q. Exit\n";
print "\n";
print "Enter Selection: ";
$ans = <STDIN>;
chomp($ans);
exit 0 if ( $ans =~ m/q/i ) || ( $ans =~ m/x/i ) || ( $ans eq "" );
if ( !( ( ( $ans >= 0 ) && ( $ans <= 3 ) ) ) )
{
print "\n\007$ans is not a valid selection\n\n";
return;
}
$subr = "phase_" . $ans;
no strict "refs";
&$subr();
use strict "refs";
}
Trending Topics
The Best V8 Stories One Small Block at Time
2) read for user input (using an individual char)
3) determine whether a character is a digit (use "isdigit(insert_variable_here)" (include ctype.h) when used it will return 0 (false) if the character is not a digit and 1 (true) if it is....so an ex: "if (isdigit(c)" ... in addtion you need to also check for the letter Q . so a combined statement such as [i]if((isdigit(c)) || ((c == 'q') || (c == 'Q')))if it isn't the input you need,you can clear the scree, and redisplay the options or an error statement or a combination of both.
4) once it is, and bad inputs filtered out, perform a switch statement within the if statement for each option accordingly
Last edited by Rhode Island Red; Oct 19, 2005 at 01:06 PM.
'accumulator=0
1) Enter number
2) Add
3) Subtract
4) Mutliply
Please enter a number from 0 to 9:'
How exactly would i use a void function to display this to the screen?
{
cout << "1) Enter Number \n"; //or printf("1) Enter Number \n");
.
.
.
}
you use a void only when you expect the function to return nothing
in your main procedure, call this function, then read the char, then call the processing function and pass it the character (by value) . and go from there
Last edited by Rhode Island Red; Oct 19, 2005 at 01:17 PM.
okay i am trying to run the program just but i am coming up with errors regarding my 'display_menu'. Where the hell do I declare that??
. THis is what my program looks like so far: #include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
//declare and initialize objects
double accumulator(0);
char display_menu;
//ask the user to enter a number that will be the accumulator
cout << "Enter a number ";
cin >> accumulator;
void display_menu()
{
cout << accumulator;
cout << "1) Enter Number \n";
cout << "2) Add \n";
cout << "3) Subtract \n";
cout << "4) Multiply \n";
cout << "5) Divide \n";
cout << "6) Modulus \n";
cout << "7) Raise to power \n";
cout << "8) Square root \n";
cout << "9) Negate \n";
cout << "0) Exit \n";
cout << "Please enter a number from 0 to 9 \n";
return;
}
return 0;
}
hint: usually you can trace an obscure error to the earliest line in the program, you understand,if the error is not so obvious. An coding error can create following errors as a result, that are actually not code errors, but the compiler unable to properly interpret the rest of the code after the error (usually syntax errors)
oh , and remove the "\n" and add ": " instead at the readline. People are used to entering at the line commanded, unless the command is quite long


Ya i was about 15 years ago..I havent programmed in a long long time, other then scripting in linux and what not