Loading data from CArchive

I've written the following function for my program.  Seems to work
fine, however the only problem is I don't know what parameter to put
in the while loop, as you can see at the moment I just have '1' which
will obviously create an infinite loop, to know when to stop pulling
data from 'ar'.

void CLogicSimulatorDoc::Serialize(CArchive& ar)
{

	int posx, posy, input0x, input0y, input1x, input1y;
	int type;

	if (ar.IsStoring())
	{
		// TODO: add storing code here
		gate * gLoop;

		for (gLoop = gFirst; gLoop != 0; gLoop = gLoop->gNext)
		{
			input0x = (gLoop->inputs[0] != 0)?gLoop->inputs[0]->posx:-1;
			input0y = (gLoop->inputs[0] != 0)?gLoop->inputs[0]->posy:-1;
			input1x = (gLoop->inputs[1] != 0)?gLoop->inputs[1]->posx:-1;
			input1y = (gLoop->inputs[1] != 0)?gLoop->inputs[1]->posy:-1;

			ar << gLoop->posx << gLoop->posy << gLoop->type << input0x <<
input0y << input1x << input1y;
			count++;
		}
	}
	else
	{
		// TODO: add loading code here
		gate * gNew, * gSearch;

		while (1)
		{
			ar >> posx >> posy >> type >> input0x >> input0y >> input1x >>
input1y;

			gNew = find_gate_from_pos(posx, posy);
			if (gNew == 0)
				gNew = create_gate(type, posx, posy);
			else
				gNew->settype(type);

			if (input0x != -1 && input0y != -1) {
				gSearch = find_gate_from_pos(input0x, input0y);
				if (gSearch == 0)
					gSearch = create_gate(NOTSET, input0x, input0y);

				gNew->inputs[0] = gSearch;
			}

			if (input1x != -1 && input1y != -1) {
				gSearch = find_gate_from_pos(input1x, input1y);
				if (gSearch == 0)
					gSearch = create_gate(NOTSET, input1x, input1y);

				gNew->inputs[1] = gSearch;
			}
		}

	}
}

0
4/24/2007 3:27:31 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
389 Views

Similar Articles

[PageSpeed] 33

>I've written the following function for my program.  Seems to work
>fine, however the only problem is I don't know what parameter to put
>in the while loop, as you can see at the moment I just have '1' which
>will obviously create an infinite loop, to know when to stop pulling
>data from 'ar'.

If you don't know how many items to read (your file format doesn't
contain a count maybe?), I think the ar >> operation will throw an
exception when you read past the end - so you can use that to know
when to stop.

Dave
0
davidl7375 (2060)
4/24/2007 5:12:24 PM
Well, the simplest way id to archive the count before entering the loop.

"stefan" <stefanclark@gmail.com> wrote in message 
news:1177428451.620577.50980@n35g2000prd.googlegroups.com...
> I've written the following function for my program.  Seems to work
> fine, however the only problem is I don't know what parameter to put
> in the while loop, as you can see at the moment I just have '1' which
> will obviously create an infinite loop, to know when to stop pulling
> data from 'ar'.
>
> void CLogicSimulatorDoc::Serialize(CArchive& ar)
> {
>
> int posx, posy, input0x, input0y, input1x, input1y;
> int type;
>
> if (ar.IsStoring())
> {
> // TODO: add storing code here
> gate * gLoop;
>
> for (gLoop = gFirst; gLoop != 0; gLoop = gLoop->gNext)
> {
> input0x = (gLoop->inputs[0] != 0)?gLoop->inputs[0]->posx:-1;
> input0y = (gLoop->inputs[0] != 0)?gLoop->inputs[0]->posy:-1;
> input1x = (gLoop->inputs[1] != 0)?gLoop->inputs[1]->posx:-1;
> input1y = (gLoop->inputs[1] != 0)?gLoop->inputs[1]->posy:-1;
>
> ar << gLoop->posx << gLoop->posy << gLoop->type << input0x <<
> input0y << input1x << input1y;
> count++;
> }
> }
> else
> {
> // TODO: add loading code here
> gate * gNew, * gSearch;
>
> while (1)
> {
> ar >> posx >> posy >> type >> input0x >> input0y >> input1x >>
> input1y;
>
> gNew = find_gate_from_pos(posx, posy);
> if (gNew == 0)
> gNew = create_gate(type, posx, posy);
> else
> gNew->settype(type);
>
> if (input0x != -1 && input0y != -1) {
> gSearch = find_gate_from_pos(input0x, input0y);
> if (gSearch == 0)
> gSearch = create_gate(NOTSET, input0x, input0y);
>
> gNew->inputs[0] = gSearch;
> }
>
> if (input1x != -1 && input1y != -1) {
> gSearch = find_gate_from_pos(input1x, input1y);
> if (gSearch == 0)
> gSearch = create_gate(NOTSET, input1x, input1y);
>
> gNew->inputs[1] = gSearch;
> }
> }
>
> }
> }
> 
0
anyone3666 (139)
4/24/2007 7:25:15 PM
Reply:

