danielmj
09-01-2015, 13:26:46
Hola, es mi primera aplicacion para android, se trata de un generador de claves pero me da error (adjunto capturas) por otra parte el código es este:
Función generar clave
function RandomPassword(PLen: Integer): string;
var
str: string;
begin
Randomize;
//string with all possible chars
case form1.cmbTipo.index of
0: begin
str := num;
end;
1: begin
str := letras;
end;
2: begin
str := num+letras;
end;
3: begin
str := sim;
end;
end;
Result := '';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PLen)
end;
Código del botón encargado de lanzar la función
procedure TForm1.GenClick(Sender: TObject);
begin
valor:= 1; //-----> variable global de tipo byte
memo.Text:= '';
begin
if opc1.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(opc1.Text)));
end;
if opc2.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(opc2.text)));
end;
if opc3.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(opc3.text)));
end;
if opc4.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(cmbTipo.Items.Text)));
end;
end;
gen.Enabled:= false;
end;
Y esta la captura del error:
http://i60.tinypic.com/ic61pi.jpg
Si pulso sobre "Break", me marca esta línea que está dentro de la función:
http://i59.tinypic.com/vp8f4g.jpg
Y esta la captura del movil:
http://i58.tinypic.com/2vctdok.png
Lo que si he observado es que si cambio el tipo de la variable "valor" de byte a integer, delphi no muestra ningún mensaje de error aunque si el movil, no sé si servirá de algo este dato. ¿Alguien puede sugerirme algo?
Gracias y un saludo.
Función generar clave
function RandomPassword(PLen: Integer): string;
var
str: string;
begin
Randomize;
//string with all possible chars
case form1.cmbTipo.index of
0: begin
str := num;
end;
1: begin
str := letras;
end;
2: begin
str := num+letras;
end;
3: begin
str := sim;
end;
end;
Result := '';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PLen)
end;
Código del botón encargado de lanzar la función
procedure TForm1.GenClick(Sender: TObject);
begin
valor:= 1; //-----> variable global de tipo byte
memo.Text:= '';
begin
if opc1.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(opc1.Text)));
end;
if opc2.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(opc2.text)));
end;
if opc3.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(opc3.text)));
end;
if opc4.IsChecked = true then
begin
memo.Lines.Add(RandomPassword(strToInt(cmbTipo.Items.Text)));
end;
end;
gen.Enabled:= false;
end;
Y esta la captura del error:
http://i60.tinypic.com/ic61pi.jpg
Si pulso sobre "Break", me marca esta línea que está dentro de la función:
http://i59.tinypic.com/vp8f4g.jpg
Y esta la captura del movil:
http://i58.tinypic.com/2vctdok.png
Lo que si he observado es que si cambio el tipo de la variable "valor" de byte a integer, delphi no muestra ningún mensaje de error aunque si el movil, no sé si servirá de algo este dato. ¿Alguien puede sugerirme algo?
Gracias y un saludo.