[JIRA] Commented: (SVC-5214) A second use of a 'For' loop fails within a subroutine.

Strife Onizuka (JIRA) no-reply at lindenlab.cascadeo.com
Fri Jan 1 17:24:59 PST 2010


    [ http://jira.secondlife.com/browse/SVC-5214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=156358#action_156358 ] 

Strife Onizuka commented on SVC-5214:
-------------------------------------

You have a ";" at the end of the for statement before the brackets for the body. Thus the body is disassociated from the loop and executed after the loop has finished it's run.

Here is some corrected code.

{code}
// stop/start Email Sender scripts

set_sender_tasks(integer onoff)
{
    integer j = llGetInventoryNumber(INVENTORY_SCRIPT);
    integer i = 0;
    
    for (; i<j ; i++)             // find name of first email task sender
    {
        string fullname = llGetInventoryName(INVENTORY_SCRIPT, i);
        
        if (llSubStringIndex(llToLower(fullname), task_name) >= 0)
        {
            fullname = llGetSubString(fullname, 0,  -2);
            
            llOwnerSay("Starting setstates "+(string)maxsenders);
            
            // Second 'For' fails immediately
            
            for (i=1; i<=maxsenders; i++)    // set state accordingly for all tasks
            {
                llOwnerSay("(for) setting task "+fullname+(string)i+" "+(string)onoff);
                llSetScriptState(fullname+(string)i, onoff);
            }
            
            i = 0;
            while (i < maxsenders)
            {
                llOwnerSay("(while) setting task "+fullname+(string)i+" "+(string)onoff);
                llSetScriptState(fullname+(string)i, onoff);
                i +=1;
            }
            return;
        }
    }
    llOwnerSay("eMail Err: sender tasks '"+task_name+"' not controllable");
}
{code}

> A second use of a 'For' loop fails within a subroutine.
> -------------------------------------------------------
>
>                 Key: SVC-5214
>                 URL: http://jira.secondlife.com/browse/SVC-5214
>             Project: 2. Second Life Service - SVC
>          Issue Type: Bug
>          Components: Scripts
>    Affects Versions: 1.34 Server
>         Environment: You are at 262826.1, 257821.6, 46.1 in Hawkshead located at sim9179.agni.lindenlab.com (216.82.42.115:13000)
> Second Life Server 1.34.2.142087
>            Reporter: Satori Taringa
>            Priority: Major
>
> The following use of  a 'For' statement in LSL fails within a subroutine.
> The first 'For' will complete, but the second 'For' will terminate 
> immediately with a value of 1 greater than the endding value.
> A comparable 'while' loop, however, will complete successfully.
> It seems as tho the second 'For' statement is initiallizing the start
> value to the endding value before running the loop.
> Since this is in use in many other scripts, this problem may be a side
> effect of the main body of code... which is part of a larger set of component
> for a commercial product I'm creating.
> {code}
> // stop/start Email Sender scripts
> set_sender_tasks(integer onoff)
> {
>     j = llGetInventoryNumber(INVENTORY_SCRIPT);
>             
>     for (i=0; i< ; i++)             // find name of first email task sender
>     {
>         fullname = llGetInventoryName(INVENTORY_SCRIPT, i);
>         
>         if (llSubStringIndex(llToLower(fullname), task_name) >= 0)
>         {
>             fullname = llGetSubString(fullname, 0, (llStringLength(fullname) - 2));
>             jump find_found;
>         }
>     }
>     llOwnerSay("eMail Err: sender tasks '"+task_name+"' not controllable");
>     jump not_found;
>     
>     @find_found;
>     
>     llOwnerSay("Starting setstates "+(string)maxsenders);
>  
> // Second 'For' fails immediately
>     for (i=1; i<=maxsenders; i++);    // set state accordingly for all tasks
>     {
>         llOwnerSay("(for) setting task "+fullname+(string)i+" "+(string)onoff);
>         llSetScriptState(fullname+(string)i, onoff);
>     }
>     
>     i = 0;
>     while (i < maxsenders)
>     {
>         llOwnerSay("(while) setting task "+fullname+(string)i+" "+(string)onoff);
>         llSetScriptState(fullname+(string)i, onoff);
>         i +=1;
>     }
>     
>     @not_found;
> }
> {code}
> [12:48]  Object: Starting setstates 30
> [12:48]  Object: (for) setting task eMail Task Send 1.1 31 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 0 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 1 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 2 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 3 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 4 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 5 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 6 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 7 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 8 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 9 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 10 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 11 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 12 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 13 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 14 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 15 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 16 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 17 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 18 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 19 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 20 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 21 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 22 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 23 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 24 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 25 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 26 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 27 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 28 0
> [12:48]  Object: (while) setting task eMail Task Send 1.1 29 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.secondlife.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the Jira-notify mailing list