Ver Mensaje Individual
  #6  
Antiguo 13-02-2008
Avatar de ixMike
ixMike ixMike is offline
Miembro
 
Registrado: feb 2004
Posts: 1.151
Reputación: 22
ixMike Va por buen camino
ok, ya se entiende

Prueba con algo así:

Código Delphi [-]
var //variables globales
  codigo: array[1..14] of char;
//nota: así podrás usar la variable como un string.

procedure Incrementar(pos: integer);
begin
if (codigo[pos] in ['0'..'8']) or (codigo[pos] in ['A'..'Y']) then codigo[pos]:=Ord(codigo[pos]+1) else
if codigo[pos]='9' then
  begin
  codigo[pos]:='0';
  incrementar(pos-1);
  end
else if codigo[pos]='Z' then
  begin
  codigo[pos]:='A';
  incrementar(pos-1);
  end;
end;


Nótese que tú sólo tendrás que llamar a la función con el parámetro 14 (el último caracter). Lo del parámetro es para la recursividad, y así optimizar el código.

Espero que te sirva.



Salu2.


Edito: tenía un "bug" donde la fución Ord. Solucionado (gracias Delphius por probarlo).

Última edición por ixMike fecha: 15-02-2008 a las 20:18:54.
Responder Con Cita