Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem with rc form

Hi,
further to this
https://www.experts-exchange.com/questions/28704842/Problem-to-project.html

which static text control, should I choose below?
User generated image
Avatar of sarabande
sarabande
Flag of Luxembourg image

as told, delete the File Number controls (4 controls) and remove the associated code.

then make the form wider and higher such that the Binary File Info could take the 'New Name' static text and associated edit control and button 'Update Name'. give good names for the id's as suggested multiple times. by right-click on the new controls you may add members and event handlers similar to the already existing code.

Sara
Avatar of Peter Chan

ASKER


as told, delete the File Number controls (4 controls) and remove the associated code.
I think I should remove Record number and Item number, right?
no. record number and item number were needed for the info blocks and the get record function.

Sara
Many thanks Sara.

Is it only to delete the items highlighted in red below?

User generated image
Any advice? Thanks a lot to Sara.
as told, only delete 4 controls regarding file number of index files. also remove functionality in dialog cpp and dialog h for these controls.

the index files with file numbers were only for temporary use. it makes less sense to evaluate them further since they were no longer used for retrieval purposes.

Sara
Very sorry Sara. Is it fine that I delete the highlighted items in above? If yes, definitely, I would further delete their related codes.
Good day Sara,
Is it fine that I remove any reference to the names like
#define IDC_RAD_NAME                    1001
#define IDC_RAD_NUMBER                  1002
#define IDC_RAD_DATARECORD              1003
IDC_EDIT_FILE_PATH

Open in new window

