hello

i am building an application in Visual c++ 6 and i want to save some variable values. i tried in all ways, until i try just to save a value that i declared right in the "Serialize" function of my CDocument class :

void CDiplomaDoc::Serialize(CArchive& ar)
{
        r=3;
	if (ar.IsStoring())
	{
		// TODO: add storing code here
        ar << r;
	}
	else
	{
		// TODO: add loading code here

	}
}

I specified to save my work in a .nor file extension. so, when i run the application, i press the save as button from the menu in my sdi application (document-view) and i save my work. but when i open the file on my computer where i tried to save this variable - i open it with notepad - and i have there : 0 . when i made r=54 for example i had 6 in the file! why/ do you know what i can do ? what do i do wrong ?:(

PS : my application is a drawing one, draws using opengl a cube, or a cone, etc. selected from the menu. but i just run the app. and i hit save as, and this is what happens(i do this to test the serialize function only)
thanks in advance.

That saves it as binary data, so you can not view it with Notepad. If you want it saved as text then convert with CString

CString s;
s.Format("%d", r);
ar << s;

Thank you very much. I want to ask if i can serialize like this for example an entire drawing?
Like a rotating cube. I do my drawing in the Document class, in a method RenderScene using opengl. i don't store my cube in anything, so i was wondering how can i serialize an entire drawing. can it be done? i've only read about serializing variables, like in a database application, but not a rotating cube for example.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.