Jump to content

Write to Text File problem


Recommended Posts

I am fairly new to Labview and am in trouble with the attached vi. The purpose of the vi (part of a larger scheme)

is to let the user measure a series of chemical standards, and then derive a calibration equation from the data. The user

would enter data in a table, edit the data and then store in a file.

The problems I am aware of (and I imagine forum members can find plenty of others) are:

- Write to Text File: data is correctly written to the file when LV is first started and the vi run, but even this is not

consistent. Sometimes the file remains blank. Having run the vi once, on later runs the file is not cleared

and new data has not been able to be subsequently written to the file, even though the new data and the

path are present at 'Write to Text File' on each occassion.

- Run time shortcut menu: a custom menu for the table, made up from application items, has been saved as a file

in the same directory as the vi. When running, the menu appears, but no action occurs when a menu item

is selected. I had assumed that no further code was required. If code is necessary I would appreciate

some help in getting started.

Any advice would be very much appreciated.

Regards.

Sorry, wrong attachment: try again

Link to comment

For your menu questions.

Yes you need to handle the event.

Using the Event structure is one way way to handle FP RTSM selections and it is quite easy.

Add a case called Shortcut Menu Selection (User) or Shortcut Menu Selection (App) for the control and handle the Item-Tag string in a case structure.

Use (User) for custom items, use (App) for Application items (you cannot edit item name/tag of application items)

Also I prefer not to execute code in the Event Structure but to queue it out to a consumer loop.

post-10325-1211334543.png?width=400

Link to comment

Hello jgcode,

Re: Runtime Shortcut Menu

Thanks for your advice. I have got it partially running, but am still in trouble.

For "copy" and "description and tip" each case operates correctly. When either if these is selected in the RTSM,

a probe on the selector terminal for these cases within the event structure shows the correct Item_tag, and the

case is then processed. For all other Application Items eg. 'empty table' or 'delete row', the Item_tags do not appear

in the Event structure.

I have not been able to figure out how to step through this bit of the code to see what is happening.

Any further advice would be much appreciated.

Regards, GraemeJ

Link to comment

QUOTE (GraemeJ @ May 24 2008, 09:09 AM)

Hello jgcode,

Re: Runtime Shortcut Menu

Thanks for your advice. I have got it partially running, but am still in trouble.

For "copy" and "description and tip" each case operates correctly. When either if these is selected in the RTSM,

a probe on the selector terminal for these cases within the event structure shows the correct Item_tag, and the

case is then processed. For all other Application Items eg. 'empty table' or 'delete row', the Item_tags do not appear

in the Event structure.

I have not been able to figure out how to step through this bit of the code to see what is happening.

Any further advice would be much appreciated.

Regards, GraemeJ

Hi Graeme, no probs.

Are you handling your custom items with event: Shorcut Menu Selection (User)

And LabVIEW application shortcuts with event: Shortcut Menu Selection (App)

??

Even if you have a overall custom menu, it can be made up of App and Custom tags so you need to use both events?

If this does not help please post up your new code.

Link to comment

Thanks jgcode,

Still in trouble. I have not understood what LV is trying to achieve with the RTSM: with the default menu, eg. 'empty table' seems an unambiguous requirement which would have had prewritten code, as is the case for much of LV. However, 'empty table' is also a custom app. which requires code to be written.

Attached is my current code. As always, would appreciate any help.

GraemeJ

Link to comment

QUOTE (GraemeJ @ May 26 2008, 09:49 AM)

Sorry I may have been a bit vague before - LV will perform code for SRTM App Events, but if you need to capture these events for other reasons then you need to use Shortcut Menu Selection (App) not Shortcut Menu Selection (User).

Now in your code the table is an indicator and it can't access these methods (empty table etc..), it needs to be a control.

Therefore one solution is to use a control and write to (update) the table using a local variable.

If you probe the item tags in the new code it will be picking up these events now.

The only problem I can think of is that the user can enter in values.

But if you keep your data private in the application and only use the local variable to write to the screen (as opposed to read at any time) this should not be a problem aside from making the table a little ugly if the user types something in.

You can't disable the table because then you can't access the SRTM.

One way to handle this is to use a value change event to load the private data back into the table if the user did change it.

May be overkill in your case?

I code in LV8.5, I saved this down to LV8.0, if you only have LV7.0, please follow the .PNG.

post-10325-1211770632.png?width=400

Download File:post-10325-1211770620.vi

Code is in LV8.0

Link to comment

Sorry I may have been a bit vague before - LV will perform code for SRTM App Events, but if you need to capture these events for other reasons then you need to use Shortcut Menu Selection (App) not Shortcut Menu Selection (User).

Many thanks indeed jgcode,

that solved the problem and I am most grateful for your help. The user being able to enter data in the table is an issue

and I will use your suggested solution.

Thanks again, GraemeJ

Link to comment

hi everybody,

i'm a student to istanbul. i'm not good to Labview. i wanna read the AI and write to text.

i read the AI but i can't write to text. My program's is writing to text just one time.

pls help me

i hope u can understand my problem

look forward your reply

Code is in LV8.0

Link to comment

firstly, thanks for your concern

i'm trying your suggestion.

i send to "calisan.VI"

thanks for everything...

hakan

hi again,

i opened your example but i don't know what can i write the "physical channells".

i writed dev1/ai0 bc i'm using "AI0". but i can't read the AI :(

pls help again.

thanks for everything

hakan

Link to comment

QUOTE (hakannn @ May 26 2008, 10:26 PM)

http://lavag.org/old_files/monthly_05_2008/post-10325-1211814136.png' target="_blank">post-10325-1211814136.png?width=400

No worries

You need to make sure you have the FULL correct physical channel name

e.g. Dev2/ai0 (PCI, USB etc..)

e.g. cDAQ1/Mod2/ai0 (Compact DAQ chassis)

not just "ai0"

Go into MAX and make sure you are selecting the correct device.

Green is "installed and is plugged in"

Yellow is "simulated"

White with red cross is "has been installed but currently not found"

For your real device make sure has a green icon and that the device name is correct.

Link to comment

QUOTE (jgcode @ May 26 2008, 11:11 AM)

You need to make sure you have the FULL correct physical channel name

Right. I suggest you also check out your "Data Neighborhood" - you can define more user-friendly names for individual channels, as well as define tasks (grouping similar channels into groups that share timing information).

Link to comment

thanks everybody,

i can read data and write to text :)

finally, how can i write to read the data time.

i can write just value but i wanna show when i read the data.

last question,

i use the "write to text file" in Lab 8.0 but i can't find it in Lab 7.1.

can i write the same program in Lab 7.1??

thanks again

that's my program.

i hope it will use by someone

hakan

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.