From: nowinski@watserv1.uwaterloo.ca (NOWINSKI A - OPTOMETRY )
Newsgroups: comp.lang.pascal
Subject: tpvision questions
Date: 14 Oct 92 13:30:24 GMT
Article-I.D.: watserv1.Bw45Ip.Kop
Organization: University of Waterloo


I am posting those questions for my 12 years old son.

Subject: Turbo Vision for Turbo Pascal 6

Hi, my name is Jack Nowinski and I have two questions about Turbo
Vision for Turbo Pascal.

1) Below you can see my program that I started working on, I am
   stuck on where I want the user to type something. What do I do
   to keep the data from the input line after someone has typed
   something. I want it to work like this:

   USES
     CRT, DOS;

   var
     MyString : String;

   begin
      WriteLn('What is your name');
      ReadLn(MyString);
      WriteLn('Your name is ',MyString);
   end.


This is the program I mentioned in the first sentence.

program TVP;

{$M 8192,8192,655360}
{$S-}

{$X+}

uses
  Dos, Crt, Objects, Drivers, Views, Menus, Dialogs,
  StdDlg, MsgBox, App;

const
     cmInputData = 103;

Type
  PBGIApp = ^DemoApp;
  DemoApp = object(TApplication)
    AppDriver: Integer;
    AppMode: Integer;
    BGIPath: PString;
    constructor Init;
    destructor Done; virtual;
    procedure HandleEvent(var Event: TEvent); virtual;
    procedure InitMenuBar; virtual;
    procedure InitStatusLine; virtual;

  end;


constructor DemoApp.Init;
var
  D: PDialog;
  Control: PView;
  R: TRect;

begin
  TApplication.Init;
end;


destructor DemoApp.Done;
begin
  TApplication.Done;

end;

procedure DemoApp.HandleEvent(var Event: TEvent);

procedure InputData;
var
  D: PDialog;
  Control: PView;
  R: TRect;

begin
  R.Assign(0, 0, 35, 11);
  D := New(PDialog, Init(R, 'Data'));
  with D^ do
  begin
    Options := Options or ofCentered;

    R.Assign(12, 8, 22, 10);
    Insert(New(PButton, Init(R, 'O~K', cmOk, bfDefault)));


    R.Assign(3, 3, 32, 4);
    Control := New(PInputLine, Init(R, 80));
    Insert(Control);
    R.Assign(2, 2, 15, 3);
    Insert(New(PLabel, Init(R, '~T~ype Name', Control)));


end;
  if ValidView(D) <> nil then
  begin
    Desktop^.ExecView(D);
    Dispose(D, Done);

end;
end;


begin
  TApplication.HandleEvent(Event);
  case Event.What of
    evCommand:
      case Event.Command of
         cmInputData : InputData;
         else
        Exit;
      end;

  else
    Exit;
  end;
  ClearEvent(Event);
end;

procedure DemoApp.InitMenuBar;
var
  R: TRect;
begin
  GetExtent(R);
  R.B.Y := R.A.Y + 1;
  MenuBar := New(PMenuBar, Init(R, NewMenu(

    NewSubMenu('~F~ile', hcNoContext, NewMenu(
    NewItem('~D~ata', '',kbnokey,cmInputData, hcNoContext,
    NewItem('E~x~it', 'Alt-X', KBAltX, cmQuit, hcNoContext,
nil))),nil))));
end;

procedure DemoApp.InitStatusLine;
var
  R: TRect;
begin
  GetExtent(R);
  R.A.Y := R.B.Y - 1;
  New(StatusLine, Init(R,
    NewStatusDef(0, $FFFF,
      NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
      NewStatusKey('', kbF10, cmMenu,


      nil)),
    nil)));
end;

var
  DemApp: DemoApp;

begin
  DemApp.Init;
  DemApp.Run;
  DemApp.Done;
end.




2) How do I put the input the user typed onto the screen.
   I would like it to work like this:


   var
     D: PDialog;
     Control: PView;
     R: TRect;

   begin
      R.Assign(0, 0, 40, 13);
      D := New(PDialog, Init(R, 'Your Data is'));
      with D^ do
   begin
      Options := Options or ofCentered;

      R.Grow(-1, -1);
      Dec(R.B.Y, 3);
      Insert(New(PStaticText, Init(R,
        #13 +
        ^C'   ')));  {There where the big space is I would like
                      the user data to be shown}

    R.Assign(14, 10, 24, 12);

    Insert(New(PButton, Init(R, 'O~K', cmOk, bfDefault)));

  end;

  if ValidView(D) <> nil then
  begin
    Desktop^.ExecView(D);
    Dispose(D, Done);
  end;
end;
Newsgroups: comp.lang.pascal