{*******************************************************}
{                                                       }
{       Pascal Script Source File                       }
{       Run by RemObjects Pascal Script in CnWizards    }
{                                                       }
{       Generated by CnPack IDE Wizards                 }
{                                                       }
{*******************************************************}

program OTADemo2;

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  TypInfo, ToolsAPI, CnCommon, CnWizUtils, CnWizIdeUtils;

var
  Form: TCustomForm;
  List: TList;
  Selected: string;
  i: Integer;

begin
  Form := IdeGetDesignedForm(nil);
  if Form <> nil then
  begin
    List := TList.Create;
    try
      IdeGetFormSelection(List, nil, True);
      for i := 0 to Form.ComponentCount - 1 do
      begin
        // In cnwizards script, Pointer was declared as Cardinal.
        // Here use _Pointer() to convert TObject to Pointer.
        if List.IndexOf(_Pointer(Form.Components[i])) >= 0 then
          Selected := '[Selected]'
        else
          Selected := '';
        Writeln(Format('%s: %s %s', [Form.Components[i].Name,
          Form.Components[i].ClassName, Selected]));
      end;
    finally
      List.Free;
    end;                
  end
  else
  begin
    Writeln('To run this demo, you must add the script to script list first.');
    Writeln('Open a form and then run the script from list again.');
  end;
end.

