LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Windows filename to DOS filename

Does anyone know how to convert Windows filename to DOS filename? eg. C:\Program Files to c:\Progra~1) I have to do this in LabVIEW. Or does LabVIEW already provide such function?
0 Kudos
Message 1 of 5
(3,558 Views)
Here is one algorithm that would do it:
1. Get the filename before the extension (.exe). If the filename string length is less than or equal to 8, do nothing and exit.
2. Initialize a counter to 0.
3. Get the first six characters in the filename and store to a buffer or variable.
4. Append the squiggly character (~) to the buffer.
5. Increment and then convert the counter to a character.
6. Append the counter character to the buffer.
7. Append the extension (.exe)
8. Check to see if the new buffer string is a file that already exists. If so, strip out the extension and the counter character, and goto step 5. If the file does not exist then you are done.
This will bomb when your counter reaches 10 because then your filename string will be 9 characters lo
ng. So you have to check for the counter reaching 10, in which case you have to go back to step 3 and get the first 5 characters instead of 6, and continue on. This will work until your counter gets to 100.
I hope this is clear enough.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 5
(3,558 Views)
Here is a VI that does a system call to get the DOS path.


LabVIEW, C'est LabVIEW

Message 3 of 5
(3,558 Views)
Merci beaucoup!
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 5
(3,558 Views)
Irene wrote in message news:<506500000008000000A4020100-1079395200000@exchange.ni.com>...
> Does anyone know how to convert Windows filename to DOS filename? eg.
> C:\Program Files to c:\Progra~1) I have to do this in LabVIEW. Or does
> LabVIEW already provide such function?

I don't know a clean way to do it, but if the file already exists,
there is a clunky way to do it:
Use Functions -> Communication -> System Exec.vi. Pass "Dir /X
windows_longfilename" to the 'command line input, then parse the
'standard output' to find the DOS version of the filename.

Paul Cardinale
0 Kudos
Message 5 of 5
(3,558 Views)