Forum > Spanish

¿Como transladar a un TMemo, el resultado paso a paso de operaciones.....?

(1/2) > >>

mav:
Lo del enunciado ¿Como transladar a un TMemo, el resultado paso a paso de operaciones diversas y la complejidad de format (para mi,claro)?..una
especie de debug...


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---.......   nombre               : String;   i,temp, final, total: integer;....... //------------------------------------------------------Operaciones     for i:= 1 to Length(nombre) do      begin       temp := temp+ord(nombre[i]);      end;     final:= temp + $2D;      total:= (((final xor $4569) xor $FFF) xor $989A);       //'%' [[Index]':'] ['-'] [Width] ['.' Precision] ArgType        Memo1.Append(       IntToStr(i)        + Format(????????????????????????????                ?????????? [temp, final,total])) ;    ............................                             Saludos  :) :)

Edson:
Si lo que quieres es mostrar el contenido de 4 enteros en un TMemo, puedes usar la forma clásica de Pascal:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Memo1.Append( IntToStr(i)+','+IntToStr(temp)+','+IntToStr(final)+','+IntToStr(total) ); 
O sino, al estilo de C:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Memo1.Append( Format('%d, %d, %d, %d', [i,temp, final, total]) ); 
Pero si lo que quieres es solo mostrar algo para depuración, mejor no uses TMemo y usa las funciones debugln(), que te muestran el resultado en la consola:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  debugln('%d, %d, %d, %d', [i,temp, final, total]); 
Para ello tienes que incluir la unidad LCLproc y habilitar la consola,en tu aplicación.

lucamar:
Otra forma de añadir variables formateadas a un memo:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Memo1.Lines.Add('%d %d %d %d', [i, temp, final, total]);con las misma sintaxis de Format().

Eso, claro, es usando el formato más "simple" posible; también podría ser, por ejemplo:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Memo1.Lines.Add('i=%d, temp=%d, final=%d, total=%d', [i, temp, final, total]);
Si quieres algo más, tendrás que decirnos qué formato estás buscando. ;)

mav:
...lo que estoy buscando (culpa tuya, Lucamar ;) ;) ;)) es ir mostrando en el memo los resultados paso a paso de las operaciones efectuadas...
 la suma de cada caracter del nombre con el siguiente y resultado..la suma posterior del $2D y resultado...el 1º xor y resultado...el 2º etc..etc
 cada uno de ellos en una linea del Memo...¡Complicandome siempre! :) :) :)
..Muchas gracias .
Saludos

lucamar:
¿Algo así como ... ?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var   nombre               : String;   i,temp, final, total: integer;   sv: String;   //------------------------------------------------------Operaciones  for i:= 1 to Length(nombre) do  begin   sv := IntToStr(temp);   temp := temp+ord(nombre[i]);   Memo.Lines.Add('Paso %d: %s + %d = %d',                  [i, sv, ord(nombre[i]), temp]);  end;  final:= temp + $2D;  Memo.Lines.Add('Paso final: %d + $2D = %d',                 [temp, final]);   { Un sólo paso, pero si quieres cada uno por separado sólo tienes    que ir calculando "total" a partir del anterior y añadiendo una línea }  total:= (((final xor $4569) xor $FFF) xor $989A);  Memo.Lines.Add('Total: (((%x xor $4569) xor $FFF) xor $989A) = %d',                 [temp, final]);

Navigation

[0] Message Index

[#] Next page

Go to full version