serialization question #2

Hello,
I have such question. I want to create SDI application to work with matix. I
have a data that stored in the file in the form of the matrix:
1 2 3 4
5 6 7 8
9 0 1 2
or something like this one. The nambers of colonms and rows may vary. How
can I read this file (serialize) and store each number in CArray for
example?

Thank you very much in advance

Igor


0
itarasov (3)
8/20/2004 8:12:09 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
576 Views

Similar Articles

[PageSpeed] 55

igor tarasov wrote:

> Hello,
> I have such question. I want to create SDI application to work with matix. I
> have a data that stored in the file in the form of the matrix:
> 1 2 3 4
> 5 6 7 8
> 9 0 1 2
> or something like this one. The nambers of colonms and rows may vary. How
> can I read this file (serialize) and store each number in CArray for
> example?
> 
> Thank you very much in advance
> 
> Igor
> 
> 

One way is when storing the matrix, first serialize the two dimensions, 
then all the values in sequence.  When reading the file, first 
deserialize the two dimensions, then all the values.

If you have the data in CArrays, you could also first serialize the 
number of CArrays, then serialize each one.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
8/20/2004 10:24:33 PM
"igor tarasov" <itarasov@eng.usf.edu> wrote in message
news:unWJ8HvhEHA.2764@TK2MSFTNGP11.phx.gbl...
> Hello,
> I have such question. I want to create SDI application to work with matix.
I
> have a data that stored in the file in the form of the matrix:
> 1 2 3 4
> 5 6 7 8
> 9 0 1 2
> or something like this one. The nambers of colonms and rows may vary. How
> can I read this file (serialize) and store each number in CArray for
> example?
>
> Thank you very much in advance
>
> Igor
>
>

you could try something like this:

CMatrix : public CObject
{
    UINT m_nRows;
    UINT m_nColumns;
    unsigned int **m_nElements;
    CMatrix();
    ~CMatrix();
    CMatrix(UINT nRows, UINT nColumns);
}

CMatrix::CMatrix(UINT nRows, UINT nColumns)
{
    m_nRows = nRows;
    m_nColumns = nColumns;

    m_nElements = new unsigned int *[m_nRows];

    for (UINT nIndex = 0; nIndex != m_nRows; nIndex++)
    {
        m_nElements[index] = new unsigned int[m_nColumns];
    }

    // other stuff you want to add
}

CMatrix::Serialize(CArchive &ar)
{
    CObject::Serialize(ar);
    if (ar.IsStoring())
    {
            ar << m_nRows;
            ar << m_nColumns;

            for (UINT rIndex = 0; rIndex != m_nRows; rIndex++)
            {
                for ( UINT cIndex = 0; cIndex != m_nColumns; cIndex++)
                {
                        ar << m_nElements[rIndex][cIndex];
                }
            }
       }
        else
        {
            ar >> m_nRows;
            ar >> m_nColumns;
            m_nElements = new unsigned int *[m_nRows];

            for (UINT nIndex = 0; nIndex != m_nRows; nIndex++)
            {
                    m_nElements[index] = new unsigned int[m_nColumns];
            }

             for (UINT rIndex = 0; rIndex != m_nRows; rIndex++)
            {
                for ( UINT cIndex = 0; cIndex != m_nColumns; cIndex++)
                {
                        ar >> m_nElements[rIndex][cIndex];
                }
            }
        }
}


Now with respect to using this contraction of code:
Feel free  to add member functions to the CMatrix like
SetElementAt, GetElementAt and so on
you could store each object created from CMatrix into
a CObArray, which will allow you to manipulate its elements as you
please.

I hope it will help you to get started, after all this is just a suggestion;


0
PRG9798 (12)
8/21/2004 12:34:59 AM
Reply:

Similar Artilces:

Option Button question
I can't remember how to group option buttons...I don't mean like grouping them as in their appearance (Draw/Group) I mean I have 2 sets of option buttons. I want the first set of 2 to perform like option buttons and that is if one is checked, the other gets unchecked. However I would like the 2nd set to perform in that same manner, but independent of the first set. In this way the user can select one option from the 1st set and one option from the 2nd set. I recall there was a way to specifiy that but now I don't remember how to do it. Thanks, Tracey --- Message posted from h...

