cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing 3d Array

Harthion
Member

Indexing 3d Array

Message contains an attachment

I have all the ASCII characters read from a binary file I already populated. My next step is a user being able to type out a string and each letter (a page in the 3d array) showing up in order that it was typed in and than can be cycled through. An example is a user types out BEN this will produce 3 pages from the 3d 5x7 matrix that are in order of the capital ascii characters.

9 REPLIES 9
altenbach
Knight of NI

Re: Indexing 3d Array

I would start with a few basic tutorials to eliminate all the race conditions and greedy loops.

Harthion
Member

Re: Indexing 3d Array

Where would I find these tutorials and do they cost money?

altenbach
Knight of NI

Re: Indexing 3d Array

Check the learning resources at the top of the forum.

 

(I am currently at a conference and will look at your code later.)

Kyle97330
Trusted Enthusiast

Re: Indexing 3d Array

Message contains a hyperlink

For a tutorial on race conditions I would recommend this short 12 minute video:

https://www.youtube.com/watch?v=9T1pqnGt9kU

 

The solution they show, using a FGV, is one of the (but not the only!) solutions to fix race conditions.

 

The whole channel is basically abandoned (last video made 8 years ago) but they did a pretty good job explaining things well in short videos and the content still holds up.

altenbach
Knight of NI

Re: Indexing 3d Array

Instead of a 3D array, create a 1D array of clusters, each containing a 2D array of booleans. Much easier to manage.

 

altenbach
Knight of NI

Re: Indexing 3d Array

Message contains a hyperlink Message contains an image

Here's one possibility. You can easily change the LEDs in each cluster to an 2D array of 24 booleans (e.g. 5x8)

 

 

10digit7Segment.png

altenbach
Knight of NI

Re: Indexing 3d Array

Message contains an image Message contains an attachment

You failed to attach your display-copy.txt (or similar) file. Once you have th2 3D array, you can just index into it.

 

Here's a highly simplified version that has a 3D array with just numbers corresponding to the plane index.

 

altenbach_0-1718333859952.png

 

Harthion
Member

Re: Indexing 3d Array

Message contains an attachment

Thank you altenbach and Kyle97330 for your advice and help. I finally figured it out by using a for loop inside a for loop (definitely not the most efficient way but the string will not go past 8 characters leading to no worry with efficiency). If I were redoing this vi I would most likely use the 1d array of clusters containing the 2d arrays as recommended by altenbach. Also, the Display - Copy.txt file is just a binary file containing the cluster of the matrix and the character array connected to the individual 2d matrix that I wrote to a binary file in the original vi. I will attach here incase anyone stumbles upon this discussion. The point of the attached vi is you write any string and it populates the matrix with the pages of the characters that were inputted that you can then tab through.

 

I also add a blank character at the last index for the character matrix as I forgot to add when inputting them in the original vi I attached.

 

If you have a more efficient way I would love to see as I am interested in what I could do better.

altenbach
Knight of NI

Re: Indexing 3d Array


@Harthion wrote:

Thank you altenbach and Kyle97330 for your advice and help. I finally figured it out by using a for loop inside a for loop (definitely not the most efficient way but the string will not go past 8 characters leading to no worry with efficiency). r.


I don't even try to understand what you are saying. A FOR loop is one of the most efficient structures (However, your outer FOR loop does nothing useful and just repeats the same operation N times.)

 

If you want us to play with your VI, you need to also attach the "text" file. And yes, it can be dramatically simplified.

 

Of course it is a really bad idea to have a binary file with a *.txt extension. Bad form! (Also give it a better name than "Display - Copy.txt")