About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
Move the code to another *. cpp
Author Message
Babulesnik Offline
Member

Post: #1
Move the code to another *. cpp
Move code Lobbi.cpp in Lobbi_lib.cpp.If I do so then a lot of mistakes:


Code Lobbi_lib.cpp:
#include "stdafx.h"
#pragma once
#include "Lobbi.cpp"
void test()
{
chat_bufer_1=text_enter;
chat_bufer_2=chat_bufer_1;
chat_line_1=chat_bufer_1.remove(30,55);
chat_line_2=chat_bufer_2.remove(0,30 );


if( text_enter.length()>30)
{
Data_Chat[chat_list_count].str_chat=chat_line_1;
chat_list_count=chat_list_count++;
Data_Chat[chat_list_count].str_chat=chat_line_2;
chat_list_count=chat_list_count++;
scroll_pos=Flt(chat_list_count)/20;
if (chat_list_count>8)
lobbi_chat.getRegion("chat_region").scrollToY(scroll_pos);
}else
{
Data_Chat[chat_list_count].str_chat=chat_line_1;
chat_list_count=chat_list_count++;
scroll_pos=Flt(chat_list_count)/20;
if (chat_list_count>8)
lobbi_chat.getRegion("chat_region").scrollToY(scroll_pos);
}

}

Code Lobbi.cpp:

#include "stdafx.h"
#include "resource.h"
#include "kosti.h"
#pragma once
#include "Lobbi_lib.cpp"

..........

Bool Update()
{
...
test();

}

How to solve this problem?


Attached File(s) Image(s)
   
02-25-2011 10:20 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: Move the code to another *. cpp
Including cpp files? If you want to make a function call to test() from Lobbi.cpp and want the body of said function in a separate file, just make a header called Lobbi_lib.h and in that file fill it with your function. You won't need to include anything in the header.

In Lobbi_lib.h
Code:
void test()
{
    ...
}

In Lobbi.cpp
Code:
...
#include "Lobbi_lib.h"
(This post was last modified: 02-26-2011 05:00 AM by Dandruff.)
02-26-2011 04:55 AM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #3
RE: Move the code to another *. cpp
(02-26-2011 04:55 AM)Dandruff Wrote:  Including cpp files? If you want to make a function call to test() from Lobbi.cpp and want the body of said function in a separate file, just make a header called Lobbi_lib.h and in that file fill it with your function. You won't need to include anything in the header.

In Lobbi_lib.h
Code:
void test()
{
    ...
}

In Lobbi.cpp
Code:
...
#include "Lobbi_lib.h"

If I transfer the code in the header file Lobbi_lib.h-many mistakes.
In the header file I need to write # include "Lobbi.cpp" so all the ads for this code are in Lobbi.cpp

Errors:

...

1> c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(36) : see declaration of 'Struct_Normal'
1>c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(49): error C2227: left of '->name' must point to class/struct/union/generic type
1>c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(49): error C2661: 'EE::ListGroup::ListGroup' : no overloaded function takes 3 arguments
1>c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(50): error C2027: use of undefined type 'Struct_Normal'
1> c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(36) : see declaration of 'Struct_Normal'
1>c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(50): error C2227: left of '->count_pl' must point to class/struct/union/generic type
1>c:\documents and settings\дима\рабочий стол\esenthelenginesdk\tutorials\lobbi.cpp(50): error C2661: 'EE::ListGroup::ListGroup' : no overloaded function takes 3 arguments
...
02-26-2011 09:36 AM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #4
RE: Move the code to another *. cpp
If want transfer it move it to new function in this file. You can't move code if it use some variable or function from this file, or need many changes.
02-26-2011 09:59 AM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #5
RE: Move the code to another *. cpp
Not to create a new topic I decided to write here.
I created the structure of IM but when called to Lobbi.cpp
Chat (). Init_Chat ();-nothing happens. Why? No errors no issues.

Here is the code Lobbi_Lib.h:

struct Struct_Chat
{
Str str_chat;
}Data_Chat[150]=
{
{"678"},
{"678"},
{"678"},
};
ListGroup Chat_Group[]=
{
ListGroup(MEMBER(Struct_Chat,str_chat),0.47,L"Data ChatRoom"),
};
// ListGroup Chat_Group=ListGroup(DATA_STR,1,2,0.5f,L"");

