Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-02-2017
Avatar de newtron
[newtron] newtron is offline
Membrillo Premium
 
Registrado: abr 2007
Ubicación: Motril, Granada
Posts: 3.461
Poder: 20
newtron Va camino a la fama
Error "Incompatible types" al pasar de Delphi 2007 a Delphi Berlin

Hola a tod@s.

Pasando un pequeño proyecto de Delphi 2007 a Delphi Berlín me encuentro el problema que en una línea me da el error "E2008 Incompatible types" al compilar, imagino que tendrá una solución tonta pero no doy con la tecla.

El código es el siguiente:

Código Delphi [-]
function TAsBarcode.Code_39:string;

type TCode39 =
  record
    c : char;
    data : array[0..9] of char;
    chk: shortint;
  end;

const tabelle_39: array[0..43] of TCode39 = (
  ( c:'0'; data:'505160605'; chk:0 ),
  ( c:'1'; data:'605150506'; chk:1 ),
  ( c:'2'; data:'506150506'; chk:2 ),
  ( c:'3'; data:'606150505'; chk:3 ),
  ( c:'4'; data:'505160506'; chk:4 ),
  ( c:'5'; data:'605160505'; chk:5 ),
  ( c:'6'; data:'506160505'; chk:6 ),
  ( c:'7'; data:'505150606'; chk:7 ),
  ( c:'8'; data:'605150605'; chk:8 ),
  ( c:'9'; data:'506150605'; chk:9 ),
  ( c:'A'; data:'605051506'; chk:10),
  ( c:'B'; data:'506051506'; chk:11),
  ( c:'C'; data:'606051505'; chk:12),
  ( c:'D'; data:'505061506'; chk:13),
  ( c:'E'; data:'605061505'; chk:14),
  ( c:'F'; data:'506061505'; chk:15),
  ( c:'G'; data:'505051606'; chk:16),
  ( c:'H'; data:'605051605'; chk:17),
  ( c:'I'; data:'506051605'; chk:18),
  ( c:'J'; data:'505061605'; chk:19),
  ( c:'K'; data:'605050516'; chk:20),
  ( c:'L'; data:'506050516'; chk:21),
  ( c:'M'; data:'606050515'; chk:22),
  ( c:'N'; data:'505060516'; chk:23),
  ( c:'O'; data:'605060515'; chk:24),
  ( c:'P'; data:'506060515'; chk:25),
  ( c:'Q'; data:'505050616'; chk:26),
  ( c:'R'; data:'605050615'; chk:27),
  ( c:'S'; data:'506050615'; chk:28),
  ( c:'T'; data:'505060615'; chk:29),
  ( c:'U'; data:'615050506'; chk:30),
  ( c:'V'; data:'516050506'; chk:31),
  ( c:'W'; data:'616050505'; chk:32),
  ( c:'X'; data:'515060506'; chk:33),
  ( c:'Y'; data:'615060505'; chk:34),
  ( c:'Z'; data:'516060505'; chk:35),
  ( c:'-'; data:'515050606'; chk:36),
  ( c:'.'; data:'615050605'; chk:37),
  ( c:' '; data:'516050605'; chk:38),
  ( c:'*'; data:'515060605'; chk:0 ),
  ( c:'$'; data:'515151505'; chk:39),
  ( c:'/'; data:'515150515'; chk:40),
  ( c:'+'; data:'515051515'; chk:41),
  ( c:'%'; data:'505151515'; chk:42)
  );


function FindIdx(z:char):integer;
var
  i:integer;
begin
  for i:=0 to High(tabelle_39) do
  begin
    if z = tabelle_39[i].c then
    begin
      result := i;
      exit;
    end;
  end;
  result := -1;
end;

var
  i, idx : integer;
  checksum:integer;

begin
  checksum := 0;
  {Startcode}
  result := tabelle_39[FindIdx('*')].data + '0';   // ------------------------> Línea donde da el error

  for i:=1 to Length(FText) do
  begin
    idx := FindIdx(FText[i]);
    if idx < 0 then
      continue;
    result := result + tabelle_39[idx].data + '0';
    Inc(checksum, tabelle_39[idx].chk);
  end;

  {Calculate Checksum Data}
  if FCheckSum then
    begin
    checksum := checksum mod 43;
    for i:=0 to High(tabelle_39) do
      if checksum = tabelle_39[i].chk then
      begin
        result := result + tabelle_39[i].data + '0';
        break;
      end;
    end;

  {Stopcode}
  result := result + tabelle_39[FindIdx('*')].data;
end;

Si algún amable forero me indica qué tengo que cambiar lo agradeceré.

Gracias y un saludo
__________________
Be water my friend.
Responder Con Cita
  #2  
Antiguo 20-02-2017
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Poder: 15
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Edito: Mi respuesta era incorrecta

Última edición por AgustinOrtu fecha: 20-02-2017 a las 23:53:41.
Responder Con Cita
  #3  
Antiguo 21-02-2017
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Poder: 15
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Solo encontre dos posibilidades:

1. Usar TStringBuilder:

Código Delphi [-]
var
  Builder: TStringBuilder;
  s: string;
  Chars: array [0..9] of Char;
begin
  Chars := 'ClubDelph';
  Builder := TStringBuilder.Create;
  try
    Builder.Append(Chars);
    Builder.Append('i');
    s := Builder.ToString;
  finally
    Builder.Free;
  end;

  Writeln(s);
  Readln;
end.

2. Mas sencillo, usar System.WideCharToString

Código Delphi [-]
begin
  Chars := 'ClubDelph';
  s := WideCharToString(Chars) + 'i';
  Writeln(s);
  Readln;
end.

En algun momento se habran deprecado los array of Char estaticos (hace muchisimo que no veo codigo escrito asi)
Responder Con Cita
  #4  
Antiguo 21-02-2017
Avatar de newtron
[newtron] newtron is offline
Membrillo Premium
 
Registrado: abr 2007
Ubicación: Motril, Granada
Posts: 3.461
Poder: 20
newtron Va camino a la fama
Cita:
Empezado por AgustinOrtu Ver Mensaje
...
2. Mas sencillo, usar System.WideCharToString

Código Delphi [-]begin Chars := 'ClubDelph'; s := WideCharToString(Chars) + 'i'; Writeln(s); Readln; end.


En algun momento se habran deprecado los array of Char estaticos (hace muchisimo que no veo codigo escrito asi)
Estupendo, esto me resuelve el programa.

Gracias y un saludo
__________________
Be water my friend.
Responder Con Cita
  #5  
Antiguo 21-02-2017
Avatar de TOPX
TOPX TOPX is offline
Miembro
 
Registrado: may 2008
Ubicación: Bogotá
Posts: 527
Poder: 16
TOPX Va camino a la fama
En mi ignorancia, lo hubiera hecho así:

Código Delphi [-]
  result := tabelle_39[FindIdx('*')].data;
  result := result + '0';
-
__________________
"constructive mind, destructive thoughts"
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
Error Incompatible Types Bant Varios 3 11-04-2016 08:45:26
Problema: "Falta el elemento Raiz" Delphi 2007 edgar_vife Varios 14 06-05-2015 18:45:21
Error: Incompatible types: got "Pointer" expected elarys OOP 2 06-03-2010 00:53:12
no "context-sensitive help" installed delphi 2007 Gaby123 Varios 2 01-04-2009 19:52:11
Error "Invalid field Type" entre Delphi 2007 y Firebird 1.5 saltamirano Varios 2 24-12-2007 23:38:07


La franja horaria es GMT +2. Ahora son las 06:34:46.


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