Similar Artilces:

How to send form data to tables programatically
Is there a way to programatically have a form update to the underlying tables? What I mean is... As a user types into a form, Access doesn't seem to actually send that data to the table (and thereby create autonumbers) until user moves on to another record. Is there a way to force that data to the tables (ie make the new records) while the user is still on the form? On Sun, 30 Dec 2007 11:33:02 -0800, markmarko <markmarko@discussions.microsoft.com> wrote: >Is there a way to programatically have a form update to the underlying tables? > >What I mean is... As a user ...

Data entry work using msoffice
Is anybody have an idea to get some data entry work in Ms office using word or excel, Ms access etc which can work from home. Please it would be very helpful if you can give a good and reliable website for this With thanks Polachan ...

DATA VALIDATION #64
i have enter all my information in my cells for a drop down list ,but every time i close off the program and restart it the cells have no information in the cells , i then goto the toolbar and the information is still there when i push ok it is available again. should this happen? i thought once you saved it would all stay the same. thanks michael dap ...

Data Migration 07-07-05
We're planning to replace our current CRM (SalesForce) with MS CRM 1.2 in 3 to 4 months. Any good tools out there for migrating data from SF to MS CRM? Hi, You can use the Migration Tool which is found on the installation CD's. But I believe there are third party tools available from Scribe to do this too. -Mark "HEC" wrote: > We're planning to replace our current CRM (SalesForce) with MS CRM 1.2 in 3 > to 4 months. Any good tools out there for migrating data from SF to MS CRM? I did alot data migration . I can develop component for you for this migrat...

Data validation does not seem to work with copy/paste
I have set up some data validation for each cell within a range. When manually enter invalid data in one of those cells, the data validatio works and an error message pops up. When I copy from one cell wit data to another cell, where the data validation results in false, i allows me to paste the value with no error message. Is there any wa to fix this -- LA ----------------------------------------------------------------------- LAF's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=965 View this thread: http://www.excelforum.com/showthread.php?threadid=46802 ...

How can I change the chart so date is up and down and data is acro
I have a chart that has the date across the bottom (category axis) and the data up the side (value axis). I want to change these. Is this possible? Hi, It depends on what chart type you are using. Have a look at Jon Peltier's example for a line chart. http://peltiertech.com/Excel/Charts/Y_CategoryAxis.html Cheers Andy speet wrote: > I have a chart that has the date across the bottom (category axis) and the > data up the side (value axis). I want to change these. Is this possible? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info =?Utf-8?B?c3BlZXQ=?= Wrote: &...

Changing data depending on time?
Hi, everyone: Does anyone know if it is possible to change data in a table according to a date? Let's say I would like to change the contents of all fields that are two days old and I would like to Access to do the work. Can Access actually do the check/change automatically? Thanks a lot, Tom On 5 May 2007 10:30:54 -0700, tomasz.cichon@gmail.com wrote: >Hi, everyone: > >Does anyone know if it is possible to change data in a table according >to a date? >Let's say I would like to change the contents of all fields that are >two days old and I would like to Access ...

Data Validation Question #5
The "Input Message" that can be added to Data Validation, has someho become dissassociated with the cells containing the Data Validation. In normal operation when you select a cell containing DV, the "Inpu Message" appears next to and slighty below the selected cell and the moved as you selected different cells, however on my sheet thos messages appear in a spot well away from the selected cell and don' move when you select a different cell. Is there some way to "re-attach" them to the cells short of removin the DV and putting it back. Thank -- Case -----...

