Mas sempre que eu vou testar o programa dah o seguinte erro quando eu uso a função:
"Project Project1.exe raised exception class EConvertError with message '' "
o problema eh q a mensagem não contem nada, então vou postar o code da função e do botão q ativa a função:
function TransNum(str : String): integer; var leng, x, i, temp, caso, loc, nlp, locint, loctip, locord, vez, total, qtd, t : integer; valores, tipos : array of String; valint, order : array of integer; begin total := 0; leng := Length(str); SetLength(valores, leng); SetLength(valint, leng); SetLength(tipos, leng); SetLength(order, leng); loc := 0; locint := 0; loctip := 0; locord := 0; vez := 0; for i := 0 to leng do begin temp := StrToInt(str[i]); if VarType(temp) = varInteger then begin valores[loc] := valores[loc] + str[i]; order[locord] := 1; locord := locord +1; vez := vez +1; end else begin if str[i] = '*' then begin tipos[loctip] := '*'; loctip := loctip +1; valint[locint] := StrToInt(valores[loc]); locint := locint +1; loc := loc +1; order[locord] := 0; locord := locord +1; vez := vez +1; end else if str[i] = '/' then begin tipos[loctip] := '/'; loctip := loctip +1; valint[locint] := StrToInt(valores[loc]); locint := locint +1; loc := loc +1; order[locord] := 0; locord := locord +1; vez := vez +1; end else if str[i] = '-' then begin tipos[loctip] := '-'; loctip := loctip +1; valint[locint] := StrToInt(valores[loc]); locint := locint +1; loc := loc +1; order[locord] := 0; locord := locord +1; vez := vez +1; end else if str[i] = '+' then begin tipos[loctip] := '+'; loctip := loctip +1; valint[locint] := StrToInt(valores[loc]); locint := locint +1; loc := loc +1; order[locord] := 0; locord := locord +1; vez := vez +1; end end; end; x := 0; nlp := 0; qtd := 0; t := 0; for i := 0 to vez do begin if order[i] = 1 then begin x := x +1; end else if order[i] = 0 then begin if x > 1 then begin if t = 0 then total := valint[nlp]; if tipos[nlp] = '*' then begin total := total * valint[nlp+1]; nlp := nlp +1; end else if tipos[nlp] = '-' then begin total := total - valint[nlp+1]; nlp := nlp +1; end else if tipos[nlp] = '+' then begin total := total + valint[nlp+1]; nlp := nlp +1; end else if tipos[nlp] = '/' then begin total := StrToInt(FloatToStr(StrToFloat(IntToStr(total)) / StrToFloat(IntToStr(valint[nlp+1])))); nlp := nlp +1; end end; end; end; Result := total; end;
Code do botão :
i := conta.Text; result.Caption := IntToStr(TransNum(i));
E aí, como resolvo? ou jah existe algo parecido com a função eval?