In the scaled down version, I only have 3 files : Form1.cpp, Lab Test 2.h, &
Form2.h . The contents of Form1.cpp are :
#include "stdafx.h"
#include "Form2.h"
#include <windows.h>
using namespace K1;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new Form2());
return 0;
}
The contents of LabTest 2.h are :
#define MAX_DWELL_SAMPLES 1000
typedef unsigned short ushort;
#pragma pack(1)
#pragma pack()
/*
***********************
** Function prototypes
***********************
*/
int ReadLn(FILE *ifile, char line[]);
& the contents of Form2.h are :
#pragma once
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <sys/timeb.h>
#include <time.h>
#include "LabTest 2.h"
namespace K1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
int point_cnt = 0, dwell_samples = 0;
char ifname[80];
FILE *sfile;
char *timeline;
int i, retries;
struct _timeb timebuffer;
BOOL bStatus;
/// <summary>
/// Summary for Form2
///
/// WARNING: If you change the name of this class, you will need to change
the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public __gc class Form2 : public System::Windows::Forms::Form
{
public:
Form2(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Button * button1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container* components;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = new System::Windows::Forms::Button();
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(112, 112);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(144, 48);
this->button1->TabIndex = 0;
this->button1->Text = S"test button";
this->button1->Click += new System::EventHandler(this, button1_Click);
//
// Form2
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(400, 254);
this->Controls->Add(this->button1);
this->Name = S"Form2";
this->Text = S"Form2";
this->ResumeLayout(false);
}
private: System::Void button1_Click(System::Object * sender,
System::EventArgs * e)
{
FILE *ifile;
int ret = FALSE, i, status;
char line[80];
ifile = fopen(ifname, "rt");
if (ifile == NULL) printf("Unable to open %s\n", ifname);
else
{
status = ReadLn(ifile, line);
if (status) sscanf(line, "%d", &dwell_samples);
if (dwell_samples > MAX_DWELL_SAMPLES) dwell_samples =
MAX_DWELL_SAMPLES;
i = 0;
status = ReadLn(ifile, line);
while (status)
{
status = ReadLn(ifile, line);
i++;
}
point_cnt = i;
ret = TRUE;
}
fclose(ifile);
}
};
int ReadLn(FILE *ifile, char line[])
{
int status, i = 0;
char buffer;
status = fread(&buffer, 1, 1, ifile);
while ((status) && (buffer != '\n') && (i < 80))
{
line[i++] = buffer;
status = fread(&buffer, 1, 1, ifile);
}
line[i] = 0;
return status;
}
}
Regards,
ak
> Have you added the corresponding cpp file to the project?
>
[quoted text clipped - 21 lines]
> > Regards,
> > ak
Nishant Sivakumar - 08 Nov 2005 17:06 GMT
In labtest2.h, the function should be declared as :-
namespace K1
{
int ReadLn(FILE *ifile, char line[]);
}

Signature
Regards,
Nish [VC++ MVP]
> In the scaled down version, I only have 3 files : Form1.cpp, Lab Test 2.h,
> &
[quoted text clipped - 209 lines]
>> > Regards,
>> > ak
AK - 08 Nov 2005 17:34 GMT
Yes - that does it !
Thank you for the help - this will remind me to protype functions within
the namespace of their use.
Regards,
ak
> In labtest2.h, the function should be declared as :-
> namespace K1
> {
[quoted text clipped - 214 lines]
> >> > Regards,
> >> > ak