Показать сообщение отдельно
Старый 02.04.2012, 15:23   #6
reyn90
Нуждающийся
 
Регистрация: 12.10.2009
Сообщений: 66
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Два цикла - конфликт!

Сообщение от ViNT Посмотреть сообщение
Должно работать. Видимо, ошибка где-то в другом месте.
я так и не нашел ошибку
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.
или не увидел
(Offline)
 
Ответить с цитированием