Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > Varios
Register FAQ Members List Calendar Guía de estilo Today's Posts

Coloboración Paypal con ClubDelphi

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 29/09/2013
aitorqrv aitorqrv is offline
Miembro
 
Join Date: Apr 2007
Posts: 18
Poder: 0
aitorqrv Va por buen camino
Ejecutar una función de otra unidad

Hola a todos, a mi cuando programo en PHP me gusta ordenar las funciones todas juntas o ordenarlas por tipos diferentes en archivos separarados. Esto lo hago para poder depurar el programa mas cacilmente en el futuro, pero en delphi no se como se hace.

Por ejemplo me gustaria meter esta función en Unit2 y poder llamarla y utilizarla desde Unit1:

Código Delphi [-]
function ReverseString( s : string ) : string;
var
  i  : integer;
  s2 : string;
begin
  s2 := '';
  for i := 1 to Length( s ) do
    s2 := s[ i ] + s2;
  Result := s2;
end;

Yo he intentado hacerlo asi, pero no funciona:

Unit1.pas
Código Delphi [-]
{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

uses
  unit2;

procedure TForm1.Button1Click(Sender: TObject);
begin
   form1.edit1.Text := ReverseString(form1.edit1.Text);
end;

end.

Unit2.pas
Código Delphi [-]
unit Unit2;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

implementation

function ReverseString( s : string ) : string;
var
  i  : integer;
  s2 : string;
begin
  s2 := '';
  for i := 1 to Length( s ) do
    s2 := s[ i ] + s2;
  Result := s2;
end;

end.

Gracias gracias.
Reply With Quote
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Función javascript que llama a otra función javascript en otra página jandroruiz HTML, Javascript y otros 4 28/02/2013 11:38
Problema con un procedure en otra unidad HombreGordo Varios 1 23/12/2011 19:20
Almacenando datos en una variable de otra unidad R0M3R0 OOP 11 21/08/2008 21:09
Acceder a un DataSet desde otra unidad SMTZ .NET 5 24/12/2005 09:01
ejecutar una funcion d otra Unit negama Varios 2 08/09/2003 19:32


All times are GMT +2. The time now is 05:30.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi