Ver Mensaje Individual
  #3  
Antiguo 24-09-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
oscarac,

Cita:
...pasar el valor de una variable a otra Global dentro de un procedimiento...


Revisa este código
Código Delphi [-]
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

   function GetDocument1(Serie : String) : String;
   var
      Numero : Integer;
   begin
      Numero := 789;
      Result := Format('%s-%.7d',[Serie,Numero]); // Result := 123-0000789
   end;

   procedure GetDocument2(Serie : String; var Document : String);
   var
      Numero : Integer;
   begin
      Numero := 789;
      Document := Format('%s-%.7d',[Serie,Numero]); // Document := 123-0000789
   end;

var
   Serie, Document : String;

begin

   Serie := '123';

   Document := GetDocument1(Serie);
   ShowMessage(Document);

   Document := EmptyStr;
   GetDocument2(Serie, Document);
   ShowMessage(Document);

end;

end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32, es un ejemplo de retorno de valores por medio de funciones y procedimientos con variables por referencia.

Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 24-09-2014 a las 17:26:23.
Responder Con Cita