no, if you still want to use `'get record' button and access records of either name index, number index, and item data.

yes, if you only want a program, to change name of an item record.

i would recommend to keep the 'get record' functionality, since it may allow you to verifiy you whether the update functionality worked correctly or not.

Sara
Many thanks.
Is it fine that I remove the whole line like

EDITTEXT        IDC_EDIT_FILE_PATH, 62, 94, 199, 14, ES_AUTOHSCROLL

Open in new window


?
yes. you should calculate the path nevertheless if the radio box selection changed and fill the member m_strFilePath with constant strings as suggested earlier.

Sara
Many thanks Sara.

It says "Unloaded" below. How to load it?
tt281.png
in the solution explorer tree select project binaryfileviewer (not solution), right-click and load project.

or. close the solution and reopen what should load the project as well.

Sara
Good day Sara,

to the current form below
 User generated image
I think I really need one "console application" that is to search the previous generated list of files, are having the relevant name inside, or not. If not, within the above rc2 form, we will append both name and number to the relevant files.
BTW, here is what I get, to run ReadBinaryFile
User generated image
if I put the same Name Key (highlighted below), I get the following
User generated image
is there anything wrong?
the item number shown in the output window surely is wrong. should be 1 to 10.

the rest looks ok. did you scroll the data record whether the searched key is at another item number?

"console application" and rc form don't fit so well together. normally you would have client-server. the server is a service, means a background program which neither has a gui nor a console. the client is either a console or a gui program and sends requests to the server which then does the updates or retrievals to the database.

note, we have some kind of database created by savebinaryfile and accessed by readbinaryfile.

the mfcapplication9 should it make possible to verify if write and read have worked correctly.

all this should work without errors before we think to add new items or to update existing items.

also note, a database with sorted index files is not so much suitable to be updated or to add keys, since this means that the index files needs to be written again.

if you want to have the database to be suitable for updates, new items, and deletions, we have to redesign the index files. they need to be organized as b-trees such that updates only require to update a few records rather than rewrite the whole index file.

Sara

they need to be organized as b-trees such that updates only require to update a few records rather than rewrite the whole index file.
Many thanks Sara.

can I have more details to re-design ReadBinaryFile project?
do you really want to redesign all we made to a client-server architecture?
it is not only readbinaryfile but also savebinaryfile which needs to be redesigned for index files.

Sara
Yes, can we step-by-step do it? Firstly, ReadBinaryFile, and later SaveBinaryFile and other projects, if necessary?
yes. first i will describe the new index files which need to be a tree rather than a sorted list.

is it still a goal to have 10 million of items stored in the database?

Sara
Yes, correct.

Many thanks Sara.
SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks. could you please update with more details to adjust the process to create files (that is SaveBinaryFile project), by using b-tree?
Many thanks Sara.
Can I know more details to adjust SaveBinaryFile to represent bitmap record and one bucket?
as suggested we would not use 64-bit savebinaryfile but a new 32-bit dll - called database_server - which could be linked to new mfc application called database_client.

savebinaryfile then is one function of the new server (dll) that could be invoked by a button of mfc client.

we could start two ways. one is to have a new mfc application with one button 'create new database' you could enter name of the database (file), number of items per record, number of records. second we have a dll project (32-bit) with one function that is to create the database files and fill the data file and the index file properly.

second is that we have a console program like savebinaryfile which creates tree index files rather than index files with sorted lists.

the first way already is heading against the final solution towards client-server database. the second firstly tries to use as most of the existing solution as possible.

How do you want to proceed?

Sara
Many many thanks Sara. 2nd way can be fine.
Ok. Create a new 32 Bit win32 console project. Name it 'DataBaseServer'. No Precompiled Headers, empty project, unicode enabled.

You May copy the savebinaryfile.cpp to the New project folder, but rename main function to savebinaryfile since we will need a New main function.

The New main will have a while loop where it waits for a request of a Client program. The First request we implement is to create a New database. For that we will use Code of savebinary file beside of creation of index files.

Sara
Many thanks Sara.


The New main will have a while loop where it waits for a request of a Client program.

More details to this?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Sara,
I copy SaveBinaryfile.cpp to the new project, and how to refer to this cpp file, within the new project?

but rename main function to savebinaryfile

Is it case-sensitive? should I name it as "SaveBinaryFile"?

Many thanks.
Is it to put your current codes into "DBServer.cpp"? If yes, how about the current codes like
int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}

Open in new window


within that?
the filename is not case sensitive.

if you would have created an empty project you wouldn't have any files like DBServer.cpp.

is DBServer a 32-bit win32 console project as suggested? if not, you should exit from vs and delete the project and create again. i want to use the DBServer with winapi what is difficult doing it with 64 bit.

i also suggest to switch-off unicode for the DBServer since we don't need mfc for the server part. it is in he general page of the project configuration settings where you have to choose 'multibyte character set' instead of 'unicode' for character set (both for debug and release configuration).

the DBServer.cpp would get the code i posted. if you created a new empty project you have to 'add .... new item ...' and create an empty dbserver.cpp. if dbserver already is 32-bit you could use the current cpp file but replace all contents with my post. delete stdafx.h and stdafx.cpp from project.

it might be that the code doesn't compile since i am at holiday and don't have a vs compiler. try to solve simple errors like 'undefined symbols' if i made a typo yourself. later we will create a dbserver.h and move all class declarations to the header. if you want you could try yourself. look how we did it with binaryfileheader.h.

the savebinaryfile.cpp not necessarily must compile since we only use it as a code base for to copying existing functionality. so you can but must not add it to the project by 'add ... existing item'.

Sara
Many thanks Sara. Please enjoy your holiday and when will you be back?
I get this
Error	1	error C4996: 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	c:\dbserver\dbserver\savebinaryfile.cpp	98	1	DBServer

Open in new window


when compiling the current project.

Many thanks
i will be back next week friday. nevertheless we can continue since most is new code anyhow.

the error you encountered actually is a warning which turned to an error if you don't decrement errorlevel 4.

the mbstowcs converts a narrow string to a wide string. you may replace it by mbstowcs_s which is a little bit safer as it requires you to pass the size of the target buffef as an additional argument. if you search for the reference docs of mbstowcs_s and compare it to those of mbstowcs you should be able to avoid the error.

note, since we try to have dbserver project as a multibyte and not a unicode project, we rarely have much need to convert from single char to wide char. so, this call in savebinaryfile.cpp probably will not be overtaken to dbserver.cpp.

Sara
as told the first request we try to implement is to a create a new database with 3 files, a data file and two index files. the number of records and the number of items per record are variable. so we could begin to create a small database as a starter, test all basic things and later create bigger databases.

is that right for you?

Sara
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good day Sara,

To last line below
	...
	std::string  strtext = os.str().substr(0, maxsize);
	std::wstring wstrtext(strtext.size() + 1, L'\0');
	size_t numChars, numChars2;
	mbstowcs_s(&numChars, &wstrtext[0], numChars2, strtext.c_str(), strtext.size());

Open in new window


what should I initialize 3rd parameter to?

Please enjoy your holidays and best wishes!
The 1st numchar should be 0, the 3rd numchar2 should be size of buffer. If This is a wstring you have to resize it before calling mbstowcs_s.
I See that it already was resized. So use wrstrtext.length() for initialising.
Sara
Good day Sara,
DBServer.cpp is now not calling events of SaveBinaryFile.cpp. what we do next?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Sara,
Where should "CreateDBRequest" be located at? Is the Header similar to the Header appears on Mfc application?

Enjoy your holidays and Have a great weekend!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
do you proceed into turning main function of savebinaryfile project to SaveBinaryFile function being called in dbserver.cpp?

if not post where you were stuck.

Sara