Jump to content

working with values of a table


Recommended Posts

Hello everyone,

I have a question regarding re-writing values in a table.

I have a table (attached as png). I have to save and read the values from this table and main point re-write.

I have been able to save and read but whenever i try to re-write a value or give in a new value in the table, it turns all the other values to zero and only the new value(s) is then shown. Do you know how i can avoid that?

And one more thing i have used .ini to save the values. Is there any easier way to do so?

Thank you :)

 

table.PNG

Link to comment

Seems to work for me.  There is quire a bit of inefficient ways of doing things, but the work of clicking Set Y or Set C does set the cell value leaving the rest.  Am I misunderstanding what it should do?

EDIT: Okay I see the problem.  So in case 1 of the sequence structure add a Transpose 2D array after the second build array, if you probe this you'll see the array only has two rows but 6 columns which is the opposite of what you want.  Then the next issue is in case 2 where every time the VI runs you are initializing the array (outside the sequence structure) be be empty.  What you probably want is to use a local variable on the WCS and wire it to the shift register in case 2.  Then the newly loaded (and transposed) values will be used and will be replaced when you click Set.

Link to comment

Problem is not Setting the values. Problem is when i run the program and the saved values are read and I want to just  change one value or overwrite one value, all the other value changes to 0 and only that new value stays in the table and if i click okay only that value is saved (obviously) and when i re-run again only one value can be saved in the table (again, obviously).

What i want is to be able to overwrite the values without changing the rest of them. How can i do this?

Also, how can the user add new row from the front panel? for example G54.1 which automatically should be after G54.

Link to comment

I found several other suggestions.

  • Control labels should be unique
  • Control terminal labels should always be seen.
  • Overuse of local variables
  • Use of native global which doesn't seen necessary here
  • Use of scalar data when you want it to grow as needed (meaning arrays should be used)
  • Use of sequence structure

Attached is a re-write that uses a state machine and no local or global variables.  For the saving and loading I highly recommend getting the OpenG Configuration File palette which allows saving any data time into an INI file, in this case I saved the Y C and Row Names.  I also added the Add button which makes a new row.  If you don't have the OpenG you can replace this with your own custom VIs that reads and write arrays of strings.

Subvi_WCS Hooovahh Edit2.vi

Link to comment

could i please ask how many  years of experience do you have? :o Your program just seems so clean and easy to understand.

I would have never thought of openG, never worked with it.

Global variable is required because this is just a SubVI and Y and C has to be read from the main VI.

:thumbup1:

Link to comment

Why thank you.  I've been using LabVIEW pretty much daily since college in 2004.  If you do anything that long, and that often, you get pretty good.  I often make the comparison to a welder.  If you started mig welding in 2004 your first welds probably look pretty terrible (just like my code).  But after doing it daily for 13 years you had better be pretty good.  Then there's the fact that I actually enjoy programming in LabVIEW so I seek out new techniques and keep up with the community.  Anyway enough about me.

OpenG is a fantastic set of tools that every developer should have available to them.  They are licensed under BSD which is a pretty relaxed license stating you can use it or modify it however you want, with only a few minor caveats.  The code has been used and tested since version 5 (or older), but hasn't had any major updates in a while.  Some of the most valuable are under File I/O, Array, and the Variant Configuration.  Having a single function that saves a front panel to a file, and loads a front panel from a file can be very useful.

Global variables aren't the only way to pass data around to other parts of the application.  Native globals have their place but often times a more manageable solution is to use a functional global variable, VIG, or action engine. 

http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801#M240328

http://www.labviewing.com/fgv-in-labview/

http://forums.ni.com/t5/Example-Programs/Basic-Functional-Global-Variable-Example/ta-p/3503982

Like in this case I could see an action engine that has a Load, Save, Read, and Write method.  Other options for passing data can involve references like a queue, or in modern versions the channel wires.

Link to comment

First of all thank you so much for the references although i might have to go through them more than once.

I need to learn a lotttt. It's been hardly one year since I began LabVIEW :rolleyes:

Thank you for your help, really appreciate it, though it makes me feel like i should just ask you all my doubts regarding the project and maybe give it to you to see how differently you would do it. :)

 

Link to comment

Hi! I need your help again.

I still have a doubt regarding the table control. How can I work on the individual rows? For example i have values of Y and C for G57 and i want to avaoid selecting the rows every time. How do I select the row depending on the options like G54  and so on. The "G54-59" will be given by the user. After the value is given I have to read the values and also be able to save them.

Also it should be able to recognize if G54.1 (for example) is not there then it should automatically add a new row.

Thank you :)

Link to comment

You already see how to work on individual rows.  What do you mean avoid selecting the rows every time?  Where in the code are you selecting rows at all?  If you want a given rows values search for it.  You see that the Add function already searches for Row Names that match the one you are trying to add, and you get an index of where the match is.  Index the Y and C values at that found index and you'll have the Y and C values for a given row.  If it returns -1 then there was no match.  This add also won't add a new name if the name already exists.

Link to comment

Here is a program that uses a multi-column listbox instead of a table.  The selected row is highlighted, and the values in the row are output to the DBL indicators on the front panel.  Selecting a row updates the output values.   Using the "Set" buttons generates new values, and also updates the row selection. A cluster is used for the shift register data to clean up the diagram.  The diagram has a case structure with the "0" case handling the file read initialization.  The "0" case code should be placed in a subVI to get rid of the case structure, but I wanted to keep the code to a single VI.

Subvi_WCS_listbox.vi

Link to comment

Here is yet another simplified version based on a classic listbox editor idea.  It has the following features:

  1. "Table" values are stored in a 2D DBL array.
  2. Editing is done using a multi-column listbox.
  3. DBL controls edit the individual row elements
  4.  Listbox updates when the DBL control values change
  5. DBL values are returned and table value file is updated when VI is closed. 

Subvi_WCS_listbox_classic.vi

Link to comment

Here is an absolute minimalist version.  From what I understand of your question, what you really want is an dialog editor that loads a file into a table, allows the user to edit the table, and also allows the user to select a row and return the values from that row.  I have attached a file that does that using the "Editable Cells" feature of the multi-column listbox to allow direct editing of the table values.  You must triple-click a cell to edit it. The user can also select a row to return the values.

cells.png

 

 

Subvi_WCS_listbox_editable.vi

Edited by smarlow
Changed attached VI to simplify more
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.