CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old August 1st, 2005, 05:50 PM
    jipeval jipeval is offline
    Member
     
    Join Date: Apr 2001
    Posts: 26
    jipeval is an unknown quantity at this point (<10)
    Passing String in function issue

    Hello,
    I am new to managed C++ and I am trying to figure out how to pass a String in a function member of a managed object:
    Here is my code:

    private: System::Void menuItem4_Click(System::Object * sender, System::EventArgs * e)
    {
    // INITIATE
    CCG *BCG=new CCG();
    String* STR;
    if( this->openFileDialog1->ShowDialog() == DialogResult::Cancel )
    {
    MessageBox::Show(S"No file loaded.");
    }
    STR=this->openFileDialog1->get_FileName();
    BCG->Read_E(STR,10,400);
    }

    Read_E is defined as follow in .h file:
    public __gc class CCG
    {
    public:
    void Read_E(String *FileName, long lStart, long lDataLenght);
    CCG(void);
    ~CCG(void);

    }
    in my .cpp file:
    void CCG::Read_E(String *strFileName, long lStart, long lDataLenght)
    {......}


    The code debugs fine but the strFilename is out of scope in my CCG::Read_E....

    I spent a lot of time trying to figure this out.. if someone could help me understanding why my strFileName becomes out of scope ...

    unmanaged JP...
    Reply With Quote
      #2    
    Old August 2nd, 2005, 04:10 AM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    Re: Passing String in function issue

    What do you mean with: "It goes out of scope"? It shall not go out of scope... Try to Copy() the string.

    Best Regards,
    Florian
    __________________
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!
    Reply With Quote
      #3    
    Old August 2nd, 2005, 02:29 PM
    jipeval jipeval is offline
    Member
     
    Join Date: Apr 2001
    Posts: 26
    jipeval is an unknown quantity at this point (<10)
    Re: Passing String in function issue

    That was helpful....

    actually the passed string pointer was working fine I could copy the string but somehow I could not see the content of the string in the Watch window... strFileName was refered as out of scope.(which does not make sense)
    ... must be an issue with this feature of the .net studio.
    I wrote another similar function in the same class and it was working fine ...
    still, I do not understand what went wrong on this previous function!
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:33 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009