Yoko

All sides of Injection
It is currently 2024-03-28 16:54:03

All times are UTC+02:00




Post new topic  Reply to topic  [ 16 posts ] 
Author Message
PostPosted: 2011-08-11 04:20:32 
Offline

Joined: 2009-10-16 16:57:23
Posts: 8
How to Break or Continue in loop?

Especially in for loop,I have tried many statements from other language,but failed.

someone can tell me?thanks


Top
   
PostPosted: 2011-08-11 08:36:49 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
What kind of loop you mean? Program "loop" or script? If the script then show me what it was.

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2011-08-11 10:40:24 
Offline
User avatar

Joined: 2006-12-08 10:51:50
Posts: 718
Location: Москва
как много иностранцев...


Top
   
PostPosted: 2011-08-11 11:44:18 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
Русские видимо все уже разобрались с инжектом и просто не задают тут вопросов :)
Мая пичатаит чирез гугляпиреводчик :roll:
Жаль иностранцев не всегда интуитивно понятно, так, как русского. Вот человек спросит про loop - то ли про какой то скрипт, то ли про цикл в принципе, то ли про программу для UO. Отвечать на ВСЕ варианты ломает. Задаст правильно вопрос - получит правильный ответ.

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2011-08-11 17:54:22 
Offline

Joined: 2009-10-16 16:57:23
Posts: 8
code example:

for i=0 to 9
if i==2 then
#break
endif
if i==5 then
#continue
endif
next

cos i dont know the break and continue statements in injection language.so now i use

repeat
until (Exitcondition)

but continue how to implement? use if? :cry:


Top
   
PostPosted: 2011-08-11 23:02:17 
Offline
User avatar

Joined: 2006-12-08 10:51:50
Posts: 718
Location: Москва
чё это он хочет конь такой


Top
   
PostPosted: 2011-08-12 02:36:32 
Offline

Joined: 2009-10-16 16:57:23
Posts: 8
:shock: ,sorry,I just translated the russian text above. :lol:
Which board should i get in? :?:


Top
   
PostPosted: 2011-08-12 08:45:12 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
ZeroDX wrote:
чё это он хочет конь такой

А ну я так сперва и подумал - он хочет в скрипте поставить паузу а потом продолжить работу :) Просто н езнает языка инжекта (бейсика бугага) и по этому не может реализовать.



2 roro4ever You can use goto
bad idea but will work


You can use a second variable
Code:
for i=0 to 9
if i==2 then
j==1
endif
if j=1 then
wait(5000)
j=0
endif
next


OR
You can use an external function

Code:
if uo.getglobal('Pause')=='On' then
   repeat
      wait (500)
   until uo.getglobal('Pause')=='Off'
endif
sub PauseOn()
   uo.setglobal('Pause','On')
endsub
sub PauseOff()
   uo.setglobal('Pause','Off')
   uo.print('Пауза выключена!')
endsub

best option in my opinion

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2011-09-01 15:45:17 
Offline

Joined: 2007-07-07 13:14:01
Posts: 90
Mirage wrote:
ZeroDX wrote:
чё это он хочет конь такой

А ну я так сперва и подумал - он хочет в скрипте поставить паузу а потом продолжить работу :) Просто н езнает языка инжекта (бейсика бугага) и по этому не может реализовать.

А чего ты за него то додумываешь? он такого не спрашивал... он спрашивал что-то вроде
i = 9, вот цикл и кончился, либо return


Top
   
PostPosted: 2011-09-01 18:03:28 
Offline

Joined: 2007-07-07 13:14:01
Posts: 90
Он так по дурацки вопрос задал, что я до сих пор не понял, что он хочет. Из оформления примера скрипта, вообще никаких выводов сделать невозможно.


Top
   
PostPosted: 2011-09-02 00:26:13 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
У него просто обычные слова вперемешку с командами и без разделения :) Потому и приходится ломать голову.

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2012-09-11 14:11:59 
Offline

Joined: 2012-09-10 20:18:54
Posts: 14
The FOR loop need some special treatment for a correct use.
Let me give you an example:

Code:
For varloop=var1 to var2
    blablabla
Next


In this example we have a flexible loop that goes from whatever var1 is adding 1 until its the same value of var2

And there goes our problems:

1 - If var1 is greater than var2 the loop will fail and will keep running until you crash. Solution:

Code:
If var1<var2 Then
    For varloop=var1 to var2
        blablabla
    Next
End If


2 - Can't use break, how can I stop my loop. Solution (only use varlastloop if you need to store the value):

Code:
If var1<var2 Then
    For varloop=var1 to var2
        blablabla
        If breakcondition Then
            varlastloop=varloop
            varloop=var2
        End If
    Next
End If


Notice that if you set varloop to something greater than var2 you will be back at problem 1

Therefore... use For only when you are sure that you will use all the looping tries/values. For other uses I recomend While (for a pre-checking condition loop) and Repeat Until (for a post-checking condition loop)


Top
   
PostPosted: 2012-09-11 23:08:10 
Offline

Joined: 2011-06-11 19:54:23
Posts: 820
Английский не так знаю, чтоб ответить ему адекватно, но думаю, он поймёт мою задумку)
По мне так актуальная реализация continue и break с сохранением всех параметров:
Code:
sub autostart()
   var i
   uo.print('start cycle')
   for i=0 to 6
      lb_continue:
      if i==2 then #continue
         i=i+1
         uo.print('continue using')
         goto lb_continue
      endif
      if i==4 then #break
         uo.print('break using')
         goto lb_break
      endif
      uo.print(str(i))
   next
   lb_break:
   uo.print('exit from cycle')
end sub


Top
   
PostPosted: 2012-09-12 10:24:16 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
Quote:
if i==4 then #break
uo.print('break using')
goto lb_break
endif
uo.print(str(i))
next
lb_break:


тебя за это сожгут. Хотя как вариант :)

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2012-09-12 10:50:11 
Offline

Joined: 2011-06-11 19:54:23
Posts: 820
Почему же?)
Сколько уже использую сие творение, ничо не вылезало не хорошего))


Top
   
PostPosted: 2017-10-05 15:46:18 
Offline

Joined: 2017-10-05 15:25:15
Posts: 2
So.... its possible or not to Break or Continue a While loop?

for those who not understand the meaning of breaking a loop, let me show you an example

Code:
SUB Test()
   WHILE NOT UO.Dead()
         IF UO.STR > UO.Life THEN
      # Special Conditiion, if this match i simple want to skip everything that is below "ENDIF"
      use bandage function....
      # Here the command we are looking for
      CONTINUE
         ENDIF
         
         # Code to be executed when above if is not match...
         ....         
         Wait(3000)
   WEND
ENDSUB


The reason to use this is to prevent the use off thousands of NESTED IF ELSE statements!
Result in a way more clean script code.

Thank you!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 16 posts ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 4 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited