forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   Прочие вопросы (http://forum.boolean.name/forumdisplay.php?f=50)
-   -   Два цикла - конфликт! (http://forum.boolean.name/showthread.php?t=16560)

reyn90 30.03.2012 16:02

Два цикла - конфликт!
 
Создал три кнопки и две из них нужно вывести в меню. Дело в том что использую команды:
Код:

repeat
      delay(100);
    until getClickedCommand = restartCmd;
restart;// это процедура
    repeat
      delay(100);
    until getClickedCommand = exitCmd;
end.

Итак по коду видно что цикл для кнопки выхода не дождётся своей очереди.
Поменять местами циклы

Код:

repeat
      delay(100);
    until getClickedCommand = exitCmd;

repeat
      delay(100);
    until getClickedCommand = restartCmd;
restart;// это процедура
end.

делает невозможным выход. Подскажите пожалуйста может быть есть другой выход?

ViNT 30.03.2012 18:49

Ответ: Два цикла - конфликт!
 
Два цикла тут не нужны, в принципе, я уже про это писал в другой теме
Код:

while true do
begin
 Cmd:=GetClickedCommand;
 if Cmd = CmdExit then halt;
 if Cmd = RestartCmd then Restart;
 Delay(100);
end;


reyn90 30.03.2012 23:38

Ответ: Два цикла - конфликт!
 
Цитата:

Сообщение от ViNT (Сообщение 224129)
Два цикла тут не нужны, в принципе, я уже про это писал в другой теме
Код:

while true do
begin
 Cmd:=GetClickedCommand;
 if Cmd = CmdExit then halt;
 if Cmd = RestartCmd then Restart;
 Delay(100);
end;


процедура невызывается

ViNT 30.03.2012 23:41

Ответ: Два цикла - конфликт!
 
Должно работать. Видимо, ошибка где-то в другом месте.

reyn90 31.03.2012 19:26

Ответ: Два цикла - конфликт!
 
Цитата:

Сообщение от ViNT (Сообщение 224151)
Должно работать. Видимо, ошибка где-то в другом месте.

Ещё денёк помучаюсь и если не найду ошибку выложу полностью код.

reyn90 02.04.2012 15:23

Ответ: Два цикла - конфликт!
 
Цитата:

Сообщение от ViNT (Сообщение 224151)
Должно работать. Видимо, ошибка где-то в другом месте.

я так и не нашел ошибку
Код:

program complex;
var textn1,textn2,textfieldn1,textfieldn2,textfieldn1j,textfieldn2j,operaciya,textotvet,modul,koren,trigo:integer;
    perd1,perd2,perm1,perm2,deystv,mnim,modint1,korintd1,korintm1,modint2,korintd2,korintm2,alfa1,alfa2:real;
    textop:string;
    reshit,cm,rest:command;

procedure restart;
begin
ClearForm;
ShowForm;
textn1:=FormAddString('N1');
textfieldn1:=FormAddTextField('deystvit','0.1',10,TF_ANY);
textfieldn1j:=FormAddTextField('+j','0.1',10,TF_ANY);
textn2:=FormAddString('N2');
textfieldn2:=FormAddTextField('deystvit','0.1',10,TF_ANY);
textfieldn2j:=FormAddTextField('+j','0.1',10,TF_ANY);
operaciya:=FormAddTextField('operaciya','-',10,TF_ANY);

AddCommand(reshit);

repeat
    delay(100);
until GetClickedCommand = reshit;


perd1:=StringToReal(FormGetText(textfieldn1),10);
perm1:=StringToReal(FormGetText(textfieldn1j),10);
perd2:=StringToReal(FormGetText(textfieldn2),10);
perm2:=StringToReal(FormGetText(textfieldn2j),10);
textop:=FormGetText(operaciya);


if textop='+' then
begin
deystv:= perd1 + perd2;
mnim:= perm1 + perm2;
end;

if textop='-' then
begin
deystv:=perd1 - perd2;
mnim:=perm1 - perm2;
end;

if textop='*' then
begin
deystv:=(perd1 * perd2)-(perm1 * perm2);
mnim:=(perd1 * perm2)+(perd2 * perm1);
end;

if textop='/' then
begin
deystv:=((perd1*perd2)+(perm1*perm2))/((perd2*perd2)+(perm2*perm2));
mnim:=((perm1 * perd2)-(perm2 * perd1))/((perd2*perd2)+(perm2*perm2));
end;

if textop='\' then
begin
deystv:=((perd1*perd2)+(perm1*perm2))/((perd2*perd2)+(perm2*perm2));
mnim:=((perm1 * perd2)-(perm2 * perd1))/((perd2*perd2)+(perm2*perm2));
end;

modint1:=sqrt((perd1*perd1)+(perm1*perm1));
korintd1:=sqrt((modint1+perd1)/2);
korintm1:=perm1/sqrt((modint1+perd1)*2);
modint2:=sqrt((perd2*perd2)+(perm2*perm2));
korintd2:=sqrt((modint2+perd2)/2);
korintm2:=perm2/sqrt((modint2+perd2)*2);

textotvet:=FormAddString(''+deystv+'+j'+mnim);
modul:=FormAddString('|N1|='+modint1+'  |N2|='+modint2);
koren:=FormAddString('N1='+korintd1+'+j'+korintm1+'  N2='+korintd2+'+j'+korintm2);

addCommand(cm);
AddCommand(rest);
removeCommand(reshit);



while true do
begin
 if GetClickedCommand = cm then halt;
 if GetClickedCommand = rest then restart;
 Delay(100);
end;




end;

begin
reshit:=CreateCommand('reshit',CM_SCREEN,1);
cm := createCommand('Exit', CM_OK, 2);
rest:=createCommand('Zanovo',CM_SCREEN,3);
ShowForm;



textn1:=FormAddString('N1');
textfieldn1:=FormAddTextField('deystvit','0.1',10,TF_ANY);
textfieldn1j:=FormAddTextField('+j','0.1',10,TF_ANY);
textn2:=FormAddString('N2');
textfieldn2:=FormAddTextField('deystvit','0.1',10,TF_ANY);
textfieldn2j:=FormAddTextField('+j','0.1',10,TF_ANY);
operaciya:=FormAddTextField('operaciya','-',10,TF_ANY);

AddCommand(reshit);

repeat
      //delay(100);
until GetClickedCommand = reshit;
//formRemove(textotvet);

perd1:=StringToReal(FormGetText(textfieldn1),10);
perm1:=StringToReal(FormGetText(textfieldn1j),10);
perd2:=StringToReal(FormGetText(textfieldn2),10);
perm2:=StringToReal(FormGetText(textfieldn2j),10);
textop:=FormGetText(operaciya);


if textop='+' then
begin
deystv:= perd1 + perd2;
mnim:= perm1 + perm2;
end;

if textop='-' then
begin
deystv:=perd1 - perd2;
mnim:=perm1 - perm2;
end;

if textop='*' then
begin
deystv:=(perd1 * perd2)-(perm1 * perm2);
mnim:=(perd1 * perm2)+(perd2 * perm1);
end;

if textop='/' then
begin
deystv:=((perd1*perd2)+(perm1*perm2))/((perd2*perd2)+(perm2*perm2));
mnim:=((perm1 * perd2)-(perm2 * perd1))/((perd2*perd2)+(perm2*perm2));
end;

if textop='\' then
begin
deystv:=((perd1*perd2)+(perm1*perm2))/((perd2*perd2)+(perm2*perm2));
mnim:=((perm1 * perd2)-(perm2 * perd1))/((perd2*perd2)+(perm2*perm2));
end;

modint1:=sqrt((perd1*perd1)+(perm1*perm1));
korintd1:=sqrt((modint1+perd1)/2);
korintm1:=perm1/sqrt((modint1+perd1)*2);
modint2:=sqrt((perd2*perd2)+(perm2*perm2));
korintd2:=sqrt((modint2+perd2)/2);
korintm2:=perm2/sqrt((modint2+perd2)*2);

textotvet:=FormAddString(''+deystv+'+j'+mnim);
modul:=FormAddString('|N1|='+modint1+'  |N2|='+modint2);
koren:=FormAddString('N1='+korintd1+'+j'+korintm1+'  N2='+korintd2+'+j'+korintm2);


alfa1:=toDegrees(atan(perd1/perm1));

{alfa1:=toDegrees(atan(perd1/perm1));
alfa2:=toDegrees(atan(perd2/perm2));}
trigo:=FormAddString('N1='+alfa1+'  N2='+alfa2);

    addCommand(cm);
    AddCommand(rest);
    removeCommand(reshit);

while true do
begin
 if GetClickedCommand = cm then halt;
 if GetClickedCommand = rest then restart;
 Delay(100);
end;

  {  repeat
      delay(100);
    until getClickedCommand = rest;
restart;
    repeat
      delay(100);
    until getClickedCommand = cm;}
end.

или не увидел

Yadro 27.04.2012 23:40

Ответ: Два цикла - конфликт!
 
Разве не так:

PHP код:

repeat
if getClickedCommand exitCmd then halt;
delay(100);
until getClickedCommand restartCmd;
restart;//процедура 



Часовой пояс GMT +4, время: 10:53.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot