Click here to Skip to main content
15,917,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//---------------------------------------------------------------------------

#include <vcl.h>
#include <stdio.h>
#include <iostream.h>


#pragma hdrstop


#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
Form7->Caption = "untitled - Notes";
}
//---------------------------------------------------------------------------
String ImeFajla;
FILE *fp;
void __fastcall TForm7::Open1Click(TObject *Sender)
{
Memo1->Clear();
OpenDialog1->Execute();
FILE *fp;
fp = fopen(OpenDialog1->FileName.c_str(),"r");
ImeFajla = OpenDialog1->FileName;
Form7->Caption = ImeFajla+" - Notes";
char s[101];
char c;
int i = 0;
c = fgetc(fp);
while(c != EOF)
{
while(c != '\n' && c!= EOF)
{
s[i++] = c;
c = fgetc(fp);
}
s[i]='\0';
i = 0;
Memo1->Lines->Add(s);
c = fgetc(fp);
}
fclose(fp);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::SaveAs1Click(TObject *Sender)
{
SaveDialog1->Execute();
FILE *fp;
fp = fopen(SaveDialog1->FileName.c_str(),"w");
ImeFajla = SaveDialog1->FileName;
fprintf(fp,"%s",Memo1->Text.c_str());
Form7->Caption = ImeFajla+" - Notes";
fclose(fp);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Save1Click(TObject *Sender)
{
FILE *fp;
if ( ImeFajla != "")
{
fp = fopen(ImeFajla.c_str(),"w");
fputs(Memo1->Text.c_str(),fp);
Form7->Caption = ImeFajla+" - Notes";
}
else
{
SaveDialog1->Execute();
fp = fopen(SaveDialog1->FileName.c_str(),"w");
ImeFajla = SaveDialog1->FileName;
fprintf(fp,"%s",Memo1->Text.c_str());
Form7->Caption = ImeFajla+" - Notes";

}

fclose(fp);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Exit1Click(TObject *Sender)
{
Form7->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm7::New1Click(TObject *Sender)
{
Memo1->Clear();
ImeFajla = "";
Form7->Caption = "untitled - Notes";
}
//---------------------------------------------------------------------------
void __fastcall TForm7::font1Click(TObject *Sender)
{
if(FontDialog1->Execute())
Memo1->Font = FontDialog1->Font;
}
//---------------------------------------------------------------------------
void __fastcall TForm7::color1Click(TObject *Sender)
{
if(ColorDialog1->Execute())
Memo1->Color = ColorDialog1->Color;
}
//----------------------------------------------------------------------






[BCC32 Error] Unit7.cpp(28): E2451 Undefined symbol 'OpenDialog1'
[BCC32 Error] Unit7.cpp(54): E2451 Undefined symbol 'SaveDialog1'
[BCC32 Error] Unit7.cpp(74): E2451 Undefined symbol 'SaveDialog1'
[BCC32 Error] Unit7.cpp(99): E2451 Undefined symbol 'FontDialog1'
[BCC32 Error] Unit7.cpp(105): E2451 Undefined symbol 'ColorDialog1'
Posted

The problem is that the dialogs your referencing aren't defined.

At least that's my guess from the errors telling you that they're undefined.
 
Share this answer
 
What's 'OpenDialog1'? Where is defined?
And, please, give a meaningful title to your post.
:)
 
Share this answer
 
Have you included the needed .h files where the dialogs are?

On the other hand... you directly do:

[quote]
String ImeFajla;
FILE *fp;
void __fastcall TForm7::Open1Click(TObject *Sender)
{
Memo1->Clear();
OpenDialog1->Execute();
FILE *fp;
fp = ...
[quote]


and you should do the same with the dialogs as with the FILE* fp, I mean...

CMemoDialog* (or whatever the name of your class is) Memo1;
COpenDialog* OpenDialog1;

If you are doing it (it is not in the snippet you posted) probably you are having conflicts with "global" and "local" definitions.
For instance, in the part of your code that I quote, you have a File* fp out of the function, and then another one inside the function. The one inside the function doesn't have to be the same as the other because you are using it locally. But the String ImeFajla is just declared at the beginning and then used in the functions, that's the reason you don't get an error for it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900