TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

#break and #continue

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
LokiChaos



Joined: 27 Oct 2009
Posts: 61

PostPosted: Wed May 04, 2016 1:09 am    Post subject: #break and #continue Reply with quote

I noticed some odd behaviour with #break and #continue with #forall loops… they do nothing.

#break and #continue do however work with #foreach, #while, #loop, and #parse

Code:

[02] forall {$t} {#echo {'&0'};#if {&0 > 5} {#break;};#echo {"&0"};}
[02] echo {'1'}
'1'
[10] if {1 > 5}
[05] endif
[02] echo {"1"}
"1"
[02] echo {'2'}
'2'
[10] if {2 > 5}
[05] endif
[02] echo {"2"}
"2"
[02] echo {'3'}
'3'
[10] if {3 > 5}
[05] endif
[02] echo {"3"}
"3"
[02] echo {'4'}
'4'
[10] if {4 > 5}
[05] endif
[02] echo {"4"}
"4"
[02] echo {'5'}
'5'
[10] if {5 > 5}
[05] endif
[02] echo {"5"}
"5"
[02] echo {'6'}
'6'
[10] if {6 > 5}
[00]     break
[05] endif
[02] echo {"6"}
"6"
[02] echo {'7'}
'7'
[10] if {7 > 5}
[00]     break
[05] endif
[02] echo {"7"}
"7"
[02] echo {'8'}
'8'
[10] if {8 > 5}
[00]     break
[05] endif
[02] echo {"8"}
"8"
[02] echo {'9'}
'9'
[10] if {9 > 5}
[00]     break
[05] endif
[02] echo {"9"}
"9"
[02] echo {'10'}
'10'
[10] if {10 > 5}
[00]     break
[05] endif
[02] echo {"10"}
"10"
[02] forall {$t} {#echo {'&0'};#if {&0 > 5} {#continue;};#echo {"&0"};}
[02] echo {'1'}
'1'
[10] if {1 > 5}
[05] endif
[02] echo {"1"}
"1"
[02] echo {'2'}
'2'
[10] if {2 > 5}
[05] endif
[02] echo {"2"}
"2"
[02] echo {'3'}
'3'
[10] if {3 > 5}
[05] endif
[02] echo {"3"}
"3"
[02] echo {'4'}
'4'
[10] if {4 > 5}
[05] endif
[02] echo {"4"}
"4"
[02] echo {'5'}
'5'
[10] if {5 > 5}
[05] endif
[02] echo {"5"}
"5"
[02] echo {'6'}
'6'
[10] if {6 > 5}
[03]     continue
[05] endif
[02] echo {"6"}
"6"
[02] echo {'7'}
'7'
[10] if {7 > 5}
[03]     continue
[05] endif
[02] echo {"7"}
"7"
[02] echo {'8'}
'8'
[10] if {8 > 5}
[03]     continue
[05] endif
[02] echo {"8"}
"8"
[02] echo {'9'}
'9'
[10] if {9 > 5}
[03]     continue
[05] endif
[02] echo {"9"}
"9"
[02] echo {'10'}
'10'
[10] if {10 > 5}
[03]     continue
[05] endif
[02] echo {"10"}
"10"


I know #forall is somewhat depreciated, so this probably goes mostly unnoticed.
Back to top
View user's profile Send private message
LokiChaos



Joined: 27 Oct 2009
Posts: 61

PostPosted: Wed May 04, 2016 1:13 am    Post subject: Reply with quote

If you want to test:
Code:

#var t {{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}}

#alias {forall} {
   #forall {$t} {
      #echo {'&0'};
      #if {&0 > 5} {
         #break;
      };
      #echo {"&0"};
   };

   #forall {$t} {
      #echo {'&0'};
      #if {&0 > 5} {
         #continue;
      };
      #echo {"&0"};
   };
}

#alias {foreach} {
   #foreach {$t} {i} {
      #echo {'$i'};
      #if {$i > 5} {
         #break;
      };
      #echo {"$i"};
   };
   #foreach {$t} {i} {
      #echo {'$i'};
      #if {$i > 5} {
         #continue;
      };
      #echo {"$i"};
   };
}

#alias {while} {
   #var i 0;
   #while {$i < 10} {
      #math i {$i + 1};
      #echo {'$i'};
      #if {$i > 5} {
         #break;
      };
      #echo {"$i"};
   };
   #var i 0;
   #while {$i < 10} {
      #math i {$i + 1};
      #echo {'$i'};
      #if {$i > 5} {
         #continue;
      };
      #echo {"$i"};
   };
};

#alias {loop} {
   #loop {1} {10} {i} {
      #echo {'$i'};
      #if {$i > 5} {
         #break;
      };
      #echo {"$i"};
   };
   #loop {1} {10} {i} {
      #echo {'$i'};
      #if {$i > 5} {
         #continue;
      };
      #echo {"$i"};
   };
}

#alias {parse} {
   #parse {123456789} {i} {
      #echo {'$i'};
      #if {$i > 5} {
         #break;
      };
      #echo {"$i"};
   };
   #parse {123456789} {i} {
      #echo {'$i'};
      #if {$i > 5} {
         #continue;
      };
      #echo {"$i"};
   };
}



Each alias should output:
Code:

'1'
"1"
'2'
"2"
'3'
"3"
'4'
"4"
'5'
"5"
'6'
'1'
"1"
'2'
"2"
'3'
"3"
'4'
"4"
'5'
"5"
'6'
'7'
'8'
'9'
'10'
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Thu May 05, 2016 10:20 am    Post subject: Reply with quote

Maybe it's not a case if #forall is not mentioned in the help

Code:

Command: #break

         The break command can be used inside the #FOREACH, #LOOP, #PARSE,
         #WHILE and #SWITCH statements. When #BREAK is found, tintin will stop
         executing the statement it is currently in and move on to the next.

Example: #while {1} {#math cnt $cnt + 1;#if {$cnt == 20} {#break}}
Back to top
View user's profile Send private message
LokiChaos



Joined: 27 Oct 2009
Posts: 61

PostPosted: Thu May 05, 2016 3:15 pm    Post subject: Reply with quote

Fair enough, just another quirk to #forall then.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group