Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Паскаль, Turbo Pascal, PascalABC.NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Закрытая тема
Ваша тема закрыта, почему это могло произойти? Возможно,
Нет наработок или кода, если нужно готовое решение - создайте тему в разделе Фриланс и оплатите работу.
Название темы включает слова - "Помогите", "Нужна помощь", "Срочно", "Пожалуйста".
Название темы слишком короткое или не отражает сути вашего вопроса.
Тема исчерпала себя, помните, один вопрос - одна тема
Прочитайте правила и заново правильно создайте тему.
 
Опции темы Поиск в этой теме
Старый 10.12.2010, 02:10   #1
Leshiy1
Форумчанин
 
Аватар для Leshiy1
 
Регистрация: 24.09.2009
Сообщений: 104
По умолчанию Cannot_T

Cannot run a unit
в чем дело
Leshiy1 вне форума
Старый 10.12.2010, 02:19   #2
alex_fcsm
Участник клуба
 
Аватар для alex_fcsm
 
Регистрация: 10.11.2008
Сообщений: 1,502
По умолчанию

модуль надо компилировать(compile)
Нормальное состояние техники - нерабочее, все остальное частный случай.
alex_fcsm вне форума
Старый 10.12.2010, 02:28   #3
Leshiy1
Форумчанин
 
Аватар для Leshiy1
 
Регистрация: 24.09.2009
Сообщений: 104
По умолчанию

Вот что не так
Код:
  Unit    SQUnit;
                                 INTERFACE
Const
      kv=4;
      speed=1.5;
      one=pi/180;
      step=one*speed;
      ms=2000;

Type  TPoint = Object
                x,y:Real;
                Pcolor:Byte;
                Constructor Init( xx,yy:Real; col:Byte);
                Procedure   Rotate (xOs,yOs :Integer ); Virtual;
                Procedure   Show   (col:Byte ); Virtual;
                Destructor  Done;
           End;

TLine  = Object ( TPoint )
                pn, pk:TPoint;
                Lcolor:Byte;
                Constructor Init (x1,y1,x2,y2:Real;  col:Byte );
                Procedure   Rotate (xOs,yOs:Integer ); Virtual;
                Procedure   Show (col:Byte); Virtual;
                Destructor  Done;
End;

TSides=Array[0..kv-1] Of TLine;
TSquare = Object ( TLine )
               as:Byte;
               Sides:TSides;
               Scolor:Byte;
               Constructor Init(aa,colK:Byte);
               Procedure   Rotate (xOs,yOs:Integer); Virtual;
               Procedure   Show   ( col:Byte );         Virtual;
               Destructor  Done;
End;

TScreen = Object(TSquare)
               Gdisp:Integer;
               Gcolor:Byte;
               angle :Real;
               OsX,OsY :Integer;

Constructor Init (aa, colK, colG:Byte;  dG:Integer);
               Procedure   GraphInit; Virtual;
               Function    ShiftOsXY :Boolean; Virtual;
               Procedure   Go; Virtual;
               Procedure   DrawGround; Virtual;
               Destructor  Done;
End;

                          IMPLEMENTATION
Uses Graph, Crt;

Constructor TPoint .Init(xx, yy:Real; col:Byte);
Begin x:=xx; y:=yy; Pcolor:=col; End;

Procedure TPoint.Rotate (xOs,yOs :Integer);
Var xx, yy:Real;
Begin  xx:= (x - xOs)*Cos(step)-(y - yOs)*Sin(step)+xOs;
       yy:= (x - xOs)*Sin (step)+(y - yOs)*Cos(step)+yOs;
       x :=xx; y:=yy;
End;

Procedure   TPoint.Show   (col :Byte);
Begin  PutPixel (Round(x), Round(y), Pcolor ); End;

Destructor  TPoint.Done;
Begin End;


Constructor Tline.Init(x1,y1,x2,y2:Real; col:Byte);
Begin pn.Init(x1,y1,col);   pk.Init(x2,y2,col);   Lcolor:=col;  End;

Procedure   TLine.Rotate (xOs,yOs :Integer);
Begin pn.Rotate(xOs,yOs);   pk.Rotate(xOs,yOs); End;

Procedure   TLine .Show (col :Byte);
Begin  If col=0 Then SetColor (col) Else SetColor (Lcolor) ;
       Line(Round(pn.x),Round(pn.y),Round(pk.x),Round(pk.y));
End;

Destructor  TLine.Done;
Begin End;


Constructor TSquare.Init (aa, colK :Byte);
Begin
  as:=aa;
  Sides[0].Init (as, as, 0, as, colK);
  Sides[1].Init (0, as,  0,  0, colK);
  Sides[2]. Init(0,  0, as,  0, colK);
  Sides[3]. Init (as,  0, as, as, colK);
  Scolor:=colK;
End;

Procedure TSquare.Rotate (xOs, yOs :Integer);

Var i:Byte;                                                                                    {вокруг оси }
Begin For i:=0 To kv-1 Do Sides[i].Rotate (xOs,yOs); End;

Procedure TSquare.Show(col :Byte);
Var  i:Byte;
Begin  For i:= 0 To kv-1 Do  Sides[i].Show(col); End;

Destructor  TSquare.Done;
Begin End;


Constructor TScreen.Init(aa, colK, colG :Byte; dG :Integer);
Var  i :Byte;
Begin
   GraphInit;
   Inherited Init (aa, colK);
   Gdisp:=dG;
   For i:=0 To kv-1 Do  With Sides[i] Do Begin
     pn.y:=pn.y+Gdisp-as;
     pk.y:=pk.y+Gdisp-as;
   End;
   Gcolor:=colG;
   OsX:=as;    OsY:=Gdisp;
   angle:=0;
   DrawGround;
End;

Procedure TScreen.GraphInit;
Var gd, gm, ErrorCode:Integer;
Begin
   If  GetGraphMode=2  Then  Exit;
   gd:=Detect;
  InitGraph(gd, gm, '');
  ErrorCode:=GraphResult;
  If ErrorCode <> grOk Then Begin
     Writeln('rty', GraphErrorMsg (ErrorCode));
     Halt(1);
  End;
End;

Procedure  TScreen.DrawGround;
Begin SetColor (Gcolor);
      Line (0, Round(Gdisp + 1), GetMaxX, Round(Gdisp + 1));
End;

Function  TScreen.ShiftOsXY :Boolean;

Begin  If angle>pi/2
         Then Begin OsX:=OsX+as;
                          ShiftOsXY := True; End
         Else ShiftOsXY:=False;
End;

Procedure TScreen.Go;
Begin
 Repeat
   Repeat
     angle:=angle+step;
     If ShiftOsXY
       Then Begin angle:=0; Continue; End;
     Rotate (OsX, OsY);
     Show(Scolor);
     Delay(ms);
     Show(0);
     If KeyPressed Then Exit;
   Until OsX>GetMaxX;
   Init (as, Scolor, Gcolor, Gdisp);
   DrawGround;
 Until False;
End;

Destructor TScreen .Done;
Begin  CloseGraph;   End;
End.
Uses SqUnit;
Const   sizeSq=80;
            colorSq=12;
            colorG=2;
            deltaG=400;

Var Driver,Mode:integer;
    Screen:TScreen;

Begin
   Driver:=Detect;
   InitGraph(Driver,Mode,'D:\ProgramFiles\Pascal7\Units');
   Screen.Init (sizeSq, colorSq, colorG, deltaG);
   Screen.DrawGround;
   Screen.Go;
   Screen.Done;
   Readln;
   CloseGraph;
End.
Leshiy1 вне форума
Старый 10.12.2010, 02:31   #4
alex_fcsm
Участник клуба
 
Аватар для alex_fcsm
 
Регистрация: 10.11.2008
Сообщений: 1,502
По умолчанию

Модуль вынесите в отдельный файл
Нормальное состояние техники - нерабочее, все остальное частный случай.
alex_fcsm вне форума
Старый 10.12.2010, 08:43   #5
Serge_Bliznykov
Старожил
 
Регистрация: 09.01.2008
Сообщений: 26,229
По умолчанию

Leshiy1, а что Вы собственно хотели получить?!

у Вас описан МОДУЛЬ (читай БИБЛИОТЕКА),
её нужно подключить к Вашей ПРОГРАММЕ
и там использовать объекты (и их методы), описанные в вашей библиотеке.

Саму по себе библиотеку запустить НЕЛЬЗЯ!

p.s. подсказка - модули начинаются с ключевого слова Unit
программа - с ключевого слова Program
Serge_Bliznykov вне форума
Старый 11.12.2010, 01:38   #6
Leshiy1
Форумчанин
 
Аватар для Leshiy1
 
Регистрация: 24.09.2009
Сообщений: 104
По умолчанию

Код:
                                Unit    SQUnit;
                                 INTERFACE
Const
      kv=4;
      speed=1.5;
      one=pi/180;
      step=one*speed;
      ms=2000;

Type  TPoint = Object
                x,y:Real;
                Pcolor:Byte;
                Constructor Init( xx,yy:Real; col:Byte);
                Procedure   Rotate (xOs,yOs :Integer ); Virtual;
                Procedure   Show   (col:Byte ); Virtual;
                Destructor  Done;
           End;

TLine  = Object ( TPoint )
                pn, pk:TPoint;
                Lcolor:Byte;
                Constructor Init (x1,y1,x2,y2:Real;  col:Byte );
                Procedure   Rotate (xOs,yOs:Integer ); Virtual;
                Procedure   Show (col:Byte); Virtual;
                Destructor  Done;
End;

TSides=Array[0..kv-1] Of TLine;
TSquare = Object ( TLine )
               as:Byte;
               Sides:TSides;
               Scolor:Byte;
               Constructor Init(aa,colK:Byte);
               Procedure   Rotate (xOs,yOs:Integer); Virtual;
               Procedure   Show   ( col:Byte );         Virtual;
               Destructor  Done;
End;

TScreen = Object(TSquare)
               Gdisp:Integer;
               Gcolor:Byte;
               angle :Real;
               OsX,OsY :Integer;

Constructor Init (aa, colK, colG:Byte;  dG:Integer);
               Procedure   GraphInit; Virtual;
               Function    ShiftOsXY :Boolean; Virtual;
               Procedure   Go; Virtual;
               Procedure   DrawGround; Virtual;
               Destructor  Done;
End;

                          IMPLEMENTATION


Uses Graph, Crt;
Constructor TPoint.Init(xx, yy:Real; col:Byte);
Begin x:=xx; y:=yy; Pcolor:=col; End;

Procedure TPoint.Rotate (xOs,yOs :Integer);
Var xx, yy:Real;
Begin  xx:= (x - xOs)*Cos(step)-(y - yOs)*Sin(step)+xOs;
       yy:= (x - xOs)*Sin (step)+(y - yOs)*Cos(step)+yOs;
       x :=xx; y:=yy;
End;

Procedure   TPoint.Show   (col :Byte);
Begin  PutPixel (Round(x), Round(y), Pcolor ); End;

Destructor  TPoint.Done;
Begin End;


Constructor Tline.Init(x1,y1,x2,y2:Real; col:Byte);
Begin pn.Init(x1,y1,col);   pk.Init(x2,y2,col);   Lcolor:=col;  End;

Procedure   TLine.Rotate (xOs,yOs :Integer);
Begin pn.Rotate(xOs,yOs);   pk.Rotate(xOs,yOs); End;

Procedure   TLine .Show (col :Byte);
Begin  If col=0 Then SetColor (col) Else SetColor (Lcolor) ;
       Line(Round(pn.x),Round(pn.y),Round(pk.x),Round(pk.y));
End;

Destructor  TLine.Done;
Begin End;


Constructor TSquare.Init (aa, colK :Byte);
Begin
  as:=aa;
  Sides[0].Init (as, as, 0, as, colK);
  Sides[1].Init (0, as,  0,  0, colK);
  Sides[2]. Init(0,  0, as,  0, colK);
  Sides[3]. Init (as,  0, as, as, colK);
  Scolor:=colK;
