unit uRegister;

// AsOf 2023-09-22
interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

procedure FormsRegister;
Function CreateForm(const FormName: string): TForm;

implementation

Uses
  uBodyPlan,
  {UsesStepsStart}
uStep_1, uStep_2, uStep_3, uStep_4, uStep_5, uStep_6, uStep_7, uStep_8, uStep_9, uStep_10, uStep_11, 
uStep_12, uStep_13, uStep_14, uStep_15, uStep_16, uStep_17, uStep_18, uStep_19, uStep_20, uStep_21, 
uStep_22, uStep_23, uStep_24, uStep_25, 
  {UsesStepsStop}

  {UsesSynapsesStart}
uSynapse_1, uSynapse_2, uSynapse_3, uSynapse_4, uSynapse_5, uSynapse_6, uSynapse_7, uSynapse_8, uSynapse_9, uSynapse_10, uSynapse_11, 
uSynapse_12, uSynapse_13, uSynapse_14, uSynapse_15, uSynapse_16, uSynapse_17, uSynapse_18, uSynapse_19, uSynapse_20, uSynapse_21, 
uSynapse_22, uSynapse_23, uSynapse_24, uSynapse_25, uSynapse_26, uSynapse_27, uSynapse_28, uSynapse_29, uSynapse_30, uSynapse_31, 
uSynapse_32, uSynapse_33, uSynapse_34, uSynapse_35, uSynapse_36, uSynapse_37, uSynapse_38, uSynapse_39, uSynapse_40, uSynapse_41, 
uSynapse_42, uSynapse_43, uSynapse_44, uSynapse_45, uSynapse_46, uSynapse_47, uSynapse_48, uSynapse_49, uSynapse_50, 
  {UsesSynapsesStop}

  {UsesDendritesStart}
uDendrite_1, uDendrite_2, uDendrite_3, uDendrite_4, uDendrite_5, uDendrite_6, uDendrite_7, uDendrite_8, uDendrite_9, uDendrite_10, uDendrite_11, 
uDendrite_12, uDendrite_13, uDendrite_14, uDendrite_15, uDendrite_16, uDendrite_17, uDendrite_18, uDendrite_19, uDendrite_20, uDendrite_21, 
uDendrite_22, uDendrite_23, uDendrite_24, uDendrite_25, uDendrite_26, uDendrite_27, uDendrite_28, uDendrite_29, uDendrite_30, uDendrite_31, 
uDendrite_32, uDendrite_33, uDendrite_34, uDendrite_35, uDendrite_36, uDendrite_37, uDendrite_38, uDendrite_39, uDendrite_40, uDendrite_41, 
uDendrite_42, uDendrite_43, uDendrite_44, uDendrite_45, uDendrite_46, uDendrite_47, uDendrite_48, uDendrite_49, uDendrite_50, 
  {UsesDendritesStop}

  {UsesSomesStart}
uSoma_1, uSoma_2, uSoma_3, uSoma_4, uSoma_5, uSoma_6, uSoma_7, uSoma_8, uSoma_9, uSoma_10, 
  {UsesSomesStop}

  {UsesAxonsStart}
uAxon_1, uAxon_2, uAxon_3, uAxon_4, uAxon_5, uAxon_6, uAxon_7, uAxon_8, uAxon_9, uAxon_10, uAxon_11, 
uAxon_12, uAxon_13, uAxon_14, uAxon_15, uAxon_16, uAxon_17, uAxon_18, uAxon_19, uAxon_20, uAxon_21, 
uAxon_22, uAxon_23, uAxon_24, uAxon_25, 
  {UsesAxonsStop}

  {UsesScopesStart}
  uScope_Blue, UScope_Black, uScope_Green, UScope_Red; // Terminal of the use clause;
{ UsesScopesStop }

const
NumberOfSteps = 25;
NumberOfSynapses = 50;
NumberOfDendrites = 50;
NumberOfSomas = 10;
NumberOfAxons = 25;
  NumberOfScopes = 4;

  NumberOfForms = NumberOfSteps + NumberOfSynapses + NumberOfDendrites + NumberOfSomas + NumberOfAxons + NumberOfScopes;

  arrayOfClasses: array [0 .. NumberOfForms - 1] of TFormClass = (
    { FormStartSteps }
TfrmStep_1,TfrmStep_2,TfrmStep_3,TfrmStep_4,TfrmStep_5,TfrmStep_6,TfrmStep_7,TfrmStep_8,TfrmStep_9,TfrmStep_10,
TfrmStep_11,TfrmStep_12,TfrmStep_13,TfrmStep_14,TfrmStep_15,TfrmStep_16,TfrmStep_17,TfrmStep_18,TfrmStep_19,TfrmStep_20,
TfrmStep_21,TfrmStep_22,TfrmStep_23,TfrmStep_24,TfrmStep_25,
    { FormStopSteps }
    //
    { FormStartSynapses }
TfrmSynapse_1,TfrmSynapse_2,TfrmSynapse_3,TfrmSynapse_4,TfrmSynapse_5,TfrmSynapse_6,TfrmSynapse_7,TfrmSynapse_8,TfrmSynapse_9,TfrmSynapse_10,
TfrmSynapse_11,TfrmSynapse_12,TfrmSynapse_13,TfrmSynapse_14,TfrmSynapse_15,TfrmSynapse_16,TfrmSynapse_17,TfrmSynapse_18,TfrmSynapse_19,TfrmSynapse_20,
TfrmSynapse_21,TfrmSynapse_22,TfrmSynapse_23,TfrmSynapse_24,TfrmSynapse_25,TfrmSynapse_26,TfrmSynapse_27,TfrmSynapse_28,TfrmSynapse_29,TfrmSynapse_30,
TfrmSynapse_31,TfrmSynapse_32,TfrmSynapse_33,TfrmSynapse_34,TfrmSynapse_35,TfrmSynapse_36,TfrmSynapse_37,TfrmSynapse_38,TfrmSynapse_39,TfrmSynapse_40,
TfrmSynapse_41,TfrmSynapse_42,TfrmSynapse_43,TfrmSynapse_44,TfrmSynapse_45,TfrmSynapse_46,TfrmSynapse_47,TfrmSynapse_48,TfrmSynapse_49,TfrmSynapse_50,

    { FormStopSynapses }
    //
    { FormStartDendrites }
TfrmDendrite_1,TfrmDendrite_2,TfrmDendrite_3,TfrmDendrite_4,TfrmDendrite_5,TfrmDendrite_6,TfrmDendrite_7,TfrmDendrite_8,TfrmDendrite_9,TfrmDendrite_10,
TfrmDendrite_11,TfrmDendrite_12,TfrmDendrite_13,TfrmDendrite_14,TfrmDendrite_15,TfrmDendrite_16,TfrmDendrite_17,TfrmDendrite_18,TfrmDendrite_19,TfrmDendrite_20,
TfrmDendrite_21,TfrmDendrite_22,TfrmDendrite_23,TfrmDendrite_24,TfrmDendrite_25,TfrmDendrite_26,TfrmDendrite_27,TfrmDendrite_28,TfrmDendrite_29,TfrmDendrite_30,
TfrmDendrite_31,TfrmDendrite_32,TfrmDendrite_33,TfrmDendrite_34,TfrmDendrite_35,TfrmDendrite_36,TfrmDendrite_37,TfrmDendrite_38,TfrmDendrite_39,TfrmDendrite_40,
TfrmDendrite_41,TfrmDendrite_42,TfrmDendrite_43,TfrmDendrite_44,TfrmDendrite_45,TfrmDendrite_46,TfrmDendrite_47,TfrmDendrite_48,TfrmDendrite_49,TfrmDendrite_50,

    { FormStopDendrites }
    //
    { FormStartSomas }
TfrmSoma_1,TfrmSoma_2,TfrmSoma_3,TfrmSoma_4,TfrmSoma_5,TfrmSoma_6,TfrmSoma_7,TfrmSoma_8,TfrmSoma_9,TfrmSoma_10,

    { FormStopSomas }
    //
    { FormStartAxons }
TfrmAxon_1,TfrmAxon_2,TfrmAxon_3,TfrmAxon_4,TfrmAxon_5,TfrmAxon_6,TfrmAxon_7,TfrmAxon_8,TfrmAxon_9,TfrmAxon_10,
TfrmAxon_11,TfrmAxon_12,TfrmAxon_13,TfrmAxon_14,TfrmAxon_15,TfrmAxon_16,TfrmAxon_17,TfrmAxon_18,TfrmAxon_19,TfrmAxon_20,
TfrmAxon_21,TfrmAxon_22,TfrmAxon_23,TfrmAxon_24,TfrmAxon_25,
    { FormStopAxons }
    //
    TfrmScope_Blue, TfrmScope_Black, TfrmScope_Green, TfrmScope_Red); // Terminal of the Array

function FormExists(AFormClass: TClass): TForm;
var
  i: integer;
begin
  Result := nil;
  for i := 0 to Application.ComponentCount - 1 do
    begin
      if Application.Components[i].ClassType = AFormClass then
        begin
          Result := TForm(Application.Components[i]);
          break;
        end;
    end;
end;

Function CreateForm(const FormName: string): TForm;
var
  FormClass: TFormClass;
  retForm: TForm;
  IconFormName: String;
begin

  FormClass := TFormClass(FindClass('Tfrm' + FormName));
  retForm := FormExists(FormClass);
  if retForm = nil then
    retForm := FormClass.Create(Application);

  IconFormName := retForm.name;
  Result := retForm;
end;

procedure FormsRegister;
var
  i: integer;
begin

  for i := 0 to NumberOfForms - 1 do
    RegisterClass(arrayOfClasses[i]);

end;

end.
