TStringList - type name expected error

Started by
1 comment, last by 15Peter20 16 years, 1 month ago
hi guys, im currently creating a steganography demo in borland builder 6.0 (yes i know it sucks but its what ive been asked to use lol) i jsut created a random class with which ill include some functions for my program. in my class header file i haev declared an ImageList as TStringList* ImageList, however it is pulling up an expected type name error. ive searched through my code and im sure i have included the header and the cpp file correctly into the project. here is my main code so far, followed by the class and its header:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <jpeg.hpp>

#include "C_Random.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFmSlideShow *FmSlideShow;
C_Random Random;
//---------------------------------------------------------------------------
__fastcall TFmSlideShow::TFmSlideShow(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFmSlideShow::sbtnOpenClick(TObject *Sender)
{
        if (!OpenImageDIR->Execute()) return;

        AnsiString Dir = ExtractFileDir(OpenImageDIR->FileName); // get the Dir
        AnsiString Ext = ExtractFileExt(OpenImageDIR->FileName); // get the Ext

        Random.GetFileNames(Ext, Dir, Memo1, OpenImageDIR);

        //StatusBar1.Panels[0]->Text = "what";
}
//---------------------------------------------------------------------------

void __fastcall TFmSlideShow::sbtnStretchClick(TObject *Sender)
{
        Image1->Stretch = !Image1->Stretch;
}
//---------------------------------------------------------------------------


void __fastcall TFmSlideShow::sbtnProportionalClick(TObject *Sender)
{
        Image1->Proportional = !Image1->Proportional;
}
//---------------------------------------------------------------------------


void __fastcall TFmSlideShow::sbtnQuitClick(TObject *Sender)
{
        FmSlideShow->Close();
}
//---------------------------------------------------------------------------

header and class:

#ifndef C_Random_H
#define C_Random_H

#include "C_Random.h"

class C_Random
{

public:

        int GetFileNames(AnsiString Ext, AnsiString Dir, TMemo* Memo1, TOpenDialog* OpenImageDIR, bool Random = true);

        void CreateList();

        TSringList* ImageFiles;

private:

};
#endif


#include "C_Random.h"
#include <iostream.h>
#include <cstdlib.h>

void C_Random::CreateList()
{
        ImageFiles = new(TStringList);
}

int C_Random::GetFileNames(AnsiString Ext, AnsiString Dir, TMemo* Memo1, TOpenDialog* OpenImageDIR, bool Random);
{
        CreateList();

        // Collect all files of the same type
        TSearchRec SearchRec;

        int iAttributes = faAnyFile; // Read only etc

        // provide FindFirst with Dir and filename example
        if (FindFirst(Dir+"\\*"+Ext, iAttributes, SearchRec) == 0)
        {
                Memo1->Lines->Add(Dir+"\\"+SearchRec.Name);

                // add first picture to the main image
                Image1->Picture->LoadFromFile(OpenImageDIR->FileName);
                //StatusBar.Panels[0]->Text = (Dir+"\\"+SearchRec.Name);
                while (FindNext(SearchRec) == 0)
                {
                        Memo1->Lines->Add(Dir+"\\"+SearchRec.Name);
                }
        }
        else
                ShowMessage("Directory search failed!");
                FindClose(SearchRec);
}

any help on spotting why this error, will be muchO help 15Peter20
Advertisement
Quote:class C_Random
{

public:

int GetFileNames(AnsiString Ext, AnsiString Dir, TMemo* Memo1, TOpenDialog* OpenImageDIR, bool Random = true);

void CreateList();

TSringList* ImageFiles;


That last line spells "String" wrong. I'm not sure if that's the way it is in your code, but at least here it's wrong.
Mike Popoloski | Journal | SlimDX
lol yes that was spelt wrong in my code xD

have changed that and now it is still cocking up with the same errors:

[C++ Warning] Unit1.cpp(4): W8058 Cannot create pre-compiled header: write failed
[C++ Error] C_Random.h(14): E2303 Type name expected
[C++ Error] C_Random.h(14): E2139 Declaration missing ;
[C++ Error] C_Random.cpp(7): E2451 Undefined symbol 'ImageFiles'
[C++ Error] C_Random.cpp(7): E2303 Type name expected
[C++ Error] C_Random.cpp(7): E2285 Could not find a match for 'operator new(unsigned int,int)'

This topic is closed to new replies.

Advertisement