Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 25-08-2010
Avatar de julyus
julyus julyus is offline
Miembro
 
Registrado: jul 2006
Ubicación: IN TO PLACES COLOMBIA AND EE.UU
Posts: 121
Poder: 18
julyus Va por buen camino
hola eficsa gracias por tu colaboracion

todavia tengo una duda o un error cunado compilo me sale un error incompatible types extended and string ???
Responder Con Cita
  #2  
Antiguo 25-08-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola julyus.

Con los tipo Variant podes hacer lo siguiente:
Código Delphi [-]
var
  va: Variant;
  ext: Extended;
  str: string;
begin
   ext:= 3.141592654;
   str:= 'Número PI';
   va:= ext; 
   str:= va; 
   ShowMessage(str); 
end;

¿ En que parte del código te salta el error ?

Saludos.
Responder Con Cita
  #3  
Antiguo 25-08-2010
Avatar de julyus
julyus julyus is offline
Miembro
 
Registrado: jul 2006
Ubicación: IN TO PLACES COLOMBIA AND EE.UU
Posts: 121
Poder: 18
julyus Va por buen camino
este es el codigo mas o menos

aqui es donde llamo el array para pasarlo a otro array creo que esta mal
la sintaxis de como hacerlo


Código Delphi [-]
type
    TEventslistArray = array[0..58] of variant;
    TNewArrayData = array[0..58] of variant;

declaracion de la funcion
Código Delphi [-]
 function SearchEvents(sIMEI: string; iCompanyId : integer;  sVehicleId : string;
            iCurrSpeed,iCurrRPM,iAccDeccValue :integer;
            bDIN1, bDIN2, bDIN3, bDIN4 : Boolean;
            fAIN1, fAIN2,  fAIN3, fAIN4 : Extended;
            iGSMSignal, iCurrentProfile : integer;
            fAcelerometerData, fGPSSpeed,  fPowerSuplyVoltage, fBatteryVoltage, fBatteryCurrent,
            fGPSPower, fPCBTemperature, fTempSensor1, fTempSensor2,
            fTempSensor3, fFuelCounter, sButtonInput, fCan0, fCan1,
            fCan2, fCan3, fCan4, fCan5, fCan6, fCan7, fCan8,  fCan9 : Extended;
            bGeoZone1, bGeoZone2, bGeoZone3,
            bGeoZone4, bGeoZone5, bGeoZone6, bGeoZone7,
            bGeoZone8, bGeoZone9, bGeoZone10, bGeoZone11,
            bGeoZone12, bGeoZone13, bGeoZone14, bGeoZone15,
            bGeoZone16, bGeoZone17, bGeoZone18, bGeoZone19, bGeoZone20 : Boolean;
            fVirtualOdometer : Extended; sCurrOperatorCode : string; bMovement : Bool ) :TEventslistArray;

funcion

uso de la funcion aqui es donde me marca el error
Código Delphi [-]

  NewArrayData := SearchEvents(sIMEI, iCompanyId, sVehicleId,
            iCurrSpeed,iCurrRPM,iAccDeccValue,
            bDIN1, bDIN2, bDIN3, bDIN4,
            fAIN1, fAIN2,  fAIN3, fAIN4,
            iGSMSignal, iCurrentProfile ,
            fAcelerometerData, fGPSSpeed,  fPowerSuplyVoltage, fBatteryVoltage, fBatteryCurrent,
            fGPSPower, fPCBTemperature, fTempSensor1, fTempSensor2,
            fTempSensor3, fFuelCounter, sButtonInput, fCan0, fCan1,
            fCan2, fCan3, fCan4, fCan5, fCan6, fCan7, fCan8,  fCan9,
            bGeoZone1, bGeoZone2, bGeoZone3,
            bGeoZone4, bGeoZone5, bGeoZone6, bGeoZone7,
            bGeoZone8, bGeoZone9, bGeoZone10, bGeoZone11,
            bGeoZone12, bGeoZone13, bGeoZone14, bGeoZone15,
            bGeoZone16, bGeoZone17, bGeoZone18, bGeoZone19, bGeoZone20,
            fVirtualOdometer, sCurrOperatorCode, bMovement);

la funcion no esta terminada lo que quiero de esta funcion es que me ingrese unos datos y si hay unos casos cumplidos me genere un array con
el registro primero ingresado y luego los casos cunplidos me generelos unos
nuevos rows repetidos solo con los casos cumplidos afectaran unas variables y generaran un nuevo row

ejemplo

a,b,c insert row en el array

entran a b y c
si c = 0 se evaluan
si c= o tonces escribe a,b y c= '123' en el array
fin

si c= 1
si c= o tonces escribe a,b y c= '321' en el array a regresar

alfinal

deben quedarme 3 rows
1 original
2 cambiado
3 cambiado

fin de la funcion


Código Delphi [-]
function TFMListenerService.SearchEvents(sIMEI: string; iCompanyId : integer;  sVehicleId : string;
            iCurrSpeed,iCurrRPM,iAccDeccValue :integer;
            bDIN1, bDIN2, bDIN3, bDIN4 : Boolean;
            fAIN1, fAIN2,  fAIN3, fAIN4 : string;
            iGSMSignal, iCurrentProfile : integer;
            fAcelerometerData, fGPSSpeed,  fPowerSuplyVoltage, fBatteryVoltage, fBatteryCurrent,
            fGPSPower, fPCBTemperature, fTempSensor1, fTempSensor2,
            fTempSensor3, fFuelCounter, sButtonInput, fCan0, fCan1,
            fCan2, fCan3, fCan4, fCan5, fCan6, fCan7, fCan8,  fCan9 : string;
            bGeoZone1, bGeoZone2, bGeoZone3,
            bGeoZone4, bGeoZone5, bGeoZone6, bGeoZone7,
            bGeoZone8, bGeoZone9, bGeoZone10, bGeoZone11,
            bGeoZone12, bGeoZone13, bGeoZone14, bGeoZone15,
            bGeoZone16, bGeoZone17, bGeoZone18, bGeoZone19, bGeoZone20 : Boolean;
            fVirtualOdometer : string; sCurrOperatorCode : string; bMovement : Bool ) :TEventslistArray;
var
count : integer;
Conn: IConnection;
sqlQuery : TADOQuery;
ADOSP: TADOStoredProc;
EvenType : string;
EvenCode  : integer;
begin




  // consulto datos
  if iCurrSpeed then
  begin

  //ejecuto el storeprocedure
  ADOSP.Connection := Conn; // paso el string de conexion
  ADOSP.ProcedureName := 'GetOverSpeed'; // pongo el nombre del SP que voy a utilizar
  ADOSP.Parameters.Refresh; // creo los parametros que espera el SP
  ADOSP.Parameters.ParamByName('@CompanyId').Value  := iCompanyId;
  ADOSP.Parameters.ParamByName('@CarNumber').Value  := sVehicleId;
  ADOSP.Parameters.ParamByName('@Speed').Value  := iCurrSpeed;
  ADOSP.Parameters.ParamByName('@EventType').Direction := EvenType;
  ADOSP.Parameters.ParamByName('@EventCode').Direction :=  EvenCode;


  end;
  ADOSP.Close;
  ADOSP.Free;
  //asigno a el arreglo


  ADOSP.Connection := Conn; // paso el string de conexion
  ADOSP.ProcedureName := 'GetOverRpm'; // pongo el nombre del SP que voy a utilizar
  ADOSP.Parameters.Refresh; // creo los parametros que espera el SP
  ADOSP.Parameters.ParamByName('@CompanyId').Value  := iCompanyId;
  ADOSP.Parameters.ParamByName('@CarNumber').Value  := sVehicleId;
  ADOSP.Parameters.ParamByName('@Factor').Value  := iCurrSpeed;
  ADOSP.Parameters.ParamByName('@EventType').Direction := EvenType;
  ADOSP.Parameters.ParamByName('@EventCode').Direction := EvenCode;
  //consuto datos


  if iCurrRPM   then
  begin

  end;
  //asigno a el arreglo


  ADOSP.Connection := Conn; // paso el string de conexion
  ADOSP.ProcedureName := 'GetOverSpeed'; // pongo el nombre del SP que voy a utilizar
  ADOSP.Parameters.Refresh; // creo los parametros que espera el SP
  ADOSP.Parameters.ParamByName('@CompanyId').Value  := iCompanyId;
  ADOSP.Parameters.ParamByName('@CarNumber').Value  := sVehicleId;
  ADOSP.Parameters.ParamByName('@AccelDecel').Value  := iCurrSpeed;
  ADOSP.Parameters.ParamByName('@EventType').Direction := EvenType;
  ADOSP.Parameters.ParamByName('@EventCode').Direction :=  EvenCode;
  //consulto
  if iAccDeccValue then
  begin

  end;
  //asigno a el arreglo


end;
Responder Con Cita
  #4  
Antiguo 25-08-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola julyus.

Claro, por que estás intentando asignar una funcion a un array of variant:
Cita:
NewArrayData := SearchEvents(...
Tendrías que declarar un puntero a método de este modo:
Código Delphi [-]
type
 TListArray = array[0..58] of Variant;
 TFuncionPtr = function (sIMEI: string; iCompanyId : integer;  sVehicleId : string;
            iCurrSpeed,iCurrRPM,iAccDeccValue :integer;
            bDIN1, bDIN2, bDIN3, bDIN4 : Boolean;
            fAIN1, fAIN2,  fAIN3, fAIN4 : string;
            iGSMSignal, iCurrentProfile : integer;
            fAcelerometerData, fGPSSpeed,  fPowerSuplyVoltage, fBatteryVoltage, fBatteryCurrent,
            fGPSPower, fPCBTemperature, fTempSensor1, fTempSensor2,
            fTempSensor3, fFuelCounter, sButtonInput, fCan0, fCan1,
            fCan2, fCan3, fCan4, fCan5, fCan6, fCan7, fCan8,  fCan9 : string;
            bGeoZone1, bGeoZone2, bGeoZone3,
            bGeoZone4, bGeoZone5, bGeoZone6, bGeoZone7,
            bGeoZone8, bGeoZone9, bGeoZone10, bGeoZone11,
            bGeoZone12, bGeoZone13, bGeoZone14, bGeoZone15,
            bGeoZone16, bGeoZone17, bGeoZone18, bGeoZone19, bGeoZone20 : Boolean;
            fVirtualOdometer : string; sCurrOperatorCode :
            string; bMovement : Bool ) :TListArray  of object;
 TForm1: class(TForm)   
 public
    FuncionPtr : TFuncionPtr;
    ...
 private
   ...
 end; 

...

Entonces la asignación sería:
Código Delphi [-]
   FuncionPtr := SearchEvents(...


Saludos.

Última edición por ecfisa fecha: 25-08-2010 a las 22:02:52.
Responder Con Cita
  #5  
Antiguo 27-08-2010
Avatar de julyus
julyus julyus is offline
Miembro
 
Registrado: jul 2006
Ubicación: IN TO PLACES COLOMBIA AND EE.UU
Posts: 121
Poder: 18
julyus Va por buen camino
Talking segunda pregunta

eficsa gracias por tu explicacion me ayudo mucho el tema y un poco de ver codigo basico

ahora tengo otra pregunta cree dentro de esta funcion que retorna un array tipo variant otro array para irle asignando unos valores en los campos
mi pregunta es el array ListArray es igual de tipo variant no se si debo crearlo asi
i:interger
i = 0;
....
ListArray[i] := valor;
i := i +1

para ir incrementado la posicion que solo tiene un valor

ver parte del código

Código Delphi [-]
function TFMListenerService.GetEventCodeArray(cIOElement : TIOElement): TArrayList;
var
i:integer;
ADOSP : TADOStoredProc;
Conn: Iconnection;
sVehicleId, iCompanyId : string;
Factor, AccelDecel, iCurrSpeed : double;
ListArray : TArrayList; //para ir acumulando  listado array que de sebe regresar de la funcion
begin

  //rrecorrido de eventos
  //try
     if (cIOElement.ElementEvent.iEventIOId = 0) then  //No hay evento significativo
      begin

        // Se verifica Conexion Desconexion
         if cIOElement.ElementValue(66) >= 6000 then
         begin
             ListArray[i] := 24;//System Connect.

         end
         else
         Begin
             ListArray[i] := 25; //System Disconnect.

         end;
        //----------------------------------------------------------------------

        //Se verifica si hay evento de Boton de Panico

        if cIOElement.ElementValue(1) =1 then
        begin
            ListArray[i] := 31 // Alert Button

        end;
        //----------------------------------------------------------------------


        //Se debe verificar si el vehiculo está encendido.
        if cIOElement.ElementValue(10) >= 2000 then

        begin
          if cIOElement.ElementValue(240) = 0 then //Si no está en movimiento
            ListArray[i] := 3 //Time Passed
          else
            ListArray[i] := 4; //Distance Passed
         end;
         //----------------------------------------------------------------------

         //iCurrSpeed := cIOElement.ElementEvent.aElements[0];
         //----------------------------------------------------------------------
         //
         try
         Conn := ConnPool.GetConnection;
         //ejecuto el storeprocedure
         ADOSP.Connection := Conn.Connection; // paso el string de conexion
         ADOSP.ProcedureName := 'GetOverRpm'; // pongo el nombre del SP que voy a utilizar
         ADOSP.Parameters.Refresh; // creo los parametros que espera el SP
         ADOSP.Parameters.ParamByName('@CompanyId').Value  := iCompanyId;
         ADOSP.Parameters.ParamByName('@CarNumber').Value  := sVehicleId;
         ADOSP.Parameters.ParamByName('@Factor').Value  := Factor;
         ADOSP.Parameters.ParamByName('@EventType').Direction := pdInputOutput;
         ADOSP.Parameters.ParamByName('@EventCode').Direction :=  pdInputOutput;
         ADOSP.Open;
         factor:= pdInputOutput[0];

         finally
         ADOSP.Close;
         ADOSP.Free;
         end;
        //asigno a el arreglo

        if cIOElement.ElementValue(11) = 0 then //Si no está en movimiento
         begin
           ListArray[i] := 21 //OverRpm

          //----------------------------------------------------------------------
         end;
       Result:= ListArray;
Responder Con Cita
  #6  
Antiguo 27-08-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Thumbs up

Hola Julyus.

Si, es correcto. Funciona como cualquier array; te vas desplazando por él incrementando o decrementando el subíndce.

Ya sea utilizando una variable tipo contador, como pusiste en el post:
Código Delphi [-]
   i:= 0;
   ListArray[i] := valor; 
   i := i +1

O con el uso de for:
Código Delphi [-]
   for i:= 0 to ...
    ListArray[i]:= valor;

Eso depende de como estructures el código.

Saludos.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Cosulta de BDF no regresa nada eduardo_2009 Tablas planas 3 21-08-2007 15:00:49
??que regresa un query?? david duarte Tablas planas 5 22-05-2006 17:04:53
Funcion SUM me regresa una cadena paty_rlopez Firebird e Interbase 6 18-04-2006 15:13:10
SQLClientDataSet no regresa lo esperado EITB OOP 2 27-09-2004 18:45:25
Como devuelvo un Arreglo en Función Prophoenix Varios 1 30-05-2003 19:40:58


La franja horaria es GMT +2. Ahora son las 22:38:58.


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