End;

Procedure TSquare.Rotate (xOs, yOs :Integer);

Var i:Byte;                                                                                    {вокруг оси }
Begin For i:=0 To kv-1 Do Sides[i].Rotate (xOs,yOs); End;

Procedure TSquare.Show(col :Byte);
Var  i:Byte;
Begin  For i:= 0 To kv-1 Do  Sides[i].Show(col); End;

Destructor  TSquare.Done;
Begin End;


Constructor TScreen.Init(aa, colK, colG :Byte; dG :Integer);
Var  i :Byte;
Begin
   GraphInit;
   Inherited Init (aa, colK);
   Gdisp:=dG;
   For i:=0 To kv-1 Do  With Sides[i] Do Begin
     pn.y:=pn.y+Gdisp-as;
     pk.y:=pk.y+Gdisp-as;
   End;
   Gcolor:=colG;
   OsX:=as;    OsY:=Gdisp;
   angle:=0;
   DrawGround;
End;

Procedure TScreen.GraphInit;
Var gd, gm, ErrorCode:Integer;
Begin
   If  GetGraphMode=2  Then  Exit;
   gd:=Detect;
  InitGraph(gd, gm, '');
  ErrorCode:=GraphResult;
  If ErrorCode <> grOk Then Begin
     Writeln('rty', GraphErrorMsg (ErrorCode));
     Halt(1);
  End;
End;

Procedure  TScreen.DrawGround;
Begin SetColor (Gcolor);
      Line (0, Round(Gdisp + 1), GetMaxX, Round(Gdisp + 1));
End;

Function  TScreen.ShiftOsXY :Boolean;

Begin  If angle>pi/2
         Then Begin OsX:=OsX+as;
                          ShiftOsXY := True; End
         Else ShiftOsXY:=False;
End;

Procedure TScreen.Go;
Begin
 Repeat
   Repeat
     angle:=angle+step;
     If ShiftOsXY
       Then Begin angle:=0; Continue; End;
     Rotate (OsX, OsY);
     Show(Scolor);
     Delay(ms);
     Show(0);
     If KeyPressed Then Exit;
   Until OsX>GetMaxX;
   Init (as, Scolor, Gcolor, Gdisp);
   DrawGround;
 Until False;
End;

Destructor TScreen.Done;
Begin  CloseGraph;   End;
End.

Program Kvadrat;
Uses SqUnit,Graph,Crt;
Const   sizeSq=80;
            colorSq=12;
            colorG=2;
            deltaG=400;

Var Driver,Mode:integer;
    Screen:TScreen;

Begin
   Driver:=Detect;
   InitGraph(Driver,Mode,'D:\ProgramFiles\Pascal7\Bin');
   Screen.Init (sizeSq, colorSq, colorG, deltaG);
   Screen.DrawGround;
   Screen.Go;
   Screen.Done;
   Readln;
   CloseGraph;
End.
Leshiy1 вне форума
Старый 11.12.2010, 01:38   #7
Leshiy1
Форумчанин
 
Аватар для Leshiy1
 
Регистрация: 24.09.2009
Сообщений: 104
По умолчанию

Я написал Program но все равно также
Leshiy1 вне форума
Старый 11.12.2010, 02:04   #8
alex_fcsm
Участник клуба
 
Аватар для alex_fcsm
 
Регистрация: 10.11.2008
Сообщений: 1,502
По умолчанию

Сделайте 2 файла - в один файл модуль в другой файл программу, в которой будете вызывать свой модуль
Нормальное состояние техники - нерабочее, все остальное частный случай.
alex_fcsm вне форума
Старый 11.12.2010, 02:30   #9
Leshiy1
Форумчанин
 
Аватар для Leshiy1
 
Регистрация: 24.09.2009
Сообщений: 104
По умолчанию

Спасибо программа запустилась. Квадратик покатился
Leshiy1 вне форума
Закрытая тема


Купить рекламу на форуме - 42 тыс руб за месяц