419 posts
Location
your hardrive
Posted 25 November 2012 - 08:39 AM
im scripting something that creates a file but i want to add a file extension how do i add ".nfp" to a string variable
767 posts
Posted 25 November 2012 - 08:47 AM
You could just use :
Sfile = fs.open(input..".nfp", "w")
thats my way?
419 posts
Location
your hardrive
Posted 25 November 2012 - 09:01 AM
what about:
local filename…".nfp" = read()
180 posts
Posted 25 November 2012 - 09:12 AM
The string.format command can output the combination of two strings, variables, or one of each.
It is similar to printf in C. %s represents string, and two of them expects two arguments each being a string.
Example:
a="one"
b=string.format("%s%s", a, ".two")
b should be "one.two"
1604 posts
Posted 25 November 2012 - 09:44 AM
If you want to use the user input, it should be like this:
local filename = read()
filename = filename..".nfp"
1548 posts
Location
That dark shadow under your bed...
Posted 25 November 2012 - 11:09 PM
you can put it onto one line too. pretty much what mystic said
local fName=read()..'.nfp'