Office v.X & Upgrade Question
I currently use Office v.X and VPC w/2000 on my G4 466, and I would like = to=20 know the easiest & least expensive way to ugrade to On 10/3/04 10:30 AM, in article 375701c4a8e8$863202c0$a601280a@phx.gbl, "Eric E." <anonymous@discussions.microsoft.com> wrote: > I currently use Office v.X and VPC w/2000 on my G4 466, and I would like to > know the easiest & least expensive way to ugrade to Office 2004? Buy the upgrade. That's about as cheap as it's going to get. Gene van Troyer ------------------------------------------- | Office 2004 | OSX.3.4 | PBG4 ...

AfterUpdate Question!
I want to add this to my code , Ony enter date if [DateCheck] (checkbox) is -1 Any help would be great..............Thanks Bob Private Sub tbAdditionCharge_AfterUpdate() If tbDayNo.value = "" Or IsNull(tbDayNo.value) Then tbDayNo.value = Format(Now, "dd-mmm-yy") End If End Sub Hi Bob, Me.tbDayNo=IIf(Me.DateCheck And IsNull(tbDayNo), _ Format(Date,"dd/mm/yy"),tbDayNo) Regards Jacob "Bob V" <rjvance@ihug.co.nz> wrote in message news:%23xApdzD7HHA.4880@TK2MSFTNGP03.phx.gbl... | | I want to add this to my code , Ony enter date if [D...

2 email downloaded by exchange server moved to public folder
Hi, I am having the following difficulties with Exchange 2003 that I could use some help on. I am running a small office system, it consists of 1 Small Business Server 2003, and 5 clients (all win xp ). I have 2 email accounts and would like to have the exchange server retreive the emails and move them to 2 different public folder depending on the email address. I did the following: configure the 2 pop3 connectors to get that mail, as user mailbox, mailbox of the account administrator on server. Now, trought Owa, on the server, i can see the received mails. Owa 's rules haven't...

countif ??? #2
Thanks - But not really wot I'm after ... I'm trying to populate source data for a graph and i need values for each number of days for each month eg how many times 1 to 10 appear when the month is Jan etc -- GazMo ------------------------------------------------------------------------ GazMo's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=14610 View this thread: http://www.excelforum.com/showthread.php?threadid=270803 Then using a pivot table / pivot chart should be what you need. A pivo table of the data you posted comes out like the one below C...

Serial Number Problem
Hi Everyone, we run Dynamics on our server anyway we had HUGE problems and lost a lot of work.....anyway after fixing lots up i still have one MAJOR problem. Serial numbers for items in the system do exist if you look up inventory ~ Serials. There is a list of serial numbers in stock ready to use. But when we go to do an invoice there are no serial numbers, it asks you if you want to overide the quantities... Our problem was we lost our inventory file therefore we had to put an old file back on...although these serial numbers are there we can not use them which also means i cant put t...

Black List Question for Micro Exchange
I was blacklisted because my 2003 Exchange server does not receive emails to the IP address. Specifically the abuse@xxx.xx.xx.xxx (where the x's are the IP address of the domain). I now need to reset the Reverse DNS so that it resolves emails to the IP address of the domain as well as the exchange email address and then resolve the emails to a users email address. Where do I start to solve this? I found out how to resolve the emails to a specific user, now how do I reconfigure the Reverse DNS to accept the emails to the IP address of the Domain? Help Please, this is beginning ...

grouping question...
I want to be able to find total labor hours per resource type, grouped by a custom charge#(text1 field) that I assign manually to each task created (see example shown below)… I realize that I can find the grouped resources hours by using “Resource Usage” but note that I can not group them by the charge#(text1 field)… If I use the Task Usage view, I see that I can group by the charge# but then can not group by the resource type…. Is this simply because the charge# field is not shared by the same tables? What am I missing or not understanding… Example: Charge# 1-1-1 Co...

Duplicate Element Names in Serialized XML
Hi All, Hoping someone can solve a problem for me. I am modifying the schema for a rather complex web service written in VB.NET. The services uses a large number of serialized classes to output the overall XML. The problem I am having is that I require 2 XML elements of the same name to be serialized from the 1 class. Due to the way the web service is written only 1 of these would be ever be called at a time. However, it seems that I get an exception if the same element name is used twice in one class.. any ideas? For example: 'start class here <XMLElement ("elementName&q...

Email newsletters #2
I want to create a one page email newsletter (with hyperlinks) using publisher then be able to send it out to a list of 200+ addresses via Gmail (Group mail) so I can personalise each message. I do not want to use it as a Pdf attachment. Please advise how this can b done. I have tried with no success. Thanks -- S Reeve Kent. UK How to save your publication as a Web Archive in Publisher and share it in e-mail http://support.microsoft.com/kb/312157/en-us -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "S Reeve" <SRee...

DDX contol type question
Greatly appreciate anyone showing me what I'm missing here. My ViewClass holds my resource editor ListBox and is the parent class. DerivedClass (from CListBox base class) holds my owner draw DrawItem function. I don't really yet understand everything about this but I wrote my first OwnerDraw derived CListBox class for the DrawItem Function to change the text in my VC studio resource editor created ListBox. Well the code compiled with no errors but in my debugger I noticed that this one UINT in my DrawItem function, going in was already initialized with a value that it shoul...

Question re: popup investment list
My popup investments list now contains many old items that I would like to remove. I cannot find any way of doing this. Suggestions would be greatly appreciated. Albert In microsoft.public.money, Albert wrote: >My popup investments list now contains many old items that I would >like to remove. I cannot find any way of doing this. Suggestions >would be greatly appreciated. Go to the details of the investment that you do not hold, and blank the symbol. Then "delete" the investment. If you cannot delete the investment, delete the transactions in the Investment Activit...

Outlook 2007 Connection takes 2 minute
We have user (remote office where we have Instagate VPN Router so user is connected using VPN connection) on Dell Laptop Latitutde E6500 with Windows XP SP3 OS and MS office 2007 with latest update. When he opens his outlook 2007 it takes 2 mintues (sometime 3 minutes) to connect to Exchange Server while other users in his office have no problem they are connected in 30 seconds. I googled it but could not find right solution. Thanks, ...

Question for the bitmap experts....
I'm trying to read bitmap data that's stored in my program's resource script. Once I have a "handle" on my bitmap resouce, I need to store it in the following data structure : typedef struct _AUX_RGBImageRec { GLint sizeX, sizeY; // Bitmap dimensions here unsigned char* data; // Bitmap data here??? } AUX_RGBImageRec; I plan on using the LoadResource() and FindResource() APIs to extract the bitmap data from the resource script. Once I get the bitmap dimensions, I can easily place that information in the "s...

A question about MFC dll.
Hi all. I have a MFC extention DLL and I compile it in static link libraries mode. When I use this dll in MFC application which is compiled in shared mode the application failed with this DLL(in static link mode is OK). How can I solve this problem? Please help me. Thanks and best regard. Unless things have changed, MFC extension DLLs must be dynamically linked. Why are you statically linking it? -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Binh Nguyen Van" <binhnv@newcenturysoft.com> wrote in message news:#bh6X1X4EHA.3472@TK2MSFTNGP09.phx.gbl... > Hi all. > &...

Control disable/enable question
I'm trying to enable/disable a command button, based on a check box(table field), on a continuous form. This form is a one-liner with only 6 items. The weird thing is, if say 8 records(line items) are shown, changing the check box on any one of the line items causes all other line's buttons to respond, not just that particular line I'm editing. The code I've tried is: Private Sub Testbutton_AfterUpdate() If Me.chkBox = True Then Me.cmdButton.Enabled = True Else: Me.cmdButton.Enabled = False End Sub I've used this in a single forms successfully, but not continu...

Publisher 2003 graphics #2
I am working in Publisher 2003 with Windows XP. I cannot get my version of Publisher to show any graphics, boxes, pictures etc. Only text is shown. What am I going wrong? Stozza wrote: > I am working in Publisher 2003 with Windows XP. > I cannot get my version of Publisher to show any graphics, boxes, > pictures etc. Only text is shown. What am I going wrong? Doesn't anyone *GOOGLE* anymore?! View > Pictures. -- In memory of MS MVP Alex Nichol: http://www.dts-l.org/ Stozza <Stozza@discussions.microsoft.com> was very recently heard to utter: > I am working...

Array functions #2
Thought I was getting the hand of array functions. Clearly not.... Can I use an array function with a set of discontiguous cells, for example (A1,A3,A5,A7,A9) rather than A1:A10? If not can someone suggest away of finding the average value of a set of discontiguous cells, some of which may have numbers, others may have an error code. (Not sure if this is relevent but I have specified any error code to be #N/A to ensure that I can still use the data set for a line chart, and not return a zero value for a cell with errors)? Is there a way without using an array function? Yes you can, is...

Web Severices: CreatePayablesInvoice question
I am trying to use the GP web services to create a payables invoice using predetermined distrubition accounts. When I create the AP Invoice with the GetPolicyByOperation("CreatePayablesInvoice", context) and I use the debug in my VS 2005, I see that the Distributions property has an array of zero elements. How can I add my behavior information to that array? This is the code (C#) I have so far and I think it is correct but I cannot find anywhere in the GP documentation how to actuall put my desired behavior into that array of behaviors. apPolicy = wsDynamicsGP.GetPolic...

value inputs..another formual question
Well I'm full of questions today...I'm really starting to understan Excel and I'm enjoying working with it. I'm making a sheet that will keep track of someone that is running tab with us. I'm inputting how much is owed on each specfic day, an the value's are added up and outputted in a "grand total" cell..... Now what happens when this person pays on the account, is there any wa I can input how much he pays which will be subtractred from the gran total, without destroying any information of past money spend (i wan to be able to keep a grand total, average ...

Serial Motor
How do you control a motor via serial port? What language should I use? Justin Case wrote: > How do you control a motor via serial port? What language should I > use? I don't know, but it certainly isn't possible with SQL Server ... http://lmgtfy.com/?q=How+do+you+control+a+motor+via+serial+port -- HTH, Bob Barrows Bob Barrows (reb01501@NOyahoo.SPAMcom) writes: > I don't know, but it certainly isn't possible with SQL Server ... What? You can't control a motor with an engine? -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se...

edit control vertical alignment question
Howdy my friends, Can your provide me some codes to center the text in an edit control? I can't seem to find any article that provides a robust way to do this. Any help is appreciated. Thanks much. DW Try this link http://www.codeguru.com/Cpp/V-S/devstudio_macros/windowmanagement/article.php/c8491/ I have updated it and it should be reposted shortly. "eewee" wrote: > Howdy my friends, > > Can your provide me some codes to center the text in an edit control? I > can't seem to find any article that provides a robust way to do this. > > Any ...

Basic INSERT question
I have a form with three fields - textbox1, textbox2, textbox3. Each textbox will have text or a number in it. what code will INSERT textbox1 into new record in Table1 field1, then INSERT textbox2 into new record Table1 field1, and so on? Is it a Loop or Array, I'm confused. On Fri, 5 Mar 2010 12:26:17 -0800, gator <gator@discussions.microsoft.com> wrote: >I have a form with three fields - textbox1, textbox2, textbox3. Each textbox >will have text or a number in it. what code will INSERT textbox1 into new >record in Table1 field1, then INSERT textbox2 in...

serial port communuication
Hi all, I m communicating to a printer device through serial port.It is failing to open the port,but when I disable and enable the com port in device manager,it works fine(i.e)it communicates with the printer and reads the configuration settings of the printer). Regards Hari are u leaving the port opened when ur program terminates ........ what is the frequency of u disabling/enabling port ....... after every run ...... some times works some times not ..... ????? "hari" <haricibi83@gmail.com> wrote in message news:1171455246.402743.203120@k78g2000cwa.googlegrou...

Serialization of jagged Arrays Issue
Hi there, I m trying to return an object (of my own written class) from a web service that contains jagged Arrays as public variables. Asp.Net is showing me the its serialized version on the browser when i invoke the service during test. Code: public class returnType { [System.Xml.Serialization.XmlElementAttribute("chassisdata")] public _chassisdata[] chassisdata; [XmlArray(),XmlArrayItem("wheel", typeof(_wheel[]),IsNullable=false)] public _wheel[][] upsteps; [XmlArray(),XmlArrayItem("wheelsize", typeof(_wheelsize[]),IsNullable=false)] publi...