Don't click here unless you want to be banned.

LSL Wiki : jump

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ec2-204-236-235-245.compute-1.amazonaws.com
jump label

A jump is like a goto in other languages. Jumps can be used to alter normal flow control. When a jump occurs, script execution immediately moves to the next statement after the corresponding label definition, skipping intervening code and breaking out of any loops.

Labels are defined by an arbitrary name, prefixed with an @ (at sign) character.

Example:

list gList;
integer scanForThingys(){
   integer i;
   integer len = llGetListLength(gList);
   for (i = 0; i < len; i++){
      if ( isThingy( llList2String(gList, i) ) )
         jump getOut;
   }
   i = -1;
   @getOut; // when the jump is executed this script leaves the FOR loop and continues from here
   return i;
}

Example: This example shows how the jump label can be used as a loop. I have done some test and this is the fastes loop out of the do-while, while, and the for-loop.

integer i;
@Loop;
if(i > 1000) jump Done;
else
{
    llSetText("Jump\n"+(string)i,<1,1,1>,1);
    i++;
}
jump Loop;
@Done;
llSay(0,"Broke!");
-KageshenKirax
Note: a jump only works within the current scope, a global function, or an event handler. Jumps don't work between global functions or event handlers.

Most coders recommend avoiding jumps where possible and you'll find that they are rarely necessary in well-structured code. LSL lacks a "break" feature that is standard in most languages for leaving a loop early so this is one case where a jump can be useful. Careful coders will avoid jumping backwards or too far forwards in their code.

For more on the subject see: GoTo Statement Considered Harmful.

Note: Please see the comments, you can only have a single jump statement going to a label.


image courtesy of http://xkcd.com/

Flow Control Jasa SEO Jasa SEO Murah Sepatu Online Toko Sepatu Online Sepatu Sepatu Murah Sepatu Safety Sepatu Futsal Cheapes Hostgator Coupon Link Booking Televisori offerte Notebook Offerte Berita Terkini Internet Marketer Muda Internet Marketer Indonesia Portatile Apple RDAnet Lorks Karikatur Bisnis Modal Kecil Bisnis UKM Berita Terbaru Iklan Baris Jasa SEO Jasa SEO Murah SEO Indonesia Konsultan SEO SEO Belajar SEO Kursus SEO Kursus SEO Murah Jam Tangan Casio Jam Tangan Casio Jam Tangan Murah Jam Tangan Grosir Baju Terbaru Grosir Baju Baju Terbaru Grosir Baju Murah Bisnis Online Belajar SEO Kerupuk Kerupuk kulit Social Bookmark Dofollow Social Bookmark Kumpulan Puisi Kirim Puisi bola hantu Penumbuh Rambut Penumbuh Rambut timbangan WBC Wonogiri Jasa SEO Murah Jasa SEO Jam Tangan Murah
There are 8 comments on this page. [Display comments/form]