?
Solved

Undeclared Identifier

Posted on 2003-03-03
16
Medium Priority
?
401 Views
Last Modified: 2013-11-20
Hi

I am returning to MFC to find I am a little
rusty on things.

I have a document called XOfficeDoc
and a form called FormDemo.

I call the following from a button event

UpdateData();
NewXOfficeDoc("XOffice.doc",m_str, m_double, m_long);



(NewXOfficeDoc is a member of XOfficeDoc)

m_str, m_double and m_long are bound variables to
edit boxes on my form. I am getting the undeclared
identifier error, I have checked the includes, spelling, headers etc and everything appears fine.

the form knows about the document but wont call
the document function!!!

Any Suggestions
0
Comment
Question by:mjwilliamson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 4
16 Comments
 
LVL 3

Expert Comment

by:cmaryus
ID: 8057344
> I have a document called XOfficeDoc ?
You mean a class XOfficeDoc ?


>(NewXOfficeDoc is a member of XOfficeDoc)
NewXOfficeDoc is an object of the class XOfficeDoc ?

If so, you must include the header where the class XOfficeDoc is declared in the source file of the form:

#include "XOfficeDoc.h"

...
void CForm::OnSomeButton()
{
...
UpdateData();
NewXOfficeDoc("XOffice.doc",m_str, m_double, m_long);
...
}
0
 

Author Comment

by:mjwilliamson
ID: 8057440
exactly - I Have the declaration in the
form code file.

I still get the error!!

Theoretically I know what should be done
- practically I seem to have missed something!
0
 
LVL 3

Expert Comment

by:cmaryus
ID: 8057486
You declared NewXOfficeDoc object?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:cmaryus
ID: 8057507
You declared NewXOfficeDoc object?
0
 
LVL 3

Expert Comment

by:cmaryus
ID: 8057523
You declared NewXOfficeDoc object?
0
 

Author Comment

by:mjwilliamson
ID: 8057720
Sorry, maybe I not explain to well.

NewXOffice is a method of XOfficeDoc
so no NewXOfficeDoc object required.

I am basically trying to call the following function

void NewXOfficeDoc(LPCTSTR aTemplate, LPCTSTR aStr, double aDouble, long aLong)
{
     CString str;
     POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition();

     while (pos != NULL) {

          CDocTemplate *temp = AfxGetApp()->GetNextDocTemplate(pos);
          if (temp->GetDocString(str,CDocTemplate::docName) && str == _T("XOffice")) {
               g_template = aTemplate;
               g_str = aStr;
               g_double = aDouble;
               g_long = aLong;
               temp->OpenDocumentFile(NULL);
               return;
          }
     }
}

contained within XOfficeDoc from FormDemo.cpp.

Thanks
0
 

Expert Comment

by:daknight2000
ID: 8058711
just suggestions..

if ur NewXOfficeDoc is member of XOfficeDoc class then:

1: definition should be
void XOfficeDoc::NewXOfficeDoc(LPCTSTR aTemplate, LPCTSTR aStr, double aDouble, long aLong)
{
...
...
}

2: if u calling NewXOfficeDoc from CFrom then XOfficeDoc object   will be required... like

void CForm::OnSomeButton()
{
...
UpdateData();
urXOfficeDoc.NewXOfficeDoc("XOffice.doc",m_str, m_double, m_long);
...
}
GetDocument() could be used if CForm is derived from CView ??????
am i right??????
:-)

0
 
LVL 3

Expert Comment

by:cmaryus
ID: 8062717
to  daknight2000
yep, that's the only ways ...
you're right also about GetDocument()
0
 

Author Comment

by:mjwilliamson
ID: 8064375
I think you are right but I found another way of doing
it.

If you put

void NewXOfficeDoc(LPCTSTR aTemplate, LPCTSTR aStr, double aDouble, long aLong);

in the file containing the function call.

I don't know why it works though!


0
 

Author Comment

by:mjwilliamson
ID: 8064385
im not sure what to do with the points?
0
 

Expert Comment

by:daknight2000
ID: 8065232
>>I think you are right but I found another way of doing
>>it.

>>If you put

>>void NewXOfficeDoc(LPCTSTR aTemplate, LPCTSTR aStr, >>double aDouble, long aLong);

now NewXOfficeDoc() is a global; thats why u are not getting any errors

:)))

0
 
LVL 3

Expert Comment

by:cmaryus
ID: 8065397
>>void NewXOfficeDoc(LPCTSTR aTemplate, LPCTSTR aStr, >>double aDouble, long aLong);

just a funnction, not a method...
0
 

Author Comment

by:mjwilliamson
ID: 8065629
cool

cheers guys
0
 

Accepted Solution

by:
daknight2000 earned 80 total points
ID: 8066031
how about giving some points?
0
 

Author Comment

by:mjwilliamson
ID: 8066298
I did ask what to do with the points but got no answer.

thanks again
0
 

Expert Comment

by:daknight2000
ID: 8069491
Thanks for the points
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question