Ver Mensaje Individual
  #5  
Antiguo 06-04-2009
clavijo83 clavijo83 is offline
Registrado
 
Registrado: abr 2009
Posts: 8
Reputación: 0
clavijo83 Va por buen camino
hola federico bueno la verdad ya me funciono ya retorna un valor la funcion llebanda, la funcion quedo asi:

Código Delphi [-]
function leebanda:PChar;stdcall;
var
  sTmp:String;
  PCharString: array[0..255] of Char;
  c1,rebut: integer;
  chBuffer: array[0..150] of char;
  NumberOfBytesRead: dword;
begin
//abro el puerto
  AbrirPuerto('COM1','1200','E','7','1');
//mensaje de solicitud de lectura
  banda;
repeat
  rebut:=0;
    repeat
      if ComFile=INVALID_HANDLE_VALUE then
        Exit;
        if not ReadFile(ComFile, chBuffer[rebut],1, NumberOfBytesRead, nil) then
          raise Exception.Create('Imposible leer datos desde el puerto');
          for c1:= 0 to NumberOfBytesRead - 1 do
          sTmp:= sTmp+chBuffer[c1];
    until rebut<100 ;
      if chBuffer[rebut]=chr(04) then
      begin
        CerrarPuerto;
        //libero memoria
        SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF);
        break;
      end;
until rebut=100;

sTmp:=Trim(sTmp);
sTmp:=copy(sTmp,7,(length(sTmp)-9));
Result := StrPCopy(PCharString, sTmp);
end;

pero ahora hay un problema en el codigo de visual:

Código:
Private Sub boton_leer_banda_Click()
    Dim txt As String
    Dim token As String
    Dim msj As String
    ' Se llama a la función del VPOS para leer la banda de tarjetas de créditos y débitos
    retorno = leebanda
    ' Se obtiene el valor del string que retorna la función del VPOS
    ' este string posee los valores de los tracks de la tarjeta a la cual se le leyo la banda
    'x = retorno
    retorno = GetToken(retorno, ";") '& vbCrLf
    Do
        token = GetToken("", ";")
        If token = "" Then Exit Do
        retorno = retorno  '& vbCrLf
        txt = token
    Loop
        ' Se asigna en la box de texto el valor de los diferentes tracks
        If retorno <> "" Then
            var = InStr(1, retorno, "?")
            msj = Mid(retorno, 2, var - 2) 'AQUI APARECE EL ERROR
            txt_track1.Text = msj
        Else
            txt_track1.Text = ""
        End If
        If txt <> "" Then
            var = InStr(1, txt, "?")
            msj = Mid(txt, 1, var - 2)
            txt_track2.Text = msj
        Else
            txt_track2.Text = ""
        End If
End Sub
me sale el siguiente error: ERROR '5' EN TIEMPO DE EJECUCION. LLAMADA A PROCEDIMIENTO O ARGUMENTO NO VALIDO.
Responder Con Cita