Very strange error

B

Benry

Hey, I figured my first post would be something grand, but instead I
have this really odd issue. I'm using VC++ 6.0 in XP Home (at work,
don't ask..I'm asking to move to something different and new). I'll
just paste my code:

"""
void CCylinderControlDlg::OnOK_Clicked()
{
CString strOne;
CString strTwo;


m_editOne.GetWindowText(strOne);
m_editTwo.GetWindowText(strTwo);

if((atof(strOne) > 0) && (atof(strOne) < 1) && (atof(strTwo) > 0)){
Interval = atof(strOne);
m_LengthOfTime = atof(strTwo);
Peak = Interval/2;
Run_Summer();

}
else{
AfxMessageBox("Please enter valid data");
CDialog::OnCancel();
}


}
double* CCylinderControlDlg::Run_Summer(){

m_test=(SAMPLE_RATE * m_LengthOfTime) + 1;

m_test2=Peak*SAMPLE_RATE;

double* buffer2;
buffer2 = new double [m_test];

for(int i = 0 ; i < m_test2 ; i++){ // start rising edge of triangle
buffer2 = (i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;
}
for(i = 0 ; i < m_test2 ; i++){ // start falling edge of triangle
buffer2 = (Peak - i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;
}

return buffer2;
}
"""

The error I'm getting is "C:\Documents and Settings\stevenr\My
Documents\Software Related\Cylinder Control\Cylinder
ControlDlg.cpp(201) : error C2059: syntax error : '='"

And this is for the following lines:

1. m_test=(SAMPLE_RATE * m_LengthOfTime) + 1;
2. m_test2=Peak*SAMPLE_RATE;
3. buffer2 = (i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;
4. buffer2 = (Peak - i/SAMPLE_RATE) * MAX_PEAK_VOLTAGE;

SAMPLE_RATE has been pound defined as 10000, MAX_PEAK_VOLTAGE is 5,
m_LengthOfTime has been atof()'ed from a CString from an EditBox on a
dialog, so has Peak. I'm really wondering where this error is coming
from...I've tried to cast each of these to the correct type. I pasted
the only two functions that I've written so far today, and I can't get
paste this blasted error..it's boggling my mind! I've cleared all of
intermediate files, rebooted, rearranged, etc etc etc...and can't
understand why I'm not able to assign a value to a variable...

Anyway, any help would be appreciated. Thanks.

-Ben
 
R

red floyd

Benry said:
[irrelevant code redacted\
"""

The error I'm getting is "C:\Documents and Settings\stevenr\My
Documents\Software Related\Cylinder Control\Cylinder
ControlDlg.cpp(201) : error C2059: syntax error : '='"

What is line 201? We can't tell from your sample clip.
 
P

Phlip

Benry said:
m_test=(SAMPLE_RATE * m_LengthOfTime) + 1;

What does SAMPLE_RATE look like? This?

#define SAMPLE_RATE 20;

Note the ; on the end. It shouldn't be there, because # things evaluate
before the core C++ language engages.
 
B

Benry

They look exactly like this:

//#define MAX_PEAK_VOLTAGE = 5
#define SAMPLE_RATE = 10000

Note the comment, I just added that because I started moving on.
But...I got the same error on this line:

if(counter_for_wave < (m_LengthOfTime*SAMPLE_RATE)){

WTF!!! There isn't even an equals sign on this line!!!! I don't get
it!
 
B

Benry

I get this error four times, all with the line numbers of what I've
annotated above in the list 1-4.
 
P

Peter Kragh

Benry said:
They look exactly like this:

//#define MAX_PEAK_VOLTAGE = 5
#define SAMPLE_RATE = 10000

Should be:

#define SAMPLE_RATE 10000

Remember the defines are translated by the preprocessor. I.e.

#define SAMPLE_RATE = 10000 would be

if(counter_for_wave < (m_LengthOfTime* = SAMPLE_RATE)){

Have you considered using const's instead? E.g.

const unsigned SAMPLE_RATE = 10000;

This will be handled by the compiler instead of the preprocessor. At
least you will get more meaningfull error messages from the compiler :)

HTH.
 
B

Benry

wow, I totally missed that. It's been a long week, I appreciate the
help. Thanks.

-Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,203
Messages
2,571,059
Members
47,668
Latest member
SamiraShac

Latest Threads

Top