If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
-
jloxy
- In need of some credit

- Posts: 3
- Joined: Tue Nov 22, 2011 5:39 am
Post
by jloxy » Tue Nov 22, 2011 5:44 am
hi i need help with this code, i dont know what it does. Please somebody explain what each line does so i can rewrite it to suit other similar functions
Code: Select all
void MyFrame::CreateBST(wxCommandEvent& WXUNUSED(event))
{
string word;
wxString wxWord;
// Clear the edit box
MainEditBox->Clear();
//open the file
ifstream infile( CurrentDocPath.mb_str(), ios::in); // ".mb_str()" gets the "string" from "wxString"
while (!infile.eof())
{
infile >> word; // Get one word
// word = strip(word); // strip the word and lowercase it
if ( (word.length() > 0) && (!infile.eof()) )
{
//Insert the word into the BST
bst->insertNode(word);
//Display the word in the MainEditBox
wxWord = wxString(word.c_str(), wxConvUTF8); // Convert word to proper wx format for appending
MainEditBox->AppendText( wxWord ); // Append the converted word
MainEditBox->AppendText( wxT("\n") ); // Change line after each word is appended
}
}
}
Thank
EDIT by Auria : please use code tags
-
Auria
- Site Admin

- Posts: 6695
- Joined: Thu Sep 28, 2006 12:23 am
-
Contact:
Post
by Auria » Tue Nov 22, 2011 4:34 pm
Sorry your question is very vague. I think this code is very explicit and well documented, apart maybe from "bst" but I assume from the larger context you can see what bst is.
So please more precise questions, explaining line by line what happens is pretty much already done since most lines are commented
"Keyboard not detected. Press F1 to continue"
-- Windows
-
jloxy
- In need of some credit

- Posts: 3
- Joined: Tue Nov 22, 2011 5:39 am
Post
by jloxy » Tue Nov 22, 2011 7:49 pm
Ok I have to rewrite this code to use with a queue zoo I just done know what the code means , forgive me I am new to programming
-
Auria
- Site Admin

- Posts: 6695
- Joined: Thu Sep 28, 2006 12:23 am
-
Contact:
Post
by Auria » Tue Nov 22, 2011 10:34 pm
This code reads a file and adds its content to an "Edit Box" and a "bst"
"Keyboard not detected. Press F1 to continue"
-- Windows
-
jloxy
- In need of some credit

- Posts: 3
- Joined: Tue Nov 22, 2011 5:39 am
Post
by jloxy » Wed Nov 23, 2011 3:58 am
Ok so how would I write a "create queue " from this ?
-
Auria
- Site Admin

- Posts: 6695
- Joined: Thu Sep 28, 2006 12:23 am
-
Contact:
Post
by Auria » Wed Nov 23, 2011 3:51 pm
jloxy wrote:Ok so how would I write a "create queue " from this ?
I'm sorry I don't understand what you are talking about. "Writing a create queue" does not seem to make much sense to me, and I don't see the link with the snippet posted
"Keyboard not detected. Press F1 to continue"
-- Windows
-
DerKleineNik
- Knows some wx things

- Posts: 29
- Joined: Fri Sep 09, 2011 9:59 am
Post
by DerKleineNik » Thu Nov 24, 2011 7:47 am
Isn't that already some kinde of "create queue"?
It reads a number of words from the file and "creates" the EditBox text with that words one after the other.
Should you maybe rewrite that code using another kind of loop for example "for" instead of "while"?