Pregunta: | 36979 - PONER ARRAYS A VALOR CERO |
Autor: | EDU TROLO |
HE HECHO UN PROGRAMA DONDE HE USADO GRAN CANTIDAD DE ARRAYS PERO DESPUES DE UN PROCESO ESTOS ACUMULAN VALORES PARA REALIZAR UN SEGUNDO PROCESO NECESITO PONER LOS ARRAYS A VALOR CERO DE UNA MANERA FACILA Y NO SE COMO HACERLO EN FOX PRO ESTO ES FACIL. GRACIAS POR ANTICIPADO POR LA RESPUESTA. |
Respuesta: | Roberto Garcia Garcia |
Para iniciarlizar o reincializar arreglos no hay nada mejor que fillchar
fillchar(variable,tamaño de la varaible,valor); por ejemplo arreglo:array [1..100] of integer; begin fillchar(arreglo,sizeof(arreglo),0); end. inicializa el arreglo "arreglo" con ceros. sizeof es una funcion que devuelve el tamaño en bytes de la variable pasada como argumento. por ejemplo var i:byte begin write(sizeof(i); end. tendra como salida 1 |
Respuesta: | Marcelo Limori |
Si entiendo lo que querés decir, esto sería algo como sigue:
. . . const menor=1; mayor=100; type arrchar=array[menor..mayor] of char; . . . procedure limpiar_arreglo(var a:arrchar); var indice:integer; begin for indice:= menor to mayor do a[indice]:=''; end; Donde "arrchar" sería el tipo de arreglo que hayas definido. "Menor" y "mayor" son el menor y el mayor índice de tu arreglo. Espero te sirva de ayuda. Saludos y buenas compiladas. |