Hi, how do I execute the loop by step with a one-button condition using for / next or while
Moderator: Rathinagiri
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Ok Serge. That must be what Jair wants. Or in any case, a very similar thing.
P.S.: I just discovered the use of DO EVENTS.
P.S.: I just discovered the use of DO EVENTS.
I get by with a little help from my friends
- serge_girard
- Posts: 3161
- 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
DO EVENTS is great, but it can interfere with other functions, so be carefull...
Serge
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
What is the scope of the DO EVENTS command?serge_girard wrote: ↑Mon Aug 21, 2017 6:51 am DO EVENTS is great, but it can interfere with other functions, so be carefull...
Serge
In other words, what functions can it affect?
I get by with a little help from my friends
- serge_girard
- Posts: 3161
- 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
All functions CAN affect. See this sample :
Press: Start loop then Pause then Interfere and finally again Pause.
Interfere has closed DBF which is used in JLOOP.
Serge
Code: Select all
#include "hmg.ch"
lPAUSE := .f.
aDBF := {}
AADD(aDBF, { "T1", "C", 8, 0 })
AADD(aDBF, { "T2", "C", 8, 0 })
DBCREATE("TEST", aDBF)
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
@ 120,200 BUTTON START2 ;
CAPTION 'Interfere loop' ;
WIDTH 80 ;
HEIGHT 30 ;
ACTION Interfere();
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
USE TEST
DO WHILE npos != 5
x1:= x1 + 10
y1:= y1 + 15
DO EVENTS
IF lPAUSE
lPAUSE := .F.
npos += 1
APPEND BLANK
REPLACE T1 WITH ALLTRIM(STR(x1))
REPLACE T2 WITH ALLTRIM(STR(y1))
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
//if pos == .T.
// npos += 1
//endif
enddo
FUNCTION Interfere()
/*******************/
x1 := 1
y1 := 2
npos := 0
USE TEST
ZAP
CLOSE ALL
Interfere has closed DBF which is used in JLOOP.
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
Yes, but if you do not press the button "Interfere", they will not close, right?serge_girard wrote: ↑Mon Aug 21, 2017 4:23 pm Press: Start loop then Pause then Interfere and finally again Pause.
Interfere has closed DBF which is used in JLOOP.
Serge
My question is oriented to which events are activated. Only those of the window "mathematica" or others besides?
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
Your example is very close to what I need, but it would be the inverse of what I need not to loop, but to advance once each time I need a button without a loop.serge_girard wrote: ↑Mon Aug 21, 2017 4:23 pm All functions CAN affect. See this sample :
Press: Start loop then Pause then Interfere and finally again Pause.Code: Select all
#include "hmg.ch" lPAUSE := .f. aDBF := {} AADD(aDBF, { "T1", "C", 8, 0 }) AADD(aDBF, { "T2", "C", 8, 0 }) DBCREATE("TEST", aDBF) 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 @ 120,200 BUTTON START2 ; CAPTION 'Interfere loop' ; WIDTH 80 ; HEIGHT 30 ; ACTION Interfere(); 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 USE TEST DO WHILE npos != 5 x1:= x1 + 10 y1:= y1 + 15 DO EVENTS IF lPAUSE lPAUSE := .F. npos += 1 APPEND BLANK REPLACE T1 WITH ALLTRIM(STR(x1)) REPLACE T2 WITH ALLTRIM(STR(y1)) 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 //if pos == .T. // npos += 1 //endif enddo FUNCTION Interfere() /*******************/ x1 := 1 y1 := 2 npos := 0 USE TEST ZAP CLOSE ALL
Interfere has closed DBF which is used in JLOOP.
Serge
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Explique isso em português --[o en español si fuese posible]--.
Mas, no caso, tente não colocar lpause:=.F.
Sempre lpause:=.T. invariavelmente, colocá-lo no início e não mudá-lo.
Veja se isso funciona da maneira que você deseja, ou algo ainda mais parecido.
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
ola Beges, eu preciso fazer um for ou while com loop manual por um botão somente pode avançar quando eu apertar o botão, hoje o for e o while ficam em automático fazendo este loop.
Re: Hi, how do I execute the loop by step with a one-button condition using for / next or while
Ok.
No modo console eu poderia ajudar, mas no modo gráfico não posso... Comecei neste verão e não poderia dedicar muito tempo.
Mas vou explicar de outra maneira e talvez seja assim que nossos amigos podem ajudar.
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 think I know what Jairpinho wants. Here is an example.
Two buttons are required: START and CONTINUE.
The START button is pressed and the loop starts:
----------------------------------
A:=0
WHILE A<9
A +=1
>>> Suspend the process waiting for the CONTINUE button to be pressed <<<
END
---------------------------------
No inner messages. (You might also want to have a CANCEL button).
Two buttons are required: START and CONTINUE.
The START button is pressed and the loop starts:
----------------------------------
A:=0
WHILE A<9
A +=1
>>> Suspend the process waiting for the CONTINUE button to be pressed <<<
END
---------------------------------
No inner messages. (You might also want to have a CANCEL button).
I get by with a little help from my friends