Results 1 to 14 of 14

Thread: Need help with GoTo labels!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82

    Need help with GoTo labels!

    I was just wondering if there was a way to return back to where i left off after going to a label. ex-

    if Blah=True then Goto LABEL_BLAH

    LABEL_BLAH:
    do some stuff
    Return to line right after the if/then statement
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  2. #2
    Zaei
    Guest
    Use a function, or Subroutine. There is now ay to go back to where you started from using GoTo.

    Z.

  3. #3
    Zaei
    Guest
    And you should NEVER use gotos anyway.

    Z.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    thnx for the help.

    I was just wondering since the goto is already in a function and i thought it seemed kinda odd to make a seperate function or sub just for my 3 or 4 lines of code, but OK.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Posts
    424

    Re: Need help with GoTo labels!

    Originally posted by Killerguppy101
    I was just wondering if there was a way to return back to where i left off after going to a label. ex-

    if Blah=True then Goto LABEL_BLAH

    LABEL_BLAH:
    do some stuff
    Return to line right after the if/then statement
    Can you not just use an On Blah Goto Whatever Resume Next like you do with errors?

    Code:
    on error goto exiterror resume next
         do whatever
    
    exiterror:
         do whatever

  6. #6
    Zaei
    Guest
    Dont have errors in your program =).

    Z.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Zaei, theres difference between exception handling and errors in the program as in bugs.

    Killerguppy101, this is probably what you are looking for, Gosubs are lighter than function calls, but they are messy, so be cautious.
    Code:
        Dim a
       
        GoSub 20
        MsgBox a
        
        Exit Sub
    20:
        a = 10
        Return
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Zaei
    Guest
    I know, but its no excuse =).

    Z.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You could try
    VB Code:
    1. If Blah=True Then Goto LABEL_BLAH
    2. LABEL_BLAH:
    3. 'do some stuff
    4. Resume Next
    5. End If
    Although, with the exception of On Error GoTo, I would agree with Zaei, and never use GoTos.

  10. #10
    Hyperactive Member
    Join Date
    Mar 2002
    Posts
    424
    Actually I wasn't talking about errors. I just wondered whether exception handling could be used for anything else besides errors.

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    In C++ or Java you can use exception handling for almost anything that has to do with selectional execution (many people do, and many people also argue against it) but many times exception handling has nothing to do with errors at all.

    Goto is not nessesary evil, its just lowlevel, and vb programmers shouldn't be accustomed to such, they should be planting pictureboxes and handling events
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Yeah that's one of the things that I don't agree about VB.NET, they basically removed all the low-level stuff that we used to optimize our programs
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  13. #13
    Zaei
    Guest
    You can do some odd things with SEH:
    Code:
    int func(int x) {
      _try { // I think its one underscore, though it may be two...
        return x;
      }
      _finally { // again, I think its one, but it may be two...
         x+=1;
      }
    }
    
    ...
    
    x = func(2)
    Guess what x is. Its 3, because the _finally block is executed before x is returned.

    Z.

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    two underscores
    well, you have to see this one, because at first sight it looks like spaghetti code
    Code:
    #include "stdio.h"
    
    void main()
    {
       int* p = 0x00000000;   // pointer to NULL
       puts("hello");
       __try{
          puts("in try");
          __try{
             puts("in try");
             *p = 13;    // causes an access violation exception;
          }__finally{
             puts("in finally");
          }
       }__except(puts("in filter"), 1){
          puts("in except");
       }
       puts("world");
    }
    hello
    in try
    in try
    in filter
    in finally
    in except
    world
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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