05-08-2020 12:16 AM
Hola, estoy intentando algo similar, mediante un replace array subset pero en un arreglo boleano. La idea es que funcione como un disparo, le doy la coordenada, disparo y se enciende un led, pero tengo un problema quiero que ese led permanezca encendido hasta el siguiente disparo, si disparo una a una todas las casillas debería mantenerse el estado anterior, les adjunto foto del código para el programa, arriba tengo la entrada de un arreglo boleano. Agradezco sus sugerencias y ayuda
05-08-2020 01:22 AM - edited 05-08-2020 01:27 AM
Keep the 2D array in a shift register anchored on the while loop.
(Also, the terminal of the OK button belongs inside its event case. You know the number of iterations before the loop starts, so it should be a FOR loop. Of course it would be better to have a state machine instead of stopping the VI at the end, so a while loop is better for that. Where is the terminal belonging to the local variable? Feel free tho attach the VI. we cannot efficiently debug pictures.)
05-08-2020 01:51 AM
05-08-2020 09:50 AM
@AntoineP wrote:
You cannot replace an element of an array if that element does not exist.
For exemple trying to replace element on the 4th row and 1st column of a 3x3 array will result in the same array as output
====>>>>
Message Edited by AntoineP on 10-09-2008 02:22 PM
That's why I created this.
05-08-2020 10:29 AM
Thanks Paul. I am going to add that to my secret stash of super-usable vis!
05-08-2020 11:30 AM - edited 05-08-2020 12:02 PM
@paul_cardinale wrote:
That's why I created this.
I am sure it can be simplified dramatically. 😉
(It could even be expanded to work with arrays of any dimensions. Not shown)
(Sorry, I attached wrong code earlier. Disregard that. Please verify correct operation)
05-08-2020 11:36 AM
Gracias por la respuesta, bueno, estoy esforzándome por entender muchos conceptos, eso se trata de un juego de batalla naval, inicialmente estoy generando los barcos de 5,4 y 3 bits aleatoriamente, sin que se crucen, con algunos problemas cuando cambian de sentido, ese arreglo final quiero compararlo con uno que genere el usuario con esos disparos, te adjunto mi programa y agradezco todas las sugerencias, tengo mucho por aprender. Gracias, por ahora me sale un aviso que el tipo de archivo (.vi) no se admite, no puedo adjuntártelo
05-08-2020 11:38 AM
You did not attach anything yet.
05-13-2020 12:29 PM
@altenbach wrote:
@paul_cardinale wrote:
That's why I created this.I am sure it can be simplified dramatically. 😉
(It could even be expanded to work with arrays of any dimensions. Not shown)
(Sorry, I attached wrong code earlier. Disregard that. Please verify correct operation)
Here's the whole set, with your improvements.
11-10-2020 03:37 PM
You technically can't as labview enforces that the other columns be of the same size so you have to put your value into that column and pad the rest with zeros. You can then replace those zeros later if you keep track of where they are with a shift register or array.