×

Discussion Board

Results 1 to 8 of 8

Thread: GoTo statement

  1. #1
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    200

    GoTo statement

    Hello,

    Can I use the 'goto' statement along with labels in Symbian C++, as outlined in the following URL:

    http://library.thinkquest.org/C01115...ual.php?tid=12


    Would appreciatea a prompt respose.


    Best Regards,
    wirefree101

  2. #2
    Super Contributor
    Join Date
    Nov 2005
    Location
    London
    Posts
    584

    Re: GoTo statement

    Yes, you can...just give it a try! Whether you should or not, is addressed in the URL you posted.

  3. #3
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    200

    Re: GoTo statement

    Thx Mr. Stichbury.

    As suggested, I gave it a shot. Following is the precise implementation:

    Code:
    TInt CWrUAppUi::Tick(TAny* aObject)
    {
       goto repeat;
    }
    
    void CWrUAppUi::HandleSessionEventL(...)
    {
    ...
    ...
    repeat:
    ...
    ...
    }

    However, the following error is received:

    Code:
    Error: label 'repeat' used but not defined
    I am assuming the cause of the error to be that the label needs to be present in the same function. How do I implement goto to transfer control to another function in the same class?

    Best,
    wirefree101
    Last edited by wirefree101; 2006-12-29 at 13:06.

  4. #4
    Super Contributor
    Join Date
    Nov 2005
    Location
    London
    Posts
    584

    Re: GoTo statement

    Perhaps by avoiding the use of goto? Why not just call the function? If you need to call only part of the function, you could refactor it into two parts.

  5. #5
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    200

    Re: GoTo statement

    Quote Originally Posted by stichbury
    If you need to call only part of the function, you could refactor it into two parts.
    Appreciate the advise & the inference about my requirement to call only a part of the function.

    Is 'refactor' simply a general term which is synonymous with 'splitting' or does it refer to a methodology by which one can execute only a part of the function?

    Wud appreciate a prompt response.

    Best,
    wirefree101

  6. #6
    Regular Contributor
    Join Date
    May 2005
    Location
    Sweden
    Posts
    272

    Re: GoTo statement

    goto in C and C++ can not jump to other functions.

  7. #7
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    280

    Re: GoTo statement

    Quote Originally Posted by wirefree101
    Appreciate the advise & the inference about my requirement to call only a part of the function.

    Is 'refactor' simply a general term which is synonymous with 'splitting' or does it refer to a methodology by which one can execute only a part of the function?

    Wud appreciate a prompt response.

    Best,
    wirefree101
    'refactor' is simply a general term which is synonymous with 'splitting'.
    You can also pass a boolean to the function and depending on whether the boolean is true or false execute the required parts.

  8. #8
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    155

    Re: GoTo statement

    Wanting to jump into the middle of a function from another function using goto is a very worrying sign indeed and probably indicative of an incorrect or poor design. As Tina suggests a TBool parameter is something to consider, but another thing to consider is to have two separate functions entirely.

Similar Threads

  1. Update SQL statement doesn't work
    By asheeshv in forum Symbian
    Replies: 4
    Last Post: 2008-12-11, 05:41
  2. Voice commands and Goto
    By jmillet in forum General Development Questions
    Replies: 0
    Last Post: 2004-08-30, 17:44
  3. How to perform if statement on database
    By zerglim in forum Symbian
    Replies: 3
    Last Post: 2004-07-03, 05:23
  4. rendering in select statement
    By grimault in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2003-07-04, 04:16
  5. wap links and goto
    By cs8st in forum General Messaging
    Replies: 2
    Last Post: 2002-10-10, 01:50

Posting Permissions

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