E2003 Необъявленный идентификатор: «Form1» - из ниоткуда - PullRequest
1 голос
/ 10 октября 2019

Впервые за долгое время я снова и снова вмешивался в Delphi на виртуальной машине и сейчас работаю над импортом JSON. Однако внезапно (без сомнения, я что-то удалил или испортил) я не могу скомпилировать проект.

Каждый раз, когда я пытаюсь, я получаю сообщение E003 Необъявленный идентификатор: 'Form1' , и редактор привязывается к файлу программы Project1 , опираясь на Application.CreateForm(TForm1, Form1);линия.

Я приложил unit1.pas, в котором находится форма, а также другие, казалось бы, соответствующие файлы. Пожалуйста помоги! Что я сделал / удалил?

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Xml.xmldom, Xml.XMLIntf,
  Xml.XMLDoc, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, IdSSLOpenSSL,
  IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, inifiles,
  Vcl.ExtCtrls, Vcl.ComCtrls;

const
  GstrAPIKey = 'removed this :)';

type
  TForm1 = class(TForm)
    Button1: TButton;
    XMLDocument1: TXMLDocument;
    Memo1: TMemo;
    IdHTTP1: TIdHTTP;
    IdSSL: TIdSSLIOHandlerSocketOpenSSL;
    rgrp_Home: TRadioGroup;
    cbx_Report: TComboBox;
    cbx_Charts: TComboBox;
    sb_Main: TStatusBar;
    dt_From: TDateTimePicker;
    dt_To: TDateTimePicker;
    Edit1: TEdit;
    lbl_DF: TLabel;
    Label1: TLabel;
    edt_Search: TEdit;
    Label2: TLabel;
    Button4: TButton;
    Button2: TButton;
    PageControl1: TPageControl;
    Reports: TTabSheet;
    Charts: TTabSheet;
    Label3: TLabel;
    Label4: TLabel;
    Memo2: TMemo;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure rgrp_HomeClick(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure cbx_ReportChange(Sender: TObject);
    procedure pnl_ReportsClick(Sender: TObject);
  private

    { Private declarations }
    procedure SetJSON(const Value : string);
    function GetJSON : string;
  public
          shortdateformat: string;
    { Public declarations }
    property JSON: string read GetJSON write SetJSON;

  end;

var
  strCommID : string;
  GstrPath,
  GstrCommID,
  GstrURL : string;

implementation

type
    TCareNote = (
                  CareNoteID  = 1,
                  CareNoteExtID = 2,
                  ADLName = 3,
                  FlagsText = 4,
                  Note = 5,
                  AnswerType = 6,
                  Fragment = 7,
                  RemedialText = 8,
                  Details = 9,
                  ServiceUserID = 10,
                  ServiceUser = 11,
                  ServiceUserLastName = 12,
                  ServiceUserForenames = 13,
                  ServiceUserDOB = 14,
                  ServiceUserLocation = 15,
                  WorkerID = 16,
                  Worker = 17,
                  VoidedByWorker = 18,
                  _supercedestack = 19,
                  SupercededbyWorker = 20,
                  WorkerLastName = 21,
                  DisplayonShiftHO = 22,
                  WorkerInitials = 23,
                  SliderData = 24,
                  SliderDate2 = 25,
                  SliderIcons = 26,
                  DateDone = 27,
                  DateDoneSU = 28,
                  Duration = 29,
                  DurationInt = 30,
                  ActionIconID = 31,
                  mraCareOrder = 32,
                  WasPlanned = 33,
                  qrVerified = 34,
                  qrData = 35,
                  nfcVerified = 36,
                  inVerified = 37
                );





{$R *.dfm}

function TForm1.GetJSON : string;
begin
  Result := Memo1.Lines.Text;
end;

procedure TForm1.SetJSON(const Value: string);
begin
  Memo1.Lines.Text := Value;
end;

{*********************************************}
procedure TForm1.Button1Click(Sender: TObject);
{*********************************************}
var
  s : tmemorystream;
begin
  idhttp1.HandleRedirects := TRUE;
  s := tmemorystream.Create;
  idhttp1.ReadTimeout := 30000;
  idhttp1.IOHandler := idssl;
  IdSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
  IdSSL.SSLOptions.Mode := sslmUnassigned;
  idhttp1.Get(GstrURL,S);
  s.Position := 0;
  memo1.Lines.loadfromstream(s);
end;

{*********************************************}
procedure TForm1.Button4Click(Sender: TObject);


{*********************************************}
var
  IniFile : TIniFile;
  strURL : string;
  strRep : string;
  strDateFrom,
  strDateTo : string;
begin
  try
      IniFile := TIniFile.Create(GstrPath+'\config.ini');
      GstrURL := IniFile.ReadString('URL','path','Error');
      GstrURL := GstrURL+GstrAPIKey;
      GstrURL := GstrURL+'/ReportsAndChartsApi/Get/';
      case cbx_Report.ItemIndex of
        -1  :  ;
        0   : begin
                  strRep := 'CareNotesReport';
              end;
        1   : begin
                  strRep := 'AccidentsReport';
              end;
        2   : begin
                  strRep := 'IncidentsReport';
              end;
        3   : begin
                  strRep := 'FallsReport';

              end;
        4   : begin
                  strRep := 'InfectionsReport';
              end;
        5   : begin
                  strRep := 'WoundSummaryReport';
              end;
        end;

      //Dates to and from for the report...
      strDateFrom := FormatDateTime('yyyy-mm-dd',dt_From.Date);
      GstrURL := GstrURL + strRep +'?DateFrom='+strDateFrom;

      strDateTo := FormatDateTime('yyyy-mm-dd',dt_To.Date);
      GstrURL := GstrURL +'&DateTo='+strDateTo;

      if (Length(edt_Search.Text) > 0) and (cbx_Report.Itemindex <> 3) then
      begin
            GstrURL := GstrURL + '&SearchText='+edt_Search.Text;
      end;

      //Community IDs
      GstrURL := GstrURL + '&CommunityID='+GstrCommID;

      //if there is anything in the search text box...

      //showmessage(strurl);
  finally

  end;
  //edt_URL.Text := IniFile.ReadString('URL','Path')+DateToStr(dt_From.DateTime)+
end;

{*************************************************}
procedure TForm1.cbx_ReportChange(Sender: TObject);
{*************************************************}
begin
if (cbx_Report.ItemIndex = 3) then
        edt_Search.ReadOnly := TRUE
else
        edt_Search.ReadOnly := FALSE;
end;

{*******************************************}
procedure TForm1.FormCreate(Sender: TObject);
{*******************************************}
begin
  //find the path of the executable to make sure the right config file is used
  GstrPath := ExtractFilePath(Application.Exename);
end;

procedure TForm1.pnl_ReportsClick(Sender: TObject);
begin

end;

{***********************************************}
procedure TForm1.rgrp_HomeClick(Sender: TObject);
{***********************************************}
var
  Inifile : TIniFile;
  strChoice :string;
begin
    try
      Inifile := TIniFile.Create(GstrPath+'\config.ini'); //create the inifile link
      strChoice := rgrp_Home.Items[rgrp_Home.ItemIndex];
      if Inifile.SectionExists('Community') then
        if IniFile.ValueExists('Community',strChoice) then
        begin
            GstrCommID := IniFile.ReadString('Community',strChoice,'');

            sb_Main.Panels[0].Text := 'Current Home: '+strChoice;
            sb_Main.Panels[1].Text := 'Comm ID: '+ GstrCommID;
            IniFile.Destroy;
        end;
    finally
      if GstrCommID = '' then MessageDLG(strChoice+' is not yet on PCS',mtInformation,[mbOK],0);

    end;

end;

end.`



object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 669
  ClientWidth = 508
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poDesigned
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object lbl_DF: TLabel
    Left = 130
    Top = 119
    Width = 54
    Height = 13
    Caption = 'Date From:'
  end
  object Label1: TLabel
    Left = 233
    Top = 119
    Width = 42
    Height = 13
    Caption = 'Date To:'
  end
  object Label2: TLabel
    Left = 336
    Top = 119
    Width = 58
    Height = 13
    Caption = 'Search Text'
  end
  object Button1: TButton
    Left = 185
    Top = 165
    Width = 145
    Height = 49
    Caption = 'Fetch Information'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Memo1: TMemo
    Left = 19
    Top = 247
    Width = 481
    Height = 132
    TabOrder = 1
  end
  object rgrp_Home: TRadioGroup
    Left = 8
    Top = 8
    Width = 105
    Height = 177
    Caption = 'Homes'
    Items.Strings = (
      'Croston'
      'Hall'
      'Magnolia'
      'Manor'
      'Croft'
      'Lodge'
      'Hollow')
    TabOrder = 2
    OnClick = rgrp_HomeClick
  end
  object sb_Main: TStatusBar
    Left = 0
    Top = 650
    Width = 508
    Height = 19
    Panels = <
      item
        Text = 'Current Home:'
        Width = 200
      end
      item
        Text = 'Comm ID:'
        Width = 400
      end
      item
        Width = 50
      end>
  end
  object dt_From: TDateTimePicker
    Left = 130
    Top = 138
    Width = 97
    Height = 21
    Date = 43744.000000000000000000
    Time = 0.867717511573573600
    TabOrder = 4
  end
  object dt_To: TDateTimePicker
    Left = 233
    Top = 138
    Width = 97
    Height = 21
    Date = 43744.000000000000000000
    Time = 0.867717511573573600
    TabOrder = 5
  end
  object Edit1: TEdit
    Left = 19
    Top = 220
    Width = 481
    Height = 21
    TabOrder = 6
  end
  object edt_Search: TEdit
    Left = 336
    Top = 138
    Width = 95
    Height = 21
    TabOrder = 7
  end
  object Button4: TButton
    Left = 398
    Top = 82
    Width = 75
    Height = 25
    Caption = 'Create URL'
    TabOrder = 8
    OnClick = Button4Click
  end
  object PageControl1: TPageControl
    Left = 130
    Top = 51
    Width = 255
    Height = 62
    ActivePage = Reports
    TabOrder = 9
    object Reports: TTabSheet
      Caption = 'Reports'
      object Label3: TLabel
        Left = 20
        Top = 12
        Width = 72
        Height = 13
        Caption = 'Choose Report'
      end
      object cbx_Report: TComboBox
        Left = 99
        Top = 9
        Width = 145
        Height = 21
        Style = csDropDownList
        TabOrder = 0
        OnChange = cbx_ReportChange
        Items.Strings = (
          'Care Notes'
          'Accidents'
          'Incidents'
          'Falls'
          'Infections'
          'Wounds')
      end
    end
    object Charts: TTabSheet
      Caption = 'Charts'
      ImageIndex = 1
      ExplicitLeft = 0
      ExplicitTop = 0
      ExplicitWidth = 0
      ExplicitHeight = 0
      object Label4: TLabel
        Tag = 10
        Left = 20
        Top = 13
        Width = 66
        Height = 13
        Caption = 'Choose Chart'
      end
      object cbx_Charts: TComboBox
        Left = 99
        Top = 9
        Width = 145
        Height = 21
        Style = csDropDownList
        TabOrder = 0
        Items.Strings = (
          'Bowel Movements'
          'Fluids'
          'Hygiene'
          'Bedrails Checks'
          'Mattress Check'
          'Repositioning'
          'Emotional Support')
      end
    end
  end
  object Button2: TButton
    Left = 164
    Top = 10
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 10
  end
  object Memo2: TMemo
    Left = 19
    Top = 432
    Width = 481
    Height = 193
    Lines.Strings = (
      'Memo2')
    TabOrder = 11
  end
  object Button3: TButton
    Left = 216
    Top = 401
    Width = 75
    Height = 25
    Caption = 'Button3'
    TabOrder = 12
  end
  object XMLDocument1: TXMLDocument
    Left = 896
    Top = 8
  end
  object IdHTTP1: TIdHTTP
    AllowCookies = True
    HandleRedirects = True
    ProxyParams.BasicAuthentication = False
    ProxyParams.ProxyPort = 0
    Request.ContentLength = -1
    Request.ContentRangeEnd = -1
    Request.ContentRangeStart = -1
    Request.ContentRangeInstanceLength = -1
    Request.Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
    Request.BasicAuthentication = False
    Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
    Request.Ranges.Units = 'bytes'
    Request.Ranges = <>
    HTTPOptions = [hoForceEncodeParams]
    Left = 944
    Top = 8
  end
  object IdSSL: TIdSSLIOHandlerSocketOpenSSL
    MaxLineAction = maException
    Port = 0
    DefaultPort = 0
    SSLOptions.Mode = sslmUnassigned
    SSLOptions.VerifyMode = []
    SSLOptions.VerifyDepth = 0
    Left = 984
    Top = 8
  end
end`

1 Ответ

7 голосов
/ 10 октября 2019

Вы (возможно, случайно) удалили объявление Form1: TForm1 в разделе интерфейса var.

var
  Form1: TForm1;  // <<--- Should be there, but is missing
  strCommID : string;
  GstrPath,
  GstrCommID,
  GstrURL : string;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...