CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 40
  1. #16
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by souldog
    I think the point of Mick's post is it is very unlikely that the CString
    is really 2.1G so something else must be going on.
    And here I thought that was obvious

  2. #17
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234
    How do you create your string??
    You may try:
    Code:
    CString str( _T('A'), INT_MAX-1 );
    Good luck!
    However:
    2,147,352,576 == unreserved virtual memory (accessible by a process (NT)).
    2,147,483,646 == INT_MAX - 1

    Also I think, we are on a wrong path.
    wangnanjing, would you, please, clarify your problem?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #18
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    Originally posted by irona20
    How do you create your string??

    If it is something like this:
    CString str = "very huge string";

    you can do the following:
    CString str = "string shorter";
    str += "the rest of the string";
    I don't know how that would help if the length is really exceeded.

    In fact this seems interesting. Consider this code for CString

    PHP Code:
    // NOTE: "operator+" is done as friend functions for simplicity
    //      There are three variants:
    //          CString + CString
    // and for ? = TCHAR, LPCTSTR
    //          CString + ?
    //          ? + CString

    void CString::ConcatCopy(int nSrc1LenLPCTSTR lpszSrc1Data,
        
    int nSrc2LenLPCTSTR lpszSrc2Data)
    {
      
    // -- master concatenation routine
      // Concatenate two sources
      // -- assume that 'this' is a new CString object

        
    int nNewLen nSrc1Len nSrc2Len;
        if (
    nNewLen != 0)
        {
            
    AllocBuffer(nNewLen);
            
    memcpy(m_pchDatalpszSrc1DatanSrc1Len*sizeof(TCHAR));
            
    memcpy(m_pchData+nSrc1LenlpszSrc2DatanSrc2Len*sizeof(TCHAR));
        }
    }

    CString AFXAPI operator+(const CStringstring1, const CStringstring2)
    {
        
    CString s;
        
    s.ConcatCopy(string1.GetData()->nDataLengthstring1.m_pchData,
            
    string2.GetData()->nDataLengthstring2.m_pchData);
        return 
    s;

    So what happens if the sum of the lengths exceeds the size of int?
    here
    PHP Code:
        int nNewLen nSrc1Len nSrc2Len;
        if (
    nNewLen != 0)
        {
            
    AllocBuffer(nNewLen); 
    Am I seeing things
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  4. #19
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by souldog
    I don't know how that would help if the length is really exceeded.

    In fact this seems interesting. Consider this code for CString

    PHP Code:
    // NOTE: "operator+" is done as friend functions for simplicity
    //      There are three variants:
    //          CString + CString
    // and for ? = TCHAR, LPCTSTR
    //          CString + ?
    //          ? + CString

    void CString::ConcatCopy(int nSrc1LenLPCTSTR lpszSrc1Data,
        
    int nSrc2LenLPCTSTR lpszSrc2Data)
    {
      
    // -- master concatenation routine
      // Concatenate two sources
      // -- assume that 'this' is a new CString object

        
    int nNewLen nSrc1Len nSrc2Len;
        if (
    nNewLen != 0)
        {
            
    AllocBuffer(nNewLen);
            
    memcpy(m_pchDatalpszSrc1DatanSrc1Len*sizeof(TCHAR));
            
    memcpy(m_pchData+nSrc1LenlpszSrc2DatanSrc2Len*sizeof(TCHAR));
        }
    }

    CString AFXAPI operator+(const CStringstring1, const CStringstring2)
    {
        
    CString s;
        
    s.ConcatCopy(string1.GetData()->nDataLengthstring1.m_pchData,
            
    string2.GetData()->nDataLengthstring2.m_pchData);
        return 
    s;

    So what happens if the sum of the lengths exceeds the size of int?
    here
    PHP Code:
        int nNewLen nSrc1Len nSrc2Len;
        if (
    nNewLen != 0)
        {
            
    AllocBuffer(nNewLen); 
    Am I seeing things
    Speculation I'd like to see what is going on first....

    thank you very little

  5. #20
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123
    Well, I don't think that the SQL statment are so huge.
    I had this problem once:

    Code:
    CString strAux = "SELECT DISTINCT \
        GenInfInforme.sINFO_CODIGO, \
        GenInfInformeDetalles.sIDET_VISTA, \
        GenInfInformeDetalles.sIDET_CONSULTA, \
        GenInfInformeDetalles.sIDET_USUARIO, \
        GenInfArbolesCF.sGIAR_ARBOL, \
        GenInfArbolesCF.nGIAR_COMPORT, \
    	GenInfArbolesCF.nGIAR_TIPOEJE, \
        GenInfArbolesCF.nGIAR_PROFUN, \
        GenInfArbolesCF.sGIAR_NODO, \
        MasterTreesStructure.NodeCode, \
        MasterTrees.TreeNumberOfLevels,\
    	MasterTreesStructure.NodeLevel, \
    	MasterTreesStructure.NodeTreeOrder \
    FROM GenInfInforme INNER JOIN \
        GenInfInformeDetalles ON \
        (GenInfInformeDetalles.sINFO_CODIGO = GenInfInforme.sINFO_CODIGO) \
    	INNER JOIN Users ON (Users.UsuarioID = GenInfInforme.sINFO_USUARIO)\
    	INNER JOIN \
        GenInfArbolesCF ON \
        (GenInfInformeDetalles.sIDET_VISTA = GenInfArbolesCF.sGIAR_VISTA \
         AND \
        GenInfInformeDetalles.sIDET_CONSULTA = GenInfArbolesCF.sGIAR_CONSULTA \
         AND \
        GenInfInformeDetalles.sIDET_USUARIO = GenInfArbolesCF.sGIAR_USUARIO \
         AND \
        GenInfInformeDetalles.sINFO_CODIGO = GenInfArbolesCF.sGIAR_CODIGO) \
         INNER JOIN \
        MasterTrees ON \
        (GenInfArbolesCF.sGIAR_ARBOL = MasterTrees.TreeMasterCode) \
         INNER JOIN \
        MasterTreesStructure ON \
        (GenInfArbolesCF.sGIAR_ARBOL = MasterTreesStructure.TreeMasterCode) ";
    
    	strAux += "WHERE ((GenInfInforme.bINFO_PRIVADO = 0 AND Users.GrupoID = '%s') OR \
        GenInfInforme.sINFO_USUARIO = '%s') AND \
         ((GenInfArbolesCF.nGIAR_TIPOEJE = 2) OR \
        ((GenInfArbolesCF.nGIAR_TIPOEJE < 2) AND \
        ((MasterTrees.TreeNumberOfLevels - 1) \
        > MasterTreesStructure.NodeLevel))) AND \
        ((GenInfArbolesCF.nGIAR_COMPORT = 0) OR \
        ((GenInfArbolesCF.nGIAR_COMPORT > 0) AND \
        ((MasterTrees.TreeNumberOfLevels - MasterTreesStructure.NodeLevel \
         - 1) >= GenInfArbolesCF.nGIAR_PROFUN))) \
    ORDER BY GenInfInforme.sINFO_CODIGO, \
        GenInfInformeDetalles.sIDET_VISTA, \
        GenInfInformeDetalles.sIDET_CONSULTA, \
        GenInfInformeDetalles.sIDET_USUARIO, \
        GenInfArbolesCF.sGIAR_ARBOL, \
    	MasterTreesStructure.NodeLevel, \
        MasterTreesStructure.NodeTreeOrder";
    I have to split my string because I get an error in runtime. So, maybe it is the same error.
    I am Miss Maiden... Miss Iron Maiden :-D

  6. #21
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    Originally posted by Mick_2002
    Speculation I'd like to see what is going on first....

    thank you very little
    I didn't mean that to be related to this guys problem. I mean is that a bug in CString
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  7. #22
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by irona20
    Well, I don't think that the SQL statment are so huge.
    I had this problem once:

    Code:
    CString strAux = "SELECT DISTINCT \
        GenInfInforme.sINFO_CODIGO, \
        GenInfInformeDetalles.sIDET_VISTA, \
        GenInfInformeDetalles.sIDET_CONSULTA, \
        GenInfInformeDetalles.sIDET_USUARIO, \
        GenInfArbolesCF.sGIAR_ARBOL, \
        GenInfArbolesCF.nGIAR_COMPORT, \
    	GenInfArbolesCF.nGIAR_TIPOEJE, \
        GenInfArbolesCF.nGIAR_PROFUN, \
        GenInfArbolesCF.sGIAR_NODO, \
        MasterTreesStructure.NodeCode, \
        MasterTrees.TreeNumberOfLevels,\
    	MasterTreesStructure.NodeLevel, \
    	MasterTreesStructure.NodeTreeOrder \
    FROM GenInfInforme INNER JOIN \
        GenInfInformeDetalles ON \
        (GenInfInformeDetalles.sINFO_CODIGO = GenInfInforme.sINFO_CODIGO) \
    	INNER JOIN Users ON (Users.UsuarioID = GenInfInforme.sINFO_USUARIO)\
    	INNER JOIN \
        GenInfArbolesCF ON \
        (GenInfInformeDetalles.sIDET_VISTA = GenInfArbolesCF.sGIAR_VISTA \
         AND \
        GenInfInformeDetalles.sIDET_CONSULTA = GenInfArbolesCF.sGIAR_CONSULTA \
         AND \
        GenInfInformeDetalles.sIDET_USUARIO = GenInfArbolesCF.sGIAR_USUARIO \
         AND \
        GenInfInformeDetalles.sINFO_CODIGO = GenInfArbolesCF.sGIAR_CODIGO) \
         INNER JOIN \
        MasterTrees ON \
        (GenInfArbolesCF.sGIAR_ARBOL = MasterTrees.TreeMasterCode) \
         INNER JOIN \
        MasterTreesStructure ON \
        (GenInfArbolesCF.sGIAR_ARBOL = MasterTreesStructure.TreeMasterCode) ";
    
    	strAux += "WHERE ((GenInfInforme.bINFO_PRIVADO = 0 AND Users.GrupoID = '%s') OR \
        GenInfInforme.sINFO_USUARIO = '%s') AND \
         ((GenInfArbolesCF.nGIAR_TIPOEJE = 2) OR \
        ((GenInfArbolesCF.nGIAR_TIPOEJE < 2) AND \
        ((MasterTrees.TreeNumberOfLevels - 1) \
        > MasterTreesStructure.NodeLevel))) AND \
        ((GenInfArbolesCF.nGIAR_COMPORT = 0) OR \
        ((GenInfArbolesCF.nGIAR_COMPORT > 0) AND \
        ((MasterTrees.TreeNumberOfLevels - MasterTreesStructure.NodeLevel \
         - 1) >= GenInfArbolesCF.nGIAR_PROFUN))) \
    ORDER BY GenInfInforme.sINFO_CODIGO, \
        GenInfInformeDetalles.sIDET_VISTA, \
        GenInfInformeDetalles.sIDET_CONSULTA, \
        GenInfInformeDetalles.sIDET_USUARIO, \
        GenInfArbolesCF.sGIAR_ARBOL, \
    	MasterTreesStructure.NodeLevel, \
        MasterTreesStructure.NodeTreeOrder";
    I have to split my string because I get an error in runtime. So, maybe it is the same error.
    What was the runtime error? The char looks proper to me

  8. #23
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by souldog
    I didn't mean that to be related to this guys problem. I mean is that a bug in CString
    I didn't look...should I look? Given the number of bugs in MFC I do not doubt it

  9. #24
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123
    Originally posted by Mick_2002
    What was the runtime error? The char looks proper to me
    I don't renember, it was three years ago I only renember I had to split my string.
    I am Miss Maiden... Miss Iron Maiden :-D

  10. #25
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234
    For wangnanjing
    If your problem is really an SQL statement, something like "SELECT blabla,... FROM...",
    If you can zip and attach it here, then there is no problem. For sure, somebody will help you.

    I have a supposition. Somehow your "SQL" is a long binary field in a recordset,
    and you had some problems trying to put it in a CString ???
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  11. #26
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by irona20
    I don't renember, it was three years ago I only renember I had to split my string.
    Heh it's ok Irona...given the number of responses, it will be three years before the original poster responds

  12. #27
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234
    Originally posted by Mick_2002
    I didn't look...should I look? Given the number of bugs in MFC I do not doubt it
    Do you know any software stuff without bugs?
    Yes? That means it does nothing.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  13. #28
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by ovidiucucu
    Do you know any software stuff without bugs?
    Yes? That means it does nothing.
    Yep...it's called any code I write...what you never heard of FVT or UNIT testing...wow imagine that....

    EDIT: does it piss me off to no end that you have that attitude? yes it does.

  14. #29
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234
    Originally posted by Mick_2002
    Yep...it's called any code I write...what you never heard of FVT or UNIT testing...wow imagine that....
    Sorry man, you must throw it away!
    Or it's insufficient tested, or nobody use it except you.
    Keep in mind: nothing is perfect.
    Originally posted by Mick_2002
    EDIT: does it piss me off to no end that you have that attitude? yes it does.
    I hope no offense, Just
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  15. #30
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by ovidiucucu
    Sorry man, you must throw it away!
    Or it's insufficient tested, or nobody use it except you.
    Keep in mind: nothing is perfect.
    Wow...geez, I've never coded for the big boys Why don't you try your attitude when coding for medical devices? Hmm? Maybe your NIBP isn't what your NIBP is? hmm? Maybe somebody makes a descision based on your cardiac calcs? Maybe then your dead

    I hope no offense, Just
    Stupidity is no offense, it's called darwinism

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured