Ver Mensaje Individual
  #1  
Antiguo 08-09-2006
Avatar de Estefania
Estefania Estefania is offline
Registrado
 
Registrado: may 2006
Posts: 2
Reputación: 0
Estefania Va por buen camino
Question ¿Como converitr dato del puerto a decimal?

Hola, necesito que me ayuden a solucionar este problema, tengo un programa que levanta datos desde el puerto com1 y por medio de la siguiente funcion me convierte el dato a un valor string, pero yo kiero convertirlo a decimal en vez de a string, como lo puedo hacer?? aca les dejo el procedimiento que esta funcionando en mi programa, si me escriben la parte de codigo que necesito insertar en este procedimiento me seria de mucha ayuda. Aqui el procedimiento:

Código Delphi [-]
procedure TMainForm.cpDrvReceiveData(Sender: TObject;
 DataPtr: Pointer; DataSize: Cardinal);
var
  i : integer;
  s : string;
begin
  // Convert incoming data into a string
  s := StringOfChar( ' ', DataSize );
  move( DataPtr^, pchar(s)^, DataSize );
  S := Trim(s) + #13 ;
  // Exit if s is empty. This usually occurs when one or more NULL characters
  // (chr(0)) are received.
  while pos( #0, s ) > 0 do
    delete( s, pos( #0, s ), 1 );
  if s = '' then exit;
  // Remove line feeds
  i := pos( #10, s );
  while i <> 0 do
  begin
    delete( s, i, 1 );
    i := pos( #10, s );
  end;
  // Process the buffer line by line. This breaks the buffer block into discreet lines.
  // If you want to act upon individual ID's and data, do it in ProcessReceivedLine routine.
  i := pos( #13, s );
  while i <> 0 do
  begin
    ProcessReceivedLine(Copy(s,1,i)) ; // Process the line
    delete( s, 1, i ); // then delete it.
    i := pos( #13, s );
  end;
end;

Ayuda pro favor!!!

Última edición por dec fecha: 08-09-2006 a las 20:44:01.
Responder Con Cita