Tema: Llenar array
Ver Mensaje Individual
  #34  
Antiguo 20-02-2020
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
De entrada y sin entrar en el funcionamiento del código veo que tienes una unit con las definiciones para usar swedll32.dll desde delphi. Eso implica que debes incluirla en el uses y no repetir de nuevo nada.


Tu código debe quedar mucho más sencillo y resumiendo esto es la parte que interesa:


Código Delphi [-]
unit sample2; 

interface  

uses   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,   StdCtrls, swiss;  

type   TForm1 = class(TForm)
    button_doit: TButton;     
    button_exit: TButton;
    outfld: TMemo;
    combo_utet: TComboBox;
    Combo_EW: TComboBox;
    Combo_NS: TComboBox;
    combo_hsys: TComboBox;
    day: TEdit;
    month: TEdit;
    year: TEdit;
    outfld: TMemo;
    hour: TEdit;
    minute: TEdit;
    second: TEdit;
    lon_deg: TEdit;
    lon_min: TEdit;
    lon_sec: TEdit;
    lat_deg: TEdit;
    lat_sec: TEdit;
    lat_min: TEdit;

 ...........
implementation

{$R *.dfm}

procedure TForm1.button_doitClick(Sender: TObject);
const
   hsys: array[0..4] of Char = ('P', 'K', 'R', 'C', 'E');
var
   tjd, tjdet, tjdut, tsid, armc, dhour, deltat : double;
   eps_true, e, nut_long: double;
   glon, glat: double;
   sjul: String[30];
   s: Array[0..255] of Char;
   sout: string[255];
   i, j: integer;
   iflag, rflag : Longint;
   ilondeg, ilonmin, ilonsec, ilatdeg, ilatmin, ilatsec: Integer;
   hcusps: array[0..12] of double;
   ascmc: array[0..9] of double;
   pname: array[0..19] of Char;
begin
  outfld.clear;
  iflag := 0;
  iday := StrToInt(day.Text);
  imonth := StrToInt(month.Text);
  iyear := StrToInt(year.Text);
  ihour := StrToInt(hour.Text);
  imin := StrToInt(minute.Text);
  isec := StrToInt(second.Text);
  ilondeg := StrToInt(lon_deg.Text);
  ilonmin := StrToInt(lon_min.Text);
  ilonsec := StrToInt(lon_sec.Text);
  ilatdeg := StrToInt(lat_deg.Text);
  ilatmin := StrToInt(lat_min.Text);
  ilatsec := StrToInt(lat_sec.Text);
  dhour := ihour + imin / 60.0 + isec / 3600.0;
  tjd := swe_julday(iyear, imonth, iday, dhour, 1);
  deltat := swe_deltat(tjd);
  if (combo_utet.ItemIndex <= 0)then
    begin
    {input date is Universal Time}
    Str((deltat * 86400):16:10,  sjul);
    sout := 'deltat:     ' + sjul + ' sec';
    outfld.Lines.Add(sout);
    tjdut := tjd;
    tjdet := tjd + deltat;
    Str(tjdut:10:8,  sjul);
    sjul := sjul + ' UT';
    end
  else
    begin
    {input date is Ephemeris Time}
    tjdet := tjd;
    tjdut := tjd - deltat;
    Str(tjdet:16:10,  sjul);
    sjul := sjul + ' ET';
    end;
  sout := 'jul. day:   ' + sjul;
  outfld.Lines.Add( sout);
  outfld.Lines.Add(' ');
  { planets }
  for i := SE_SUN to SE_TRUE_NODE do
    begin
      rflag := swe_calc(tjdet, i, iflag, xx[0], serr);
      if (rflag <> iflag) then outfld.Lines.Add(StrPas(serr));
      Str(xx[0]:16:10,  sjul);
      swe_get_planet_name(i, pname);
      sout := StrPas(pname);
      for j := StrLen(pname) to 11 do sout := sout + ' ';
      sout := sout + sjul;
      outfld.Lines.Add( sout);
    end;
  { for houses: ecliptic obliquity and nutation }
  rflag := swe_calc(tjdet, SE_ECL_NUT, 0, xx[0], serr);
  if (rflag <> 0) then outfld.Lines.Add(StrPas(serr));
  eps_true := xx[0];
  e:=xx[1];
  nut_long := xx [2];
  { geographic position }
  glon := ilondeg + ilonmin / 60.0 + ilonsec / 3600.0;
  if (combo_EW.ItemIndex > 0) then glon := -glon;
  glat := ilatdeg + ilatmin / 60.0 + ilatsec / 3600.0;
  if (combo_NS.ItemIndex > 0) then glat := -glat;
  { sidereal time }
  tsid := swe_sidtime(tjdut);
  tsid := tsid + glon / 15;
  armc := tsid * 15;
  outfld.Lines.Add(' ');
  Str(tsid:16:10, sjul);
  sout := 'Sid. time   ' + sjul;
  outfld.Lines.Add( sout);
  Str(armc:16:10, sjul);
  sout := 'ARMC        ' + sjul;
  outfld.Lines.Add( sout);
  { house method }
  i := combo_hsys.ItemIndex;
  if (i < 0) then i := 0;
  swe_houses_armc(armc, glat, eps_true, hsys[i], hcusps[0], ascmc[0]);
  Str(ascmc[0]:16:10, sjul);
  sout := 'ascendant   ' + sjul;
  outfld.Lines.Add( sout);
  Str(ascmc[1]:16:10, sjul);
  sout := 'MC          ' + sjul;
  outfld.Lines.Add( sout);
  Str(ascmc[3]:16:10, sjul);
  sout := 'vertex      ' + sjul;
  outfld.Lines.Add( sout);
  outfld.Lines.Add( '');
  for i := 1 to 12 do
    begin
      Str(i:2, sjul);
      sout := 'house ' + sjul + '    ';
      Str(hcusps[i]:16:10, sjul);
      sout := sout + sjul;
      outfld.Lines.Add( sout);
    end;

end;

procedure TForm1.button_exitClick(Sender: TObject);
begin
  swe_close;
  close;
  Exit;
end;

end.

El código es un galimatías. Debes ir con orden. Primero inicializaciza los ComboBox en funciones de inicio o en el Form.Create.
Luego darás funcionalidad a los botones...

Debes estudiar el uso de esa dll pues al parecer debes inicializar con una ruta que debe contener previamente algunos archivos y quizás requiera más acciones. Este punto es básico y piensa que probablemente ninguno de nosotros estamos familiarizados con esa dll, ese es tu cometido.

Cuando requieras preguntar alguna cosa concreta, trata de aislar en lo posible el código que te preocupa y que sea suficiente para entenderte pero no tán sobrecargado que se pierdan las ganas de leerlo.


Saludos.

Última edición por escafandra fecha: 20-02-2020 a las 22:19:05.
Responder Con Cita