LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

illegal filename

Hi,
I built an user interface to allow free filenames to save data. unfortunately some user enters "/" and ":". those characters are illegal in windows environment. when the program tries to save the file either nothing happens and all datas are gone or an error message occurs.
how can I prevent this. do I really have to check the filename to detect any possible illegal characters on it? or is there an easier way.

thanks for the help
yves
0 Kudos
Message 1 of 6
(3,535 Views)
Hi,

There are several solutions...

If you're using LabVIEW 7.x, you can create an event structure and check
"key down", "key repeat" and "value change" to do the filtering.

In LabVIEW <7, you can do this in a while loop, but it's ugly.

Perhaps the easiest way it not to use a string control, but a path control.
In LabVIEW >6, you can have a browse button as a bonus. The user can now
browse to different paths, so if you don't want this, you still have to
check the result.

Regards,

Wiebe.


"Yves" wrote in message
news:50650000000800000056EC0000-1079395200000@exchange.ni.com...
> Hi,
> I built an user interface to allow free filenames to save data.
> unfortunately some user enters "/" and ":". those characters are
> illegal in windows environment.
when the program tries to save the
> file either nothing happens and all datas are gone or an error message
> occurs.
> how can I prevent this. do I really have to check the filename to
> detect any possible illegal characters on it? or is there an easier
> way.
>
> thanks for the help
> yves
0 Kudos
Message 2 of 6
(3,535 Views)
Hello,

I'm afraid you'll have to check whether the filename has illegal caracters or not (\ / : * ? " < > |).

Another solution could consist in using two different elements on the front panel. The first element (path control) could be used for the browse button (hide the control behind the button for example) and the second (path indicator) could be used to display the selected path. Don't forget to wire the control and the indicator.

Hope this helps !
Julien
0 Kudos
Message 3 of 6
(3,535 Views)
Hi Yves,

can't you use the file dialog function? this detects if the file path
and name is legal or not.

Niko

Yves wrote:
> Hi,
> I built an user interface to allow free filenames to save data.
> unfortunately some user enters "/" and ":". those characters are
> illegal in windows environment. when the program tries to save the
> file either nothing happens and all datas are gone or an error message
> occurs.
> how can I prevent this. do I really have to check the filename to
> detect any possible illegal characters on it? or is there an easier
> way.
>
> thanks for the help
> yves
0 Kudos
Message 4 of 6
(3,535 Views)
unfortunately the filename is built with concatenated strings. this makes it impossible to use path controls.
thanks anyway.
yves
0 Kudos
Message 5 of 6
(3,535 Views)
Then you can try the new file function and have a look at the error
output. It creates a new file, but does not replace an existing file.

Yves wrote:

> unfortunately the filename is built with concatenated strings. this
> makes it impossible to use path controls.
> thanks anyway.
> yves
0 Kudos
Message 6 of 6
(3,535 Views)