How to Break or Continue in loop?
Moderators: Murderator+, Murderator
How to Break or Continue in loop?
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
Especially in for loop,I have tried many statements from other language,but failed.
someone can tell me?thanks
Re: How to Break or Continue in loop?
What kind of loop you mean? Program "loop" or script? If the script then show me what it was.
Re: How to Break or Continue in loop?
как много иностранцев...
Re: How to Break or Continue in loop?
Русские видимо все уже разобрались с инжектом и просто не задают тут вопросов
Мая пичатаит чирез гугляпиреводчик
Жаль иностранцев не всегда интуитивно понятно, так, как русского. Вот человек спросит про loop - то ли про какой то скрипт, то ли про цикл в принципе, то ли про программу для UO. Отвечать на ВСЕ варианты ломает. Задаст правильно вопрос - получит правильный ответ.

Мая пичатаит чирез гугляпиреводчик

Жаль иностранцев не всегда интуитивно понятно, так, как русского. Вот человек спросит про loop - то ли про какой то скрипт, то ли про цикл в принципе, то ли про программу для UO. Отвечать на ВСЕ варианты ломает. Задаст правильно вопрос - получит правильный ответ.
Re: How to Break or Continue in loop?
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?
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?

Re: How to Break or Continue in loop?
чё это он хочет конь такой
Re: How to Break or Continue in loop?


Which board should i get in?

Re: How to Break or Continue in loop?
ZeroDX wrote:чё это он хочет конь такой
А ну я так сперва и подумал - он хочет в скрипте поставить паузу а потом продолжить работу

2 roro4ever You can use goto
bad idea but will work
You can use a second variable
Code: Select all
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: Select all
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
Re: How to Break or Continue in loop?
Mirage wrote:ZeroDX wrote:чё это он хочет конь такой
А ну я так сперва и подумал - он хочет в скрипте поставить паузу а потом продолжить работуПросто н езнает языка инжекта (бейсика бугага) и по этому не может реализовать.
А чего ты за него то додумываешь? он такого не спрашивал... он спрашивал что-то вроде
i = 9, вот цикл и кончился, либо return
Re: How to Break or Continue in loop?
Он так по дурацки вопрос задал, что я до сих пор не понял, что он хочет. Из оформления примера скрипта, вообще никаких выводов сделать невозможно.
Re: How to Break or Continue in loop?
У него просто обычные слова вперемешку с командами и без разделения
Потому и приходится ломать голову.

Re: How to Break or Continue in loop?
The FOR loop need some special treatment for a correct use.
Let me give you an example:
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:
2 - Can't use break, how can I stop my loop. Solution (only use varlastloop if you need to store the value):
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)
Let me give you an example:
Code: Select all
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: Select all
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: Select all
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)
-
- Posts: 820
- Joined: 2011-06-11 19:54:23
Re: How to Break or Continue in loop?
Английский не так знаю, чтоб ответить ему адекватно, но думаю, он поймёт мою задумку)
По мне так актуальная реализация continue и break с сохранением всех параметров:
По мне так актуальная реализация continue и break с сохранением всех параметров:
Code: Select all
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
Re: How to Break or Continue in loop?
if i==4 then #break
uo.print('break using')
goto lb_break
endif
uo.print(str(i))
next
lb_break:
тебя за это сожгут. Хотя как вариант

-
- Posts: 820
- Joined: 2011-06-11 19:54:23
Re: How to Break or Continue in loop?
Почему же?)
Сколько уже использую сие творение, ничо не вылезало не хорошего))
Сколько уже использую сие творение, ничо не вылезало не хорошего))
Re: How to Break or Continue in loop?
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
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!
for those who not understand the meaning of breaking a loop, let me show you an example
Code: Select all
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!