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 24-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
Question funcion que me regresa un arreglo

hola amigo hace 3 años no programo en delphi algunas cosas las he olvidado quiero crear una function que me regrese un array

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



Código Delphi [-]
function TFMListenerService.SearchEvents( NewEventlistArray: TEventslistArray);
var
count : integer;
begin
end;

mi pregunta es que tengo que enviarle 25 parametros a esta funcion para evaluarlos dentro de esta debo nombrar los 25 parametro y sus tipos de campo diciendo que NewEventlistArray me devolvera mi arreglo ya evaluado??

asi??

Código Delphi [-]
function TFMListenerService.SearchEvents(a : integer,b : string ,d... NewEventlistArray: TEventslistArray);
var
count : integer;
begin
end;

gracias si alguien me explica
Responder Con Cita
  #2  
Antiguo 24-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.

Primero te comento que las funciones declaradas así:
Código Delphi [-]
function TFMListenerService.SearchEvents( NewEventlistArray: TEventslistArray);
te van a dar error de sintáxis. Tendrías que declararlas así:
Código Delphi [-]
function TFMListenerService.SearchEvents( NewEventlistArray: TEventslistArray): Resultado;

Ahora, si lo que enviás es un arreglo de strings y la función devuelve el mismo arreglo modificado, me parece,
que te conviene usar TStrings.

Por ejemplo esta función te devuelve los strings sin el primer caracter:
Código Delphi [-]
function TForm1.FuncionDemo(Lista: TStrings): TStrings;
var
  i: Integer;
begin
  for i:= 0 to Lista.Count - 1 do
   Lista[i]:= Copy(Lista[i],2,Length(Lista[i]));
  Result:= Lista;
end;

Un ejemplo de llamada:
Código Delphi [-]
var
  Ts: TStrings;
begin
  Ts:= TStringList.Create;
  try
    Ts.Add('Uno');    
    Ts.Add('Dos');
    Ts.Add('Tres'); 
    Ts:= FuncionDemo(Ts);
    ListBox1.Items:= Ts;
  finally
    Ts.Free;
  end;

Espero que sea eso lo que andas buscando...

Saludos.

Última edición por ecfisa fecha: 24-08-2010 a las 01:42:18.
Responder Con Cita
  #3  
Antiguo 24-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
confused ??

no se si te entendi bien
Código Delphi [-]type TEventslistArray = array[0..58] of string; 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 : string; sCurrOperatorCode : Extended; bMovement : Bool ) :TEventslistArray;


nose si mi :TEventslistArray; devolvera mi arreglo ??
esto es un web service por eso no lo he probado en forms no se si funciones la otra duda es si tipo los campos se genere algun problema gracias...
Responder Con Cita
  #4  
Antiguo 24-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
confused ??

no se si te entendi bien
Código Delphi [-]
Código Delphi type     TEventslistArray = array[0..58] of string;



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 : string; sCurrOperatorCode : Extended; bMovement : Bool ) :TEventslistArray; [-]
[-][/delphi]


nose si mi :TEventslistArray; devolvera mi arreglo ??
esto es un web service por eso no lo he probado en forms no se si funciones la otra duda es si tipo los campos se genere algun problema gracias...
Responder Con Cita
  #5  
Antiguo 24-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.

Si la función SearchEvents la declaraste para que devuelva un TEventslistArray y dentro de ella
asignas a la variable Result un TEventsListArray, te va a devolver eso sin duda alguna.

Si no comprendí bién tu duda, por favor hacemelo saber.

Saludos.

Última edición por ecfisa fecha: 24-08-2010 a las 19:43:09.
Responder Con Cita
  #6  
Antiguo 24-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
Exclamation hola amigo por la ayuda

la duda que me queda es si miras los campos que envio tienen tipo, el
array es de tipo string esto me daria errores?
ahora lo que quiero es lo siguiente NewArrayData es un array que va a recibir los resultados de SearchEvents el resultado del array lo voy a pasar a este para hacer un ulitimo proceso
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); gracias por tu tiempo
Responder Con Cita
  #7  
Antiguo 24-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
No tenés nada que agradecer.

A ver si con esto solucionamos algo...
Código Delphi [-]
type
  RecSearchEvents = record
    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 : string;
    sCurrOperatorCode : Extended;
    bMovement : Bool
  end;
  TForm1 = class(TForm)
  private
  public
    function SearchEvents(Param: RecSearchEvents): RecSearchEvents;
  end;


var
  Form1: TForm1;

implementation {$R *.dfm}

function TForm1.SearchEvents(Param: RecSearchEvents): RecSearchEvents;
begin
   // Operaciones de la funcion
  Result:= Param;
end;

En este caso pasas y recibis un RecSearchEvents. (o el nombre que quieras darle)
Tenés que cargar los valores en el record antes de llamar a la función por ej:
Código Delphi [-]
var
  rs:RecSearchEvents;
begin
  rs.sIMEI:= '1934102937340';
  rs.iCompanyID:= 11234; 
  ...
  rs:= SearchEvents(rs); // rs, ahora tiene los valores procesados en la función
end;

Nota: No es necesario, pero al ser tantos campos para una mayor claridad quizá te convenga
declarar el registro así:
Código Delphi [-]
  RecSearchEvents = record
    sIMEI: string;
    iCompanyId : integer;
    sVehicleId : string;
    iCurrSpeed, iCurrRPM, iAccDeccValue :integer;
    bDIN: array[1..4] of Boolean;
    bAIN: array[1..4] of Extended;
    iGSMSignal, iCurrentProfile : integer;
    fAcelerometerData, fGPSSpeed,  fPowerSuplyVoltage,
    fBatteryVoltage, fBatteryCurrent, fGPSPower, fPCBTemperature,
    fTempSensor1, fTempSensor2, fTempSensor3, fFuelCounter,
    sButtonInput: Extended;
    fCan: array[0..9] of Extended;
    bGeoZone: array[1..20] of Boolean;
    fVirtualOdometer : string;
    sCurrOperatorCode : Extended;
    bMovement : Bool
  end;

Es mas o ménos lo que buscabas ?

Saludos.

Última edición por ecfisa fecha: 24-08-2010 a las 21:42:37.
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 09:14:11.


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