insert text data using function
Hi Guys, I need help on the following matter. Suppose i have two column A and B. Now when i insert some text in the A1 cell i want the data automatically set up in the B1 Cell. Fox example if i type Linux in the A1 cell "Open Source" will be automatically inserted in the B1 cell but if i insert windows "close source" will be inserted autoamtically. I tried with if function but no success. How can i achieve that? Mosaddeq Aziz You need to set up all of your possible data entry values for column A on Sheet2. Then in column B on sheet2, put the values you want aut...

How do I make the x axis data the y axis data? #2
My graph automatically makes certain data the y axis and other data the x axis. I need to just reverse it for the graph I am looking for. Any suggestions? Hi Sarah, you can change the Source data of the chart by right- clicking it. There you can define the columns / rows for the x- and the y-axis. Best Markus >-----Original Message----- >My graph automatically makes certain data the y axis and other data the x >axis. I need to just reverse it for the graph I am looking for. Any >suggestions? >. > ...

Getting Excel Data from One Sheet to Another....
Hey Guys, I have the following Excel problem at work and I am not sure how to solve it. Here is the low down: Excel Sheet #1 Data (First line is the header - [Person and Job]) Person Job --------------------------------------- Fred ? Fred ? Sam ? Kevin ? Kevin ? Julie ? Excel Sheet #2 Data (First line is the Header - [Person and Job]) Person Job --------------------------------------- Fred Mop Boy Julie Hostess Sam Burger Man Kevin Manager Now here is the situation that I have. Based on the how the "Person" Column corresponds to the "Job" Column in Exce...

Query to count between list of number (Predicting Start/End that may occur in data range)
Hi, I have a below list of numbers. 566667 566668 566669 566665 566666 566671 566672 566680 I want a query that would return a count between start and end of range. Like Start End Quantity 566665 566669 5 566671 566672 2 566680 566680 1 Thank you. On 2 apr, 07:17, Angela <ims...@gmail.com> wrote: > Hi, > > I have a below list of numbers. > > 566667 > 566668 > 566669 > 566665 > 566666 > 566671 > 566672 > 566680 > > I want a query that would return a coun...

Using XSLT to transform XML prior to loading into Dataset
I am trying to transfor an XML document prior to loading into a Dataset. My problem stems from the known bug in Visual Studio that prevents loading a well formed XML because of duplicate child names: http://support.microsoft.com/default.aspx?scid=kb;en-us;325696 Anyway, I want to transform the XML using the XSLT to get around this problem, but I am having a tough time coming up with a way to apply the XSLT before loading it into the dataset. Any help and sample code appreciated. Thanks in advance. -Patrick pschouten1701@hotmail.com The XslTransform class has an overload of the Transform m...

Entering data
Please help me enter data into cells that seem to be locked. In article <15a201c43e09$dbea4e10$3501280a@phx.gbl>, "Alicia Contreras" <anonymous@discussions.microsoft.com> wrote: > Please help me enter data into cells that seem to be > locked. Hi Alicia, try: Tools > Protect > Unprotect Hope this helps! ...

