Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Extension to Written File

Status
Not open for further replies.

writhziden

Mechanical
Sep 9, 2004
2
I have a program that reads the name of a file and from the name creates a new file. It's done by setting the name of the original file as a character variable, x, and then substituting that variable into "FILE=x"

Is there a way to add .txt or .xls or something similar after the x?
 
Replies continue below

Recommended for you

Yes there is!

Just add //'.txt' after the string variable which will concatenate the text string '.txt' on to your string variable

FILE=x//'txt'
 
You might want that to be something like....

File= TRIM(x)//'.txt'

The above will get rid of the excess spaces at the end of 'x'. Also... you must make sure you declare x and File to be Character variables of sufficient length.

Dan :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor