Ver Mensaje Individual
  #4  
Antiguo 20-10-2007
Andres_vl Andres_vl is offline
Registrado
 
Registrado: sep 2007
Posts: 4
Reputación: 0
Andres_vl Va por buen camino
Más ayuda porf

Cita:
Empezado por enecumene Ver Mensaje
Hola Andres_vl, el codigo lo puedes poner en los eventos OnCreate y/o OnShow del form.

Saludos.
Mi programa debe leer el port contínuamente y exponer los datos en el form4
Acá pongo el codigo que generó delphi más lo que puse
Tengo estas preguntas a ver si me pueden dar una mano

1. En el form4 tengo un boton de Salir pero no me funciona , parece que se queda pegado en el while.
2. Me pueden escribir en este còdigo como llamar a un procedimiento que esté en la unit4
3.Me pueden indicar como declaro en el uses del programa “program MAQ_ARAND_00”que se vá a usar la unit4 y un procedimiento de esta.

Nota, estoy usando los componente abakus que estan todos en la unit 4 y me reclama cuando trato de leer la comm1 con alguna instrucción en el program MAQ…

Adjunto el código

De antemano Muchas Gracias por la ayuda

Cristian

program MAQ_ARAND_00;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3},
Unit4 in 'Unit4.pas' {Form4};
{$R *.res}



begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TForm4, Form4);
Application.Run;


end.


unit Unit4;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AbCBitBt, AbVInd, AbDBCtrls, _GClass, AbLED, AbBar, StdCtrls,
ExtCtrls, jpeg, AbTank, AbOpHour, CPortCtl, CPort;

type
TForm4 = class(TForm)
Label1: TLabel;
GRAMOS: TAbDBValueInd;
AbColBitBtn4: TAbColBitBtn;
AbDBValueInd1: TAbDBValueInd;
AbDBValueInd2: TAbDBValueInd;
AbBar1: TAbBar;
AbBar2: TAbBar;
AbBar4: TAbBar;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
AbValueInd2: TAbValueInd;
Label5: TLabel;
AbValueInd3: TAbValueInd;
AbValueInd4: TAbValueInd;
Label6: TLabel;
AbValueInd5: TAbValueInd;
Label7: TLabel;
Label8: TLabel;
AbValueInd6: TAbValueInd;
Shape1: TShape;
Shape2: TShape;
Shape11: TShape;
AbValueInd8: TAbValueInd;
AbValueInd9: TAbValueInd;
AbValueInd10: TAbValueInd;
Label13: TLabel;
Label14: TLabel;
AbValueInd12: TAbValueInd;
AbValueInd13: TAbValueInd;
AbOpHourCounter2: TAbOpHourCounter;
AbOpHourCounter3: TAbOpHourCounter;
AbValueInd7: TAbValueInd;
Label18: TLabel;
Label19: TLabel;
AbValueInd11: TAbValueInd;
AbValueInd1: TAbValueInd;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label15: TLabel;
Label16: TLabel;
AbOpHourCounter4: TAbOpHourCounter;
Image1: TImage;
Button1: TButton;
ComTerminal1: TComTerminal;
Edit1: TEdit;
Label17: TLabel;
Edit2: TEdit;
ComPort1: TComPort;
procedure AbColBitBtn4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }

end;
var
Form4: TForm4;
Str: Char;
Strcomp1:String;
Strcomp2:String;
Strcomp3:String;
Strcomp4 :String;
Strcomp5 :String;
Str1:String;
Str2:String;
Str3:String;
Valor:Integer;
texto:string;
Valor1:double;
ByteC_ON:Char;
Peso1L,Peso2L,Peso3L:String;
Peso1H,Peso2H,Peso3H:String;
PESO1,PESO2,PESO3: String;

implementation

{$R *.dfm}
//

function IntToBinRec(valor,digitos:integer):string;

begin
if digitos=0 then
result:=''
else
begin
if (valor AND (1 shl (digitos-1)))>0 then
result:='1'+IntToBinRec(valor,digitos-1)
else
result:='0'+IntToBinRec(valor,digitos-1)
end;
end;

function BinToInt(Value: String): Integer;
var
i,Size: Integer;
begin
Result:=0;
Size:=Length(Value);
for i:=Size downto 1 do
if Value[i]='1' then Result:=Result+(1 shl (Size-i));
end;

procedure TForm4.AbColBitBtn4Click(Sender: TObject);
begin
Strcomp5:='A';
form4.close
end;

procedure TForm4.Button1Click(Sender: TObject);
begin
Str:='4';
Strcomp1:='A';
Strcomp2:='A';
Strcomp3:='B';
Strcomp4:='A';
Strcomp5:='C';
Comport1.Open ;

While (Strcomp5 <> Strcomp4) do // espera una 'A'
begin
While (Strcomp2 <> Strcomp1) or (Strcomp5 <> Strcomp4) do // espera una 'A'
begin
Comport1.ReadStr(Strcomp2,1);
end;

While (Strcomp2 <> Strcomp3) or (Strcomp5 <> Strcomp4) do //Loop espera una 'B'
begin
ComPort1.ReadStr(Peso1L,1);
ComPort1.ReadStr(Peso1H,1);
ComPort1.ReadStr(Peso2L,1);
ComPort1.ReadStr(Peso2H,1);
ComPort1.ReadStr(Peso3L,1);
ComPort1.ReadStr(Peso3H,1);

PESO1:= Peso1L+Peso1H;
PESO2:= Peso2L+Peso2H;
PESO3:= Peso3L+Peso3H;

GRAMOS.ValueStr:= IntToStr(BinToInt(PESO1));
AbDBValueInd1.ValueStr:= IntToStr(BinToInt(PESO2));
AbDBValueInd2.ValueStr:= IntToStr(BinToInt(PESO3));

Comport1.ReadStr(Strcomp2,1);

end;
end;
end;
end.


Responder Con Cita