im scripting something that creates a file but i want to add a file extension how do i add ".nfp" to a string variable
combining strings
Started by ETHANATOR360, Nov 25 2012 08:39 AM
5 replies to this topic
#1
Posted 25 November 2012 - 08:39 AM
#2
Posted 25 November 2012 - 08:47 AM
You could just use :
Sfile = fs.open(input..".nfp", "w")
thats my way?
Sfile = fs.open(input..".nfp", "w")
thats my way?
#3
Posted 25 November 2012 - 09:01 AM
what about:
local filename...".nfp" = read()
local filename...".nfp" = read()
#4
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:
b should be "one.two"
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"
#5
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"
#6
Posted 25 November 2012 - 11:09 PM
you can put it onto one line too. pretty much what mystic said
local fName=read()..'.nfp'
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











