Murtan 317 Practically a Master Poster

Maybe you should look for a method to disable a control.

(second big hint)

Murtan 317 Practically a Master Poster

Yes the getFName did return a constant character pointer. All pointers can implicitly be treated as an array (you just have to be careful not to write where you don't have permission). In this case, it points to the buffer inside the PERSON object and is a pointer to a const char. (The const part encourages the compiler to make it hard for you to write through the pointer accidentally.) You can use this pointer in your code like you would any character array. (Specifically, you can cout << p.getFName(); and will output the first name, just like you might expect it to.)

We don't really need to make a copy of the string unless we plan to modify it. And if we do, we can make the copy using the pointer.

The same thing works in reverse for the setFName() method, except the only thing we do with the pointer is to make a copy of what it pointed to into our buffer.

Murtan 317 Practically a Master Poster

then the calls from main to reference the new methods:

case ADDPERSON :
				
				cout << "Enter First Name " << endl;
				cin >> fName;
				cout << "Enter last Name " << endl;
				cin >> lName;
				cout << "Enter Address " << endl;
				cin >> Address;

				p.setFName(fName);
				p.setLName(lName);
				p.setAddress(Address);

				status = access.addPerson(p);

You already had character buffers for the fName, lName and Address declared.

Murtan 317 Practically a Master Poster

I think you understand the concept. Here's your PERSON class (without the people array) but with some accessors added.

class PERSON
{
private:
	char fName[25];
	char lName[25];
	char Address[100];

public:
	PERSON();
	char const * getFName() const;
	char const * getLName() const;
	char const * getAddress() const;
	void setFName(char const * fname);
	void setLName(char const * lname);
	void setAddress(char const * address);
};

Here's an example implementation for a couple of those methods I added:

char const * PERSON::getFName() const
{
	return fName;
}
void PERSON::setFName(char const * _fname)
{
	strcpy_s(fName, sizeof(fName), _fname);
}
Murtan 317 Practically a Master Poster

On one more design note, it looks like you had PERSON and then attempted to add an array to it to make the address book.

I would recommend having an ADDRESSBOOK class that has the array and the members for updating and accessing the PERSON objects in the ADDRESSBOOK.

Murtan 317 Practically a Master Poster

Generally, you want to avoid the above. I think if you tried hard enough, you might be able to hack something together, but I don't think it would be worth the ongoing effort.

I know in visual studio that once you tell it that one dll (or lib) depends on another one in your solution, that you are then prevented from specifying the depndency in reverse. (It uses dependency to help establish build order.)

If you really have two objects (classes, modules, whatever) that depend on each other that closely, they should be in the same compilation unit (lib, dll, etc.)

Murtan 317 Practically a Master Poster

as far as code like:

cout << "Enter First Name " << endl;
				cin >> p.fName;
				cout << "Enter last Name " << endl;
				cin >> p.lName;
				cout << "Enter Address " << endl;
				cin >> p.Address;

where p is an instance of PERSON, it is generally not allowed.
Your options are:
1) make the members public. (bad form, but you could make it work.)
2) add accessors for the dataitems. Methods like setFName(char const * fname) that will allow you to set the data members. You would have to accept user input into temporary variables and then call the accessor to set the data.
3) add an update that takes all of the fields that might be updated in one call. (Similar to the previous, you still need to use temporary variables.)
4) add a method that would prompt for and accept input into the members. (I think you said you couldn't do that, but I don't know if it was because you couldn't make it work, or if it was not permitted.)

#2 tends to be the most common implementation.

Murtan 317 Practically a Master Poster

The code as posted has a few problems:

In combination with const int MAXADDRESS = 25; , the statement char people[MAXADDRESS]; declares an array of 25 characters.

But later in methods of the class, you treat people like it was an array of PERSON.

See: people[head] = p; and p = people[tail]; for examples. (This shouldn't even compile, doesn't your compiler complain about it?)

You also have methods which you appear to intend to 'return' a value through a PERSON reference. For example: bool PERSON::findPerson(char *lastName, PERSON &p) appears to search the people array (treating it like an array of PERSON) for a name that matches and assigns to p from the PERSON array. As long as you are aware that at the point of that assignment, the contents of whatever were passed in as 'p' have been overwritten with a copy of the record found, everything is fine. I just wanted to make sure you understood how it works.

Murtan 317 Practically a Master Poster

I was trying things in a test application. DateTime.Now.ToString("HH:mm:ss") and DateTime.Now.ToString("hh:mm:ss tt") both seem to produce valid output.

Does SQL like one format better than the other?

Murtan 317 Practically a Master Poster

Is time a reserved word? Could you name the column qtime like you did qdate?

Murtan 317 Practically a Master Poster

You still have string sortList; in main() and it is masking the function you want to call.

You need to pass the number of students to sortlist
Change the call sortList(grades, int size); into sortList(grades, Num_Students);

Murtan 317 Practically a Master Poster

One side note, when I was writing the test app, I had to set Num_Students after I read from the input file. My read from the input file looks like the following: (there is some debug still so I can see that it is doing something)

printf("main: reading grades.txt\n");
	ifstream infile("grades.txt");
	if (!infile.is_open())
		printf("main: Failed to open grades.txt\n");
	else{
		while(!infile.eof() && i < Num_grades){
			infile >> grades[i].ID;
			infile >> grades[i].q1;
			infile >> grades[i].q2;
			infile >> grades[i].e1;
			infile >> grades[i].e2;
			infile >> grades[i].assg1;
			infile >> grades[i].assg2;
			infile >> grades[i].assg3;
			if (! infile.eof()){
				cout << "main: grades[" << i << "].ID=" << grades[i].ID << endl;
				i++;
			}
		}
	}
	infile.close();
	Num_Students = i;

Please make any changes from the above that make sense to you.

We need to get your code compiled and running. If you want to work on it some, go ahead. When I first started working with your file, I commented out anything that had a compile error that I couldn't "just fix". Then I started running it and got the functionality that was implemented working. Then I started adding the functionality that I had commented out. (Its an iterative approach to development.)

If you get stuck:
Compile your file.
Post the entire file you just compiled in code=c++ tags
Post the entire error list from that compile in code tags

Murtan 317 Practically a Master Poster

And if you do the struct thing, the call to Totaller could take 2 structs, one for the totals and one for the new data to add to the totals.

Sample struct, but you can add or remove fields as appropriate

struct Payinfo {
    float gross;
    float federaltax;
    float statetax;
    float ssitax;
    float hours;
    float payrate;
    float deferred;
    float reghrs;
    float ovthrs;
    float netpay;
}
Murtan 317 Practically a Master Poster

You probably can put it into 2 different functions. You could probably make it work if you tried hard enough. But was the point to make the two 20 argument functions work or to make the code work?

I don't know if you saw the suggestion, but the creation of a struct that you fill with the arguments and then pass a pointer to the struct is actually a MUCH better implementation than all of the individual parameters.

The struct allows you to set the parameters by name. So to verify that the right data is in the right place is just verifying that the source data is correct for the target member. Validation of the function calls with 20 arguments involves looking at the prototype and parameter counting to make sure you get the data in the right position in the list.

The struct makes it easy to pass the same arguments on to another function if that is required.

If you REALLY want to do the 20 argument functions and have more than one, you might want to make a convention for the declaration and calling of the functions where you put each argument on its own line in the source file. It helps with the argument counting and other validation if the parameter list is clear. It would also help to have a logical organization for the order that the parameters appear.

sample of layout, but I still don't recommend it:


       
Murtan 317 Practically a Master Poster

So you want the loop to keep running while the xPos is different or the yPos is different. You wrote while the xPos is different AND the yPos is different. The loop needs to run while either doesn't match.

while((board.getgXPos() != board.getXPos()) || (board.getgYPos() != board.getYPos()))
SHWOO commented: Helpful! +3
Murtan 317 Practically a Master Poster

Can you run it yet?

What does it do?

Murtan 317 Practically a Master Poster

If you're not going to use sortField, go ahead and remove it.

PS- ddanbe is right

In my sample program, the sort submenu looks like this:

sortExit = false;
                do{
                   char sortCommand;
                   cout << "1: Student ID" << endl;
                   cout << "2: Quiz 1 Grade" << endl;
                   cout << "3: Quiz 2 Grade" << endl;
                   cout << "4: Exam 1 Grade" << endl;
                   cout << "5: Exam 2 Grade" << endl;
                   cout << "6: Assignment 1 Grade" << endl;
                   cout << "7: Assignment 2 Grade" << endl;
                   cout << "8: Assignment 3 Grade" << endl;
                   cout << "9: Return to main menu" << endl;
                   cout << endl;
                   cout << "Enter field to be sorted(1-8): ";
                   cin >> sortCommand;
                   
                   switch (sortCommand){ 
                          case '1':
                               for (int ii = 0; ii < Num_Students; ii++)
                                   scores[ii] = grades[ii].ID;
                               sortList(scores, Num_Students);
                               showList(scores, Num_Students);
                               break;
                          // 
                          // Skipping cases for 2-8 here
                          // 
                          case '9':
                               sortExit = true;
                               break;
                          default:
                               cout << "Invalid Command" << endl;
                   }
                }while( !sortExit );
ddanbe commented: respect is mutually, this is a hard one +3
Murtan 317 Practically a Master Poster

Your code:

//Sort IDs or grades into a column.
           case '3':
                do{
                   cout << "1: Student ID" << endl;
                   cout << "2: Quiz 1 Grade" << endl;
                   cout << "3: Quiz 2 Grade" << endl;
                   cout << "4: Exam 1 Grade" << endl;
                   cout << "5: Exam 2 Grade" << endl;
                   cout << "6: Assignment 1 Grade" << endl;
                   cout << "7: Assignment 2 Grade" << endl;
                   cout << "8: Assignment 3 Grade" << endl;
                   cout << endl;
                   cout << "Enter field to be sorted(0-7): ";
                   cin >> sortWhat;
                   
                   switch (sortWhat){ 
                          case '1':
                               sortField(Num_Students[], int num, sortWhat);
                               showList(grades[].ID, Num_Students);
                               break;
                          case '2':
                               int q1scores[65];
                               for (int ii = 0; ii < Num_Students; i++)
                               q1scores[ii] = grades[ii].q1;
                               break;

I moved and renamed the q1scores array (I was getting warnings).
I presumed an alternate version of sortField named sortList that expects an array of integers and a count. It sorts the array.

//Sort IDs or grades into a column.
           case '3':
                do{
                   cout << "1: Student ID" << endl;
                   cout << "2: Quiz 1 Grade" << endl;
                   cout << "3: Quiz 2 Grade" << endl;
                   cout << "4: Exam 1 Grade" << endl;
                   cout << "5: Exam 2 Grade" << endl;
                   cout << "6: Assignment 1 Grade" << endl;
                   cout << "7: Assignment 2 Grade" << endl;
                   cout << "8: Assignment 3 Grade" << endl;
                   cout << endl;
                   cout << "Enter field to be sorted(0-7): ";
                   cin >> sortWhat;
                   int scores[Num_grades];
                   
                   switch (sortWhat){ 
                          case '1':
                               for (int ii = …
Murtan 317 Practically a Master Poster

Ok, I'm curious, what compiler are you using? (I'm still seeing lots of compile errors.)

I found another basic problem. Inside your main() you declare char sortField which hides the function int sortField(students grades[], int num, string sortThis) This may be related to your current issue.

How are the sub-selections under '3' sort grades supposed to work?

If I select 1, should the output just be a sorted list of IDs? or should the entire grades array be sorted by ID and then output?

If I select 2, should I just see a sorted list of quiz 1 grades or all of the records ordered by the quiz 1 grade?

Murtan 317 Practically a Master Poster

I agree with ninwa, the function you have doesn't make much sense.

void addressType::print_add(string str, string Cit, string St, int Z)
{
	cout<<"Address: "<<str<<endl;
	cout<< Cit <<","<<St<<endl;
	cout<<"Zip: "<<Z<<endl;

	return ;

}

The function asks you pass in all of the address data when the address data is already in the class. (Though your sample doesn't show how the address data got in there.)

You could write the print method as shown by ninwa, or if you prefer your output format:

void addressType::print_add()
{
	cout << "Address: " << St_address << endl;
	cout << city << "," << state << endl;
	cout << "Zip: " << Zip << endl;
}

Additional comments:

#1 If you have a function with a void return type, the return statement at the end of the function is not necessary.

#2 It is a good idea to establish naming conventions for your classes and members. The one that stood out the most to me as not matching were the names of the data members. You have a leading capital letter on 2 of them and leading lower-case on the other 2. It probably should be one way or the other, but not both.

Murtan 317 Practically a Master Poster

It's the programmers responsibility to ensure the target buffer is sufficiently large enough to hold the maximum possible output size.

I think lint (or something like it) might catch it, but I'm not sure.

Murtan 317 Practically a Master Poster

You also have a basic misunderstanding of arrays of structures.

For example in your sort case, you have this in one of the subcases:

sortList(grades[].q1, Num_Students);
    showList(grades[].q1, Num_Students);

You seem to be under the impression that you can generate an array of quiz one scores with grades[].q1 what you have is a syntax error. If you want an integer array containing the quiz one scores, you're going to have to make it.

int q1scores[65];
    for (int ii = 0; ii < Num_Students; ii++)
        q1scores[ii] = grades[ii].q1;

This might come closer to what you're looking for, but I'm not sure.

If you want to be able to sort the entire grades array by different fields in the structure, you would normally write one sort that takes a comparison function (which tells you which record of two would come first) and the helper comparison functions for the different fields you want to sort by.

Your swap inside your bubble sort is also problematic:

if(grades[k].ID > grades[k + 1].ID){
                              temp = grades[k].ID;
                              grades[k] = grades[k + 1];
                              grades[k +1].ID = temp;
                              swap = true;

This saves the ID from structure [k], copies all of the fields from [k+1] to [k] (id, q1, q2, e1, e2, assg1, assg2, assg3), then sets the ID in [k+1] from the saved ID. You lost all of the scores from record [k].

Murtan 317 Practically a Master Poster

Is this a problem:

cout << "Enter field to be sorted(0-7): ";
                   cin >> sortWhat;
                   
                   switch (sortThis){ 
                          case '1':

You're getting the input into sortWhat and then switching on sortThis.

Murtan 317 Practically a Master Poster

You moved the lines too far out...(sigh)

import random
#list of words the computer will be picking
word_list = ['python', 'jumble', 'easy', 'difficult', 'answer', 'tracer', 'muffin']

print "I'm picking one of the " , len(word_list), "words from a secret list"
random_word = random.choice(word_list)
print "Computer has selected secret word", len(random_word), "letters."

guess_count = 0
correct_guess = ""
wrong_guess = ""
previous = ""
correct = random_word

while guess_count<5:
      guess_count+=1

      while True:    
          guess=raw_input("\nguess one letter ")
          guess = guess.strip().lower()

          if len(guess) >1:
              print "Please enter only one letter."
          elif guess in previous:
              print guess, ("has already been guessed ")
              guess_count-=1
          else:
              break


      if guess in correct:
         print guess, "\nyes"
         correct_guess += guess
         previous += guess
      else:
         print guess, "\nno"
         wrong_guess += guess
      previous += guess

print correct_guess
print wrong_guess

print len(correct_guess), "correct guesses and", len(wrong_guess), "incorrect"

## guessing the word

print "Guess the word"
guess = raw_input ("\nYour guess:")
guess = guess.lower()
while (guess != correct) and (guess !=""):
    
   if guess != correct:
        print "Incorrect..\n"
   break
   print "Thanks for playing."     
   raw_input("\n\nPress the enter key to exit.")   
   

if guess == correct:
   print "That's it! You guessed it!\n"

print "Thanks for playing."
raw_input("\n\nPress the enter key to exit.")
Murtan 317 Practically a Master Poster

Can you use functions...you're having a hard time keeping the indenting right.

lines 31-38 should be out one indent...they need to be 'inside' the while guess_count < 5 but not 'inside' the while True

The "er no" is coming from line 36 but you're not supposed to get there until you've passed all the input tests.

I actually wrote a 'get me a letter' function and I call it from the main in my test app.

def getLetterGuess(previous):
    # Remind the user of the previous guesses if any
    if len(previous) > 0:
        print "You have already guessed:", ','.join(previous)
    # loop until we get a valid guess
    while True:
        lguess = raw_input("Guess a letter: ").strip().lower()
        if len(lguess) != 1:
            print "Enter only one character"
        elif not lguess.isalpha():
            print lguess,"is not a letter, please try again"
        elif lguess in previous:
            print "You have already guessed",lguess
        else:
            break
        print
    return lguess

Then I use it from the main like this:

# Take the Letter Guesses
for gidx in xrange(5):
    guess = getLetterGuess(previous)
    if guess in random_word:
        print "Yes,", guess, "is in the word"
        correct_guess += guess
    else:
        print "Sorry,", guess, "is not in the word"
        wrong_guess += guess
    previous += guess
Murtan 317 Practically a Master Poster

When I put the while loop where it was supposed to go, I got the following from running it:

I'm picking one of the  7 words from a secret list
Computer has selected secret word 6 letters.

guess one letter er
Please enter only one letter.

guess one letter sd
Please enter only one letter.

guess one letter ght
Please enter only one letter.

guess one letter e
e is not correct

guess one letter rt
Please enter only one letter.

guess one letter r
r is not correct

guess one letter tr
Please enter only one letter.

guess one letter t
t is not correct

It looks like it is working to me.

while guess_count< 5:
    guess_count+=1

    while True:
        guess=raw_input("\nguess one letter ")
        guess = guess.strip().lower()

        if len(guess) >1:
           print "Please enter only one letter."
        elif guess in previous:
           print guess, ("has already been guessed ")
        else:
           break

    if guess in correct:
Murtan 317 Practically a Master Poster

Name search: You start at the head and while there are still entries on the list, you compare the names. If they match, you found it. (if the list is still in alphabetical order, you can stop when you find a name > than the one you're looking for.)

ID search: You start at the head and while there are still entries on the list, you compare the IDs. If they match, you found it.

Once you have found it, you need to be careful about the updates. It is usually best form to remove the one you found, update it and re-add it. (Because if the field that specifies the list order changes, you need to re-position the record in the list.)

Murtan 317 Practically a Master Poster

In my test app, I didn't limit them to entering one letter, but I validated what they typed and complained if it was more than one character.

You could replace the raw_input and the first if test with a while loop:

while True:
    guess = raw_input("\nguess one letter ")
    guess = guess.strip().lower()
    if len(guess) > 1:
        print "Please enter only one letter"
   elif guess in previous:
        print guess, "has already been guessed "
   else:
        break

If you do, remember to change the elif guess in correct: to if guess in correct:

Murtan 317 Practically a Master Poster

Please use code tags when posting code, preferably the language-specific version so we get syntax highlighting. It makes the code MUCH easier to read.

If you want the linked list to be ordered by last name, the convention is to put the record in the list where it belongs.

If the first record added is for "James Smith" then it is the only record. If we now want to add a record for "Bill Wilson", it should be added after "James Smith". If we then add a record for "Carol Fisher" if goes before "James Smith". Repeat as additional records are added and the list will always be sorted by last name.

So the code ends up looking something like:

// preinitialize the new record's next to null
newstudent -> next = null;

student_list * prev = null;
student_list * curr = head;
// while there are more records to look at on the list
while (curr != null)
{
   // should the new record come before the 'current' record in the list?
   if (strcmp(newstudent -> Last_Name, curr -> Last_Name) < 0)
   {
      newstudent -> next = curr;
      break
   }
   prev = curr;
   curr = prev -> next;
}

if (prev == null)
   head = newstudent
else
   prev -> next = newstudent
Salem commented: Better copy/paste the "please use tags" phrase to a hot key, you need it a lot at DW +24
Murtan 317 Practically a Master Poster

you're still missing the elif guess in correct: before the print guess,"is correct" I'm hoping its just the broken code tag that caused it, or you lost your indentation.

Murtan 317 Practically a Master Poster
def isWhole(num):
    return num == int(num)

Works pretty well, but can fail for numbers that are really close to whole:

Test code and output

for ii in xrange(1,20):
    f = float('3.'+'9'*ii)
    print ii, f, isWhole(f)
    
1 3.9 False
2 3.99 False
3 3.999 False
4 3.9999 False
5 3.99999 False
6 3.999999 False
7 3.9999999 False
8 3.99999999 False
9 3.999999999 False
10 3.9999999999 False
11 3.99999999999 False
12 4.0 False
13 4.0 False
14 4.0 False
15 4.0 False
16 4.0 True
17 4.0 True
18 4.0 True
19 4.0 True
Murtan 317 Practically a Master Poster

yes, and be careful of using the get* methods in outputdata, its not necessary, just reference the members.

Murtan 317 Practically a Master Poster

From what I'm reading of the posts and assignment, you should remove the for loop from inputData() and add a for loop to main to call inputData for all three TMoney members of the array money.

TMoney money[3];
for (int jj = 0; jj < 3; jj++)
    money[jj].inputData();

The first data entered will be in money[0], the second in money[1] and the third in money[2].

You're supposed to print the second set?

money[1].outputData();
Murtan 317 Practically a Master Poster

I tried to explain about indenting before...

Your while loop that starts on line 13 only contains line 14 and line 15. Line 16 will not be executed until the while is complete.

You lost an elif statement between lines 18 and 19...

The while loop used to go through line 26 in previous versions of the code.

The while loop starting on line 33 will keep looping until you get the right guess or enter a blank line, but the loop doesn't contain code to prompt for another guess.

line 34 is incrementing tries. Where did tries come from, do we use it anywhere?

The tests for incorrect on lines 35 and 37 can be performed as a single if guess != correct:

Murtan 317 Practically a Master Poster

At least part of the problem is in your last set of code...

The tempptr was null, so you allocated and initialized it, but tempptr was just a copy of the pointer from current[target[i]] you made no effort to set the original array entry to the newly allocated item.

Also (I'm actually presuming this is a copy/paste error) the call to the function to recurse calls a function of a different name. (In the function CreateList , it calls CreateRhs )

I can think of other ways to write CreateList, but what you have appears to work. Given a preference, I would have written CreateList something like:

item ** CreateList(int arrayLength, int * maxArray)
{
    int ii;
    int mymax;
    item ** rval;

    if (arrayLength < 1)
        return null;
    mymax = maxArray[0] + 1;
    rval = (item **)malloc( mymax * sizeof(item *));
    for (ii = 0; ii < mymax; ii++)
    {
        rval[ii] = (item *)CreateList(arrayLength - 1, maxArray + 1);
    }
    return rval;
}

This makes an extra recursion to initialze the item pointers to null, but it made the code slightly easier to read. (Feel free to add a test and eliminate the last recursion level.)

I also didn't like doing the cast in rval[ii] = (item *)CreateList but the return type was not compatible with the array type. In order to do that assignment without the cast, we would need to create a union type for the list pointer. The union would either point …

Murtan 317 Practically a Master Poster

The current database search uses where qdate = #" + DateTime.Now.ToString("dd-MMM-yyyy") + "#" which limits the search to only find records for the given date.

You could extend that to have a 'morning', 'afternoon' and 'evening/night' questions using time...

The only other was to implement it would be to somehow get the information as to whether or not the current user has already seen a particular question. (Maybe you could keep a last date/question index for each user?)

If the last question date was today's date, then select the next index question (if any).

Note that the database would need to have a field to establish the order that questions would be presented during the day.

Also note that some entity must be populating the database with questions for future dates so that when the date arrives there is a question available. The entity would have to support adding more than one question for a given date, potentially including an order in which the questions were to be presented.

Now you put some effort into the problem if you want me to post any more, the "I just can't think of anything" is all worn out.

Murtan 317 Practically a Master Poster

For more help with the int vs char for the array implementation, it would help to have a better idea of how the board will be used.

Murtan 317 Practically a Master Poster

Another common option is to leave the board in a single dimensional array. Depending on how you interface to the board, it has advantages and disadvantages.

For example, a 3 x 3 board would use 9 elements in an array. The first 3 would be the first row (or first column depending on your preference) the next 3 would be the second row and the last 3 would be the third and final row.

// ptr is just a char * in my class
void Board::create()
{
    ptr = new char [ width * height ];

    // filling the cells with numbers (I don't know why)
    int k = 1;
    for (int i = 0; i < width; i++)
    {
        for (int j = 0; j<height;j++)
        {
            ptr[i * width + j] = k++;
        }
    }
}
Murtan 317 Practically a Master Poster

The error I posted was from the command-line compiler.

I'm running:

python --version
Python 2.5.2

The error message was generated with:

python foo.py

where foo.py contained the code you had posted.

The line:

print guess, "has already been guessed ")

does have a syntax error...what's that last closing paren ')' for?

Murtan 317 Practically a Master Poster

ok, you are aware the indentation is CRITICAL in python applications?

In this first case, only one line is executed 10 times and the output is 11 lines long:

for ii in xrange(10):
    print "Apple"
print "Pear"

In this second case, two lines are executed 10 times and the output is 20 lines long, the only difference is whitespace at the start of a line:

for ii in xrange(10):
    print "Apple"
    print "Pear"

I picked up the code from your message and saved it into foo.py
I ran python foo.py and got the following message:

File "foo.py", line 3
    word_list = ['python', 'jumble', 'easy', 'difficult', 'answer', 'tracer', 'muffin']
    ^
IndentationError: unexpected indent

Note that it says the problem is on line 3 and is pointing at the w in word_list. Somehow, you have added a leading space to all of the lines in your code except the import and the first comment.

Take out the leading spaces for top-level lines.

You also have blatant indentation problems with the lines numbered 25 and 29 in your last post. They need to be at the same indentation as the lines before them, but they are obviously not.

Once you fix this indentation so you can compile, you have caused a logic problem by un-indenting code that needs to be part of the while guess_count < 5: loop.

Be patient, go carefully and read the compiler messages. Indent the code …

Murtan 317 Practically a Master Poster

I will comment however that users tend to like things to start at 1 rather than 0.

If I'm asking a user questions, it makes more sense to them to answer questions 1 - 10 rather than questions 0 - 9.

This is however also easily handled at the output point:

for (int ii = 0; ii < 10; ii++)
{
    printf("Question #%d:\n", ii+1);
}

The loop still ran from 0 to 9, making it more compatible with arrays, but the user 'sees' 1 to 10.

Murtan 317 Practically a Master Poster

The current implementation only looks at the first record returned and builds an output string with the question and answer options.

If there was more than one question matched, how would it work?

Should this return all of the questions delimited in some fashion?

Should it always return a list of questions, that might be empty?

Should you pass a question index into this method and keep calling it until it returns something indicating no more questions?

How would the user interact with it?
Would all of the questions for the day be on the same page, or would you want one page per question?

Murtan 317 Practically a Master Poster

Close, but the line 4 needs to follow like 5 and print the len of the random_word.

As written, line 4 (if it used 'len' instead of 'leg') would tell you how many words there were.

print "I'm picking one of my", len(word_list), "words."
random_word = random.choice(word_list)
print "My secret word has", len(random_word), "letters."
Murtan 317 Practically a Master Poster

The problem wasn't to remove references to random_word but to set it to a random selection from your list of words.

You use guess_word in many places to mean many different things, this is generally 'bad form'.

Initially, it is the array of words:

guess_word = ['python', 'jumble', 'easy', 'difficult', 'answer', 'tracer', 'muffin']

Then later you assign it from the word that the player entered

word=raw_input("What say you (hit Enter to quit) ")
guess_word = word

So, to help me out:

Use word_list to refer to the list of words to pick from.

Set random_word to be one of the words from the word_list. (Try using random.choice)

Oh, and in a previous version, you told them how many letters were in the random word, if it is permissable still, do something like

print "My secret word has", len(random_word), "letters"

For testing / debugging, I usually add something so I can see the word. (Remove it before you turn it in or give it to someone else to play.)

print "** DEBUG: Word:", random_word, "**"

When you're validating letter guesses, see if they are in the random_word.

After the 5 guesses, have the user enter the guess_word you should strip() and lower() the guess.

Then compare the guess_word to the random_word to see if they guessed correctly.

Murtan 317 Practically a Master Poster

The while loop starting on line 45 is NOT supposed to be inside the while loop from line 10. Move it out to the same level as the while from line 10.

You can not run the posted code...the posted code doesn't select or define random_word before the test on line 22. When I run it, it stops there.

When I've fixed both of the above, I'm not seeing the error you describe. What did you enter for the guess?

Murtan 317 Practically a Master Poster

In your description of MyEvent, I didn't see where any data from the background worker was transferred to the form.

Could you describe a little more about that, maybe it will have a clue.

Murtan 317 Practically a Master Poster

Change the return on line 34 and on line 37 to break to allow the while loop started on line 29 to exit.

Murtan 317 Practically a Master Poster

I think jlm699's code was just an example of how you might extend tuples (because you said you couldn't use lists.) I don't think it was intended to be a specific example for your program.

Did you read my previous message about how I thought you ought to structure the main part of your program?

for guesscount in range(1,6):
        lguess = raw_input("Enter your letter guess #%d" % guesscount)
        # put an if test here along with the 'yes' or 'no' display
    # They've run out of letter guesses
    guess_word = raw_input("What do you think the word is? ")
    # test and output here

You don't have to follow my advice specifically, but the current structure you have will not work. The two consecutive while loops don't perform like the game should. Once you get a letter right, there is no way to get back to the loop for getting a letter wrong.

You need some form of outside loop, and the while loops really should be IF statements.

New topic:

Are you even trying to run your code? What errors are you seeing?

(I get an error after my first guess...what do you see?)

#hint you need to initialize tried_good and tried_bad as tuples
tried_good = ()
tried_bad = ()
# I know I told you to make them 0 before, but I thought you were
# counting guesses, not collecting them
#
#Then you need to do something like what jlm699 …
Murtan 317 Practically a Master Poster

If the program you are trying to intercept is a DOSBOX program (which I read to mean a program written before windows, but that will be run under windows) that does help clarify what you will need to do.

Because it is a DOSBOX program, it probably will just send the characters to the printer. There may be few control codes mixed in, but it should be fairly easy to filter them.

There were a couple of DOS TSR based programs that would intercept calls to the printer and direct them to a file (See for example PRN2FILE, source code if you can find it)

These programs no-longer work under the modern windows interaface as they worked using a DOS concept calls TSR (Terminate Stay Resident) which allowed them to remain in memory to handle the calls, but that is no-longer available with Windows.

Can you have your program 'launch' or 'start' the other program?

If so, you might be able to 'pre-setup' its runtime environment such that when it goes to print, your 'wrapper' program gets the data instead. I know that being the 'launcher' of an application can give you additional rights releated to the application when it runs.

I am unfortunately 'stuck' at this point as I can't find a resource to direct you to for more information, but don't have any more time to spend right now either.

Murtan 317 Practically a Master Poster

So if I understand it correcly, your application has 4 windows. The main window and 3 other forms. The 3 forms are updated by backgroud worker threads.

Does the program always create all 3 forms, even if they are not visible?

Does the program always start the 3 background threads, or does it wait until the associated window is set to visible?

If the thread starts when the window is set to visible, are there any provisions to suspend or terminate the thread when the window is hidden?

Can you identify whether it is the close of the first window or the open of the second window that is causing your lockup?

How does the background thread interface with the window?

As I say the above, I seem to remember that you can (or could) generate problems when making calls into methods of the window (form) from more than one thread.