2 Column Data lookup
Hi, I have data in column A, B and C starting from row number 2. Also, I have some data in column P and Q starting from row number 2. The data in A and B TOGETHER constitute a Unique ID. Similarly data in P and Q together constitute a Unique ID. Now based on the data in P and Q I want to look up A and B and return value from C in column R. As of now, I use an inefficient way of building up a helper column in D (D2 = A2 & B2) and S (S2 = P2 and Q2). Then in R2 I write the formula, = =INDEX($C$2:$D$1000,MATCH(S2,$D$2:$D$1000,0),1) Is there a better way of accomplishing the above (an ar...

Parse(?) data from text file
I have a large text file that has hundresds (or thousands) of compiled questionairres that I want to convert to a more usable format (excel?). Here is what it looks like: ======================== Name: Joe Jones Address: 123 main comment: varies from blank to 20+ lines may have muliple paragraphs others: 8 or 10 other fields =============================== next questionnaire ====================== A couple of details: the separator line of ====s vary in length, the individual questionnaires are not always identical. Some have a couple of extra 'fields'. I envision a separat...

Sorting Data in a column
I am trying to extract data that is in a single column to split it into 3 columns. The data is cyclic and has 3 variables, a time, a data point and a random number. These simply run abcabcabcabc down the column and i would like to get all of the a's into a column, all of the b's into another column and all of the c's into a third column. any ideas? VBA? Sub Test() Dim iLastRow As Long Dim i As Long iLastRow = Cells(Rows.Count, "A").End(xlUp).Row If iLastRow Mod 3 <> 1 Then iLastRow = iLastRow - 1 If iLastRow Mod 3 <> 1 Then iLastRow = iLa...

Pb with Data validation based on named list
Hello, I create a Name as Test = {"A" , "B"} (not a range but a list of datas) by the menu 'Insert" / "Name" / "define" Then i cant'use that name "Test" in the Data validation Combo box by the menu "Datas" / "Validation" / "Option" / "Autorize" (List) The error message is that system does'nt accept in "Source" = Test Where is the Probleme thanks for your help Gilles PROVOST Hi Gilles You don't need the named range. In Data Validation>List>Source>A,B No need ...

Vertical Gridlines & Data Marker
Firstly, I noticed that a vertical gridlines of the chart are not align with the gridlines of the data tables. I am wondering how it can be aligned. Secondly, I also noticed that a marker is located on the leftside virtical gridlines of X scales. I am also wondering how to place it on the center. Hi Gary, In my version of Excel they are. Try it with a line chart. In Excel 2007 you might have to make an adjustment. We need more info. With a data table the markers are placed between the vertical gridlines, if you don't like that you can remove the data table and then format th...

Using string data to create charts?
For my class project, our group ended up doing surveys. We collecte hundreds of them and then I manually entered the data into an acces database. I exported the database table as an excel worksheet so that I coul make charts. The problem is that all the data is in string format, and excel doesn' seem to want to make charts using that. For example, we have question that is multiple choice and there are 5 answers, each of whic is a different word. What I am trying to get Excel to do is where I select the column tha the different answers are in and have it count up all the same answer ...

Data Validation in Shared Workbook
I set up a shared workbook that included some data validation. Now I need to add an additional valid value but when I go to Tools, Share Workbook, Editing I cannot turn off "Allow changes....) so that I can change the validation. It is OK if I lose the change history up to this point. Any ideas why this option is disabled? Thanks! -- susieqhersh ------------------------------------------------------------------------ susieqhersh's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26887 View this thread: http://www.excelforum.com/showthread.php?threadid=4...

vba code for excel to extract data from txt file
USING Excel 2000. I have a text file that when viewed in excel lists the entire row of data in one cell. I cannot parse data because each line does not have the same break. I want to extract the fields into individual cells. I will need to define "what" I am looking for. Is there sample vba code for excel I can reference to learn how this may be done? sample report REF #:A1B CUSIP:12345678 TD:1/1/00 SYMBOL:ABC QTY: 1 SD:01/03/00 ACME COMPANY PRICE: 9.101 MKT:OTC want to extract REF# TD ...

Data from DialogBox to MainFrame
Hi, I have a CDialogBox class, which collects some information (Cstrings and ints), and stores them in internal variales. I would like to pass that information to the MainFrame class. how can i do that? I'm using Visual Stuido 6.0. SDI. thanks in advance Martin wrote: > Hi, I have a CDialogBox class, which collects some information > (Cstrings and ints), and stores them in internal variales. I would like > to pass that information to the MainFrame class. how can i do that? > I'm using Visual Stuido 6.0. SDI. > thanks in advance > Martin: Is this a modal or mod...

Main Form
Hello, I've been searching through the forums, but haven't found anything yet. Does anyone know of a way to copy data from multiple worksheets (i.e. 30) to one master form? I do NOT want to summarize the data, I want to replicate it exactly, and have a live link so that if the individual sheets are changed, the master will update. All column headings are identical, but there are variable numbers of rows. My only thoughts so far are simply typing =Sheet1!A2 and dragging, repeating for each sheet (or I guess writing a macro to do this). However, if I insert a new r...

IE8 will not load
My IE8 will not load. When I click on the icon, I get a flash but nothing loads. I have tried resetting the IE8 properties in the Internet Options on the Control Panel. I have tried un-installing downloading and re-installing IE8. I have tried to start it via a command line in "No Add-on" mode. All with no joy. I have scanned for Malware, adware, crapware, viruses, trojans, etc...........I have deleted all temp files, what the heck am I missing. Is there somebody out there that can give me some options? Doug.CVD wrote: > My IE8 will not load. When I click on...