Hi, how do I execute the loop by step with a one-button condition using for / next or while
Moderator: Rathinagiri
Hi, how do I execute the loop by step with a one-button condition using for / next or while
Hi how do i advance the search with a button on a loop using for / next or while
DO WHILE npos != 5
x1:= x1+10
y1:= y1+15
mathematica.text_1.value := x1 // tempo decorrente
mathematica.text_2.value := y1 // valor desejado em base de tempo
mathematica.text_3.value := npos // tempo decorrente
if pos == .T.
npos += 1
endif
enddo
DO WHILE npos != 5
x1:= x1+10
y1:= y1+15
mathematica.text_1.value := x1 // tempo decorrente
mathematica.text_2.value := y1 // valor desejado em base de tempo
mathematica.text_3.value := npos // tempo decorrente
if pos == .T.
npos += 1
endif
enddo
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
I tried, but there was no way for the process to stop on a button, I just made it appear and disappear. (I'm a rookie, as you can see ).jairpinho wrote: ↑Tue Aug 15, 2017 1:27 am Hi how do i advance the search with a button on a loop using for / next or while
DO WHILE npos != 5
x1:= x1+10
y1:= y1+15
mathematica.text_1.value := x1 // tempo decorrente
mathematica.text_2.value := y1 // valor desejado em base de tempo
mathematica.text_3.value := npos // tempo decorrente
if pos == .T.
npos += 1
endif
enddo
But an interim solution is this:
Code: Select all
IF ! MSGYESNO(" npos="+STR(npos,1)+" Prosseguir (Sim ou Não) ?")
EXIT
ENDIF
npos +=1
* * * * * * * * * * * * * * * * * *
Lo he intentado, pero no había manera de que el proceso se parase en un boton, solo he conseguido que este apareciese y desapareciese a conveniencia. (Soy novato, como puedes comprobar ).
Pero una solución para salir del paso es esta:
Code: Select all
IF ! MSGYESNO(" npos="+STR(npos,1)+" Continuar ?")
EXIT
ENDIF
npos +=1
I get by with a little help from my friends
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Jair,
In the main:
lSTOP := .f.
+
@ 600,10 BUTTON Start_STOP ;
CAPTION 'Cancel' ;
WIDTH 80 ;
HEIGHT 30 ;
ACTION {lSTOP := .T. } ;
FONT "Arial" SIZE 09 ;
TOOLTIP "Stop searching " ;
FLAT
Before the loop:
lSTOP := .F.
In the loop:
WHILE ..
DO EVENTS
IF lSTOP
EXIT
ENDIF
ENDDO
This I use to stop loops!
Serge
In the main:
lSTOP := .f.
+
@ 600,10 BUTTON Start_STOP ;
CAPTION 'Cancel' ;
WIDTH 80 ;
HEIGHT 30 ;
ACTION {lSTOP := .T. } ;
FONT "Arial" SIZE 09 ;
TOOLTIP "Stop searching " ;
FLAT
Before the loop:
lSTOP := .F.
In the loop:
WHILE ..
DO EVENTS
IF lSTOP
EXIT
ENDIF
ENDDO
This I use to stop loops!
Serge
There's nothing you can do that can't be done...
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Serge, that button interrupts a process, but I think it's not what Jairpinho wants.
It is that in each step (before or after npos += 1) the process stops and ask if you want to continue.
Excuse me both if I am wrong, but I have interpreted it thus, since it makes no sense to stop an accountant of 1 to 5, something impossible even for Lucky Luke.
* * * * * * * * * * * * * * * * *
Serge, ese botón interrumpe un proceso, pero creo que no es lo que quiere Jairpinho.
Se trata de que en cada paso (antes o después de npos +=1) el proceso se detenga y pregunte si se desea continuar.
Disculpadme los dos si me equivoco, pero yo lo he interpretado así, ya que carece de sentido parar un contador de 1 a 5, algo imposible incluso para Lucky Luke.
It is that in each step (before or after npos += 1) the process stops and ask if you want to continue.
Excuse me both if I am wrong, but I have interpreted it thus, since it makes no sense to stop an accountant of 1 to 5, something impossible even for Lucky Luke.
* * * * * * * * * * * * * * * * *
Serge, ese botón interrumpe un proceso, pero creo que no es lo que quiere Jairpinho.
Se trata de que en cada paso (antes o después de npos +=1) el proceso se detenga y pregunte si se desea continuar.
Disculpadme los dos si me equivoco, pero yo lo he interpretado así, ya que carece de sentido parar un contador de 1 a 5, algo imposible incluso para Lucky Luke.
I get by with a little help from my friends
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
@Serge and BeGes
Congrats, you are understand the question.
Regards
Congrats, you are understand the question.
Regards
Viva INTERNATIONAL HMG
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Well, maybe he wants to draw a sloping line in the cartesian plane small step to small step...
Pues a lo mejor quiere dibujar una recta inclinada en el plano cartesiano pasito a pasito...
I get by with a little help from my friends
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
I just meant to say "I do not understand"
BTW
reminded me this:... to draw a sloping line in the cartesian plane small step to small step...
http://www.hmgforum.com/viewtopic.php?f=9&t=2387
Regards.
Viva INTERNATIONAL HMG
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
I was kidding...
I imagine there are more sophisticated tools for drawing.
Jair does not want a line. He wants a button (or two ) inside a WHILE / END loop that always interrupts and allows to continue or cancel.
I imagine there are more sophisticated tools for drawing.
Jair does not want a line. He wants a button (or two ) inside a WHILE / END loop that always interrupts and allows to continue or cancel.
I get by with a little help from my friends
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
I even want a button to interrupt and continue a for or while, thanks to everyone for the tips but they do not answer as I need
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Jair,
It is difficult to understand/see exactly what you want. May be this?
Serge
It is difficult to understand/see exactly what you want. May be this?
Code: Select all
#include "hmg.ch"
lPAUSE := .f.
DEFINE WINDOW mathematica ;
AT 0,0 ;
WIDTH 750 ;
HEIGHT 800 ;
ICON "" ;
TITLE 'mathematica ' ;
NOMAXIMIZE ;
NOSIZE ;
BACKCOLOR WHITE ;
MAIN
ON KEY ESCAPE ACTION { mathematica.Release }
@ 10,10 LABEL text_1 ;
VALUE " " ;
WIDTH 500 ;
HEIGHT 20 ;
BACKCOLOR GREEN;
FONT 'Arial' SIZE 9 ;
@ 40,10 LABEL text_2 ;
VALUE " " ;
WIDTH 500 ;
HEIGHT 20 ;
BACKCOLOR YELLOW;
FONT 'Arial' SIZE 9 ;
@ 70,10 LABEL text_3 ;
VALUE " " ;
WIDTH 500 ;
HEIGHT 20 ;
BACKCOLOR ORANGE;
FONT 'Arial' SIZE 9 ;
@ 120,10 BUTTON START ;
CAPTION 'Start loop' ;
WIDTH 80 ;
HEIGHT 30 ;
ACTION JLOOP();
FONT "Arial" SIZE 09 ;
TOOLTIP "Start " ;
FLAT
@ 160,10 BUTTON PAUSE ;
CAPTION 'Pause' ;
WIDTH 80 ;
HEIGHT 30 ;
ACTION {lPAUSE := .T. } ;
FONT "Arial" SIZE 09 ;
TOOLTIP "Pause " ;
FLAT
END WINDOW
CENTER WINDOW mathematica
ACTIVATE WINDOW mathematica
FUNCTION JLOOP()
/**************/
lPAUSE := .F.
x1 := 1
y1 := 2
npos := 0
DO WHILE npos != 5
x1:= x1 + 10
y1:= y1 + 15
DO EVENTS
IF lPAUSE
lPAUSE := .F.
npos += 1
MSGINFO('PAUSE')
ENDIF
mathematica.text_1.value := x1 // tempo decorrente
mathematica.text_2.value := y1 // valor desejado em base de tempo
mathematica.text_3.value := npos // tempo decorrente
enddo
There's nothing you can do that can't be done...