April 26, 2024, 10:15:32 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Project Building-Newb' question

Started by Haim, September 23, 2006, 12:47:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

Up till now I worked only with single source files.
I am now trying my first project with two source files and one include file.

when I try to comple and execute the project I get the following messages:

Compiling...
TrainingMain.src
TrainingDB.src
File: C:\Program Files\Aurora\projects\Training\TrainingDB.src (26) invalid character '0x0d'
-

Linking...
Aurora Linker v1.0 Copyright ÂÃ,©2005,2006 Ionic Wind Software
Unresolved external CtrainingDB@InitCourses
Error: Unresolved extern CtrainingDB@InitCourses
Error(s) in linking TrainingApp.exe

What am I doing wrong???????


Here is the code:

1. the include file
//TrainingApp.inc

//API declarations
declare import, GetSysColor(index as int),int;

//main menu constants

#define mnu_import       10
#define mnu_export      12
#define mnu_quit       99
#define mnu_courses      20
#define mnu_assigns      22


// Data Base Class Definitions

class CtrainingDB
{
   declare CtrainingDB();
   declare  _CtrainingDB();
   declare InitCourses(),int;
   declare InitAssigns(),int;
   
   string DBPath;
   string CourseDB;
   string AssignsDB;
}

2. the main source

//TrainingApp main window
#autodefine "off"
#include "TrainingApp.inc"


//CMainWin definition
class CMainWin : CWindow
{
   declare CMainWin();
   declare _CMainWin();
   declare virtual OnClose(),int;
   declare virtual OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
   declare virtual OnCreate(),int;
   declare virtual OnMenuPick(int nid),int;
}

//CMainWin Implementation
CMainWin::CMainWin()
{
}

CMainWin::_CMainWin()
{
}

CMainWin::OnClose(),int
{
   if( MessageBox(this,"Are You Sure?","Quit this app?",4) = 6)
   Destroy();
   return false;
return 0;
}

CMainWin::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
return 0;
}

CMainWin::OnCreate(),int
{
   CMenu m;
   Cwindow!!OnCreate();
   m.BeginMenu();
   
   m.MenuTitle( "&File");
   m.menuItem("Import from excel file...",0,mnu_import);
   m.menuitem("Export to excel file...",0,mnu_export);
   m.separator();
   m.MenuItem( "&Quit",0,mnu_quit);
   
   m.MenuTitle( "&View");
   m.menuitem("Courses",0,mnu_courses);
   m.menuitem("Course Assignments",0,mnu_assigns);
   m.EndMenu();
   SetMenu(m.Detach());
   
return 0;
}

CMainWin::OnMenuPick(int nid),int
{
   select nid
   {
      case mnu_quit:
      OnClose();
   }
   return true;
}

   
global sub main()
{
      
   CMainWin *pmainwin;
   pmainwin=new(CMainWin,1);
      
   pmainwin->create(0,0,800,600,AWS_VISIBLE|AWS_CAPTION|AWS_SYSMENU|AWS_MINIMIZEBOX|AWS_MAXIMIZEBOX,0,"Trainng Application",NULL);
   pmainwin->setwindowcolor(getsyscolor(15));
   
   CtrainingDB *db;
   db=new(CtrainingDB,1);
   db->initcourses();
   
   do {wait(); }until !(pmainwin->IsValid());
   if pmainwin != null delete(pmainwin);
   if !(db == null)  delete(db);

   return false;
}


3. class implementation source

//CTrainingDB.src

#include "TrainingApp.inc"



CtrainingDB :: CtrainingDB()
{
//DBpath=getstartpath();
}

CtrainingDB :: _CtrainingDB()
{

}

   
CtrainingDB :: Initcourses(),int
{
   
   return (7);
}

CtrainingDB :: InitAssigns(),int
{
   return 0;
}


Haim

I am aware of that thread and I know the rules, but it seems that despite all that I am unable to create a working project.
I am probably too dumb to find out the reason. I guess I need to be told.

Parker

Instead of defining an Initcourses method, try InitCourses (same way you declared it).

Haim

Thanks Parker and Mike, It works now.

I have not, until now, known that Aurora is case sensitive (sometimes..?)

What are the rules regarding case sensitivity in Aurora?

Haim

Parker

It's not actually case sensitive, but case does matter - identifiers are stored as the case they were typed, so you have to get the case right when declaring external or global functions and variables. However, as long as it was declared correctly, it doesn't matter how you type it (this is why we can use openfile, OpenFile, and OPENFILE for the same function, though fileio.inc has to declare OPENFILE because that is how it is exported).

Haim

Thanks,
I am not sure I understand this.
The code worked when it was in a single source file. Only when I separated it into multiple files the problem occured.
Is it possible that the linker is case sensitive while the compiler is not? I think this could prvide some explanation.

In any event, I tink that the Aurora tutorial and/or Help fies should be ammended to reflect this issue.

Haim

Ionic Wind Support Team

Yes the linker is case sensitve with externals.  Otherwise we wouldn't be able to use external objects compiled with other languages.

As parker stated you have to get the declare right.  Same as it was in my 'other' language.
Ionic Wind Support Team

Kale

This is how i structure a project.

When you want to have a seperate file that contains a class implementation, you have one include file (*.inc) in which you declare the class only. Like this:


#include "WindowsTypes.inc"

#define CCHDEVICENAME 32
#define CCHFORMNAME 32

struct SCREEN_COORDS
{
unsigned int x;
unsigned int y;
}

Struct DEVMODE
{
    CHAR dmDeviceName[CCHDEVICENAME];
    WORD dmSpecVersion;
    WORD dmDriverVersion;
    WORD dmSize;
    WORD dmDriverExtra;
    DWORD dmFields;
    SHORT dmOrientation;
    SHORT dmPaperSize;
    SHORT dmPaperLength;
    SHORT dmPaperWidth;
    SHORT dmScale;
    SHORT dmCopies;
    SHORT dmDefaultSource;
    SHORT dmPrintQuality;
    SHORT dmColor;
    SHORT dmDuplex;
    SHORT dmYResolution;
    SHORT dmTTOption;
    SHORT dmCollate;
    CHAR dmFormName[CCHFORMNAME];
    WORD dmLogPixels;
    DWORD dmBitsPerPel;
    DWORD dmPelsWidth;
    DWORD dmPelsHeight;
    DWORD dmDisplayFlags;
    DWORD dmDisplayFrequency;
    DWORD dmICMMethod;
    DWORD dmICMIntent;
    DWORD dmMediaType;
    DWORD dmDitherType;
    DWORD dmReserved1;
    DWORD dmReserved2;
}

class CDesktop
{
//Properties
DEVMODE Info;

//Methods
declare CDesktop();
declare GetWidth(), int;
declare GetHeight(), int;
declare GetBitDepth(), int;
declare GetFrequency(), int;
}


Then we have a source file (*.src) which contains the implementation (definition) of the class, like this:


#include "Desktop.inc"

#define SM_CXSCREEN 0
#define SM_CYSCREEN 1

declare import, EnumDisplaySettings alias EnumDisplaySettingsA(LPCTSTR lpszDeviceName, DWORD iModeNum, DEVMODE lpDevMode), int;

CDesktop::CDesktop()
{
EnumDisplaySettings(0, -1, Info);
}

// Get the width
CDesktop::GetWidth(), int
{
return Info.dmPelsWidth;
}

// Get the height
CDesktop::GetHeight(), int
{
return Info.dmPelsHeight;
}

// Get the bit depth
CDesktop::GetBitDepth(), int
{
return Info.dmBitsPerPel;
}

// Get the frequency
CDesktop::GetFrequency(), int
{
return Info.dmDisplayFrequency;
}


Notice the '#include "Desktop.inc"' command at the top. THis includes the include file which holds the declaration of that class.

To actually use this in a project, we create a new project in the IDE and open the above *.src file only and add it to the newly created project by right clicking on it in the IDE and selecting 'Insert File Into Project'. Include files are not added to a project because the source files have already included them.

Once you have include a seperate file like this into your project you can then create a new *.src file to hold the program that will use the above class. Like this:


#include "Desktop.inc"

declare import, Sleep(int Milliseconds);

global sub main()
{
CDesktop Desktop;
print("Desktop Width: " + str$(Desktop.GetWidth()));
print("Desktop Height: " + str$(Desktop.GetHeight()));
print("Desktop Bit Depth: " + str$(Desktop.GetBitDepth()));
print("Desktop Frequency: " + str$(Desktop.GetFrequency()));
print("");

//Main Loop
While (GetKey() = "")
{
sleep(1);
}
}


This main file also needs adding to the current project. Notice again the '#include "Desktop.inc"' command at the top. This includes the above class for use in our main source file. The compiler already knows where the class's implementation is because its added to the project. All source files added to the project are compiled. Include files are included into source files.

Haim

Thank you all for your explanations.

Haim

kryton9

Kale, thanks for that code too. I had been looking into the API, but I am not good with it yet and getting nowhere. That is really neat. I am going to go through now and see what all I can pull out of it, a must for graphics. So thanks, that is awesome!!

Kale

Quote from: kryton9 on September 23, 2006, 04:07:50 PM
Kale, thanks for that code too. I had been looking into the API, but I am not good with it yet and getting nowhere. That is really neat. I am going to go through now and see what all I can pull out of it, a must for graphics. So thanks, that is awesome!!

This is just a little sample really, it could be expanded to get more info from a users system and even support multiple monitors, etc. ;)