struct Chat
{
GuiObjs Chat_Obj;
Str Name_Region
,Path_Gobj;
List <Struct_Chat>List_Chat;

void Init_Chat()
{
Name_Region="Chat_Region";
Path_Gobj ="../Data/Gui/Obj/chat.gobj";

Chat_Obj.load (Path_Gobj );Gui+=Chat_Obj;
Chat_Obj.getRegion(Name_Region)+=List_Chat.create(Chat_Group,1).setData(Data_Cha​t,ELMS(Data_Chat));
};
};
02-26-2011 04:20 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #6
RE: Move the code to another *. cpp
http://www.cplusplus.com/doc/tutorial/classes/

For your previous question, make sure they are defined before calling them
02-26-2011 10:25 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #7
RE: Move the code to another *. cpp
(02-26-2011 10:25 PM)Dandruff Wrote:  http://www.cplusplus.com/doc/tutorial/classes/

For your previous question, make sure they are defined before calling them
Thanks.
(02-26-2011 04:20 PM)Babulesnik Wrote:  Not to create a new topic I decided to write here.
I created the structure of IM but when called to Lobbi.cpp
Chat (). Init_Chat ();-nothing happens. Why? No errors no issues.

Here is the code Lobbi_Lib.h:

struct Struct_Chat
{
Str str_chat;
}Data_Chat[150]=
{
{"678"},
{"678"},
{"678"},
};
ListGroup Chat_Group[]=
{
ListGroup(MEMBER(Struct_Chat,str_chat),0.47,L"Data ChatRoom"),
};
// ListGroup Chat_Group=ListGroup(DATA_STR,1,2,0.5f,L"");

struct Chat
{
GuiObjs Chat_Obj;
Str Name_Region
,Path_Gobj;
List <Struct_Chat>List_Chat;

void Init_Chat()
{
Name_Region="Chat_Region";
Path_Gobj ="../Data/Gui/Obj/chat.gobj";

Chat_Obj.load (Path_Gobj );Gui+=Chat_Obj;
Chat_Obj.getRegion(Name_Region)+=List_Chat.create(Chat_Group,1).setData(Data_Cha​t,ELMS(Data_Chat));
};
};

It was necessary to create a structure and then call it. Here is working code:

//==============================================
struct S_Chat
{
Str str_chat;
};/*Data_Chat[50]=
{
{"test_string"},
};*/
ListGroup Chat_Group[]=
{
ListGroup(MEMBER(S_Chat,str_chat),0.47,L"Data ChatRoom"),
// ListGroup(DATA_STR,1,2,0.5f,L""),
};
// ListGroup Chat_Group=ListGroup(DATA_STR,1,2,0.5f,L"");

struct Struct_Chat
{
Memb<Str>Data_Chat;
GuiObjs Chat_Obj;
Str Name_Region
,Path_Gobj;
List <Struct_Chat>List_Chat;
TextDS ChatFont;

void Init_Chat()
{
Data_Chat.add("12345");
//Data_Chat.add("56789");

ChatFont.reset();
ChatFont.font=Fonts("../Data/Gui/Fonts/chat_font.font");
Name_Region = "Chat_Region";
Path_Gobj = "../Data/Gui/Obj/chat.gobj";
Chat_Obj .load (Path_Gobj );Gui+=Chat_Obj;
Chat_Obj .getRegion(Name_Region).width=0.04 ;
Chat_Obj .getRegion(Name_Region)+=List_Chat.create(Chat_Group,1,true).setData(Data_Chat);​//(Data_Chat,ELMS(Data_Chat));
List_Chat.tds =&ChatFont;
ChatFont .color=Color(255,241,191);
List_Chat.lit_color=Color(0,0,0,0);
List_Chat.cur_color=Color(0,0,0,0);


};
};
Struct_Chat Chat; -Here is where the problem. In the one line)))
//==============================================

Chat.Init_Chat(); -Works fine )
(This post was last modified: 02-27-2011 12:53 AM by Babulesnik.)
02-27-2011 12:48 AM
Find all posts by this user Quote this message in a reply
Post Reply