Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng 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
Joined
Sep 9, 2004
Messages
2
Location
US
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?
 
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

Back
Top