lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Is it possible to use the .. operator which concatenates strings:

Argument1 = "C:\\folder1" -- notice: \\ produces \Argument2 = "C:\\folder2"execute("batch " .. Argument1 .. " " .. Argument2) 
The above is treated as:

execute("batch C:\\folder1 C:\\folder2") 

Is this correct... seems a little to simple?

Regards
Brian


>----- ------- Original Message ------- -----
>From: "Peter Shook" <pshook@hotmail.com>
>To: lua@bazar2.conectiva.com.br
>Sent: Sun, 18 May 2003 17:22:13
>
>
>Lua doesn't do string interpolation.  Here's what
>you do, assuming you are 
>using Lua 4
>
>function subst(str, table)
>  local v = gsub(str, '$([_%a][_%w]*)',
>		  function(w) return %table[w] or ''
>end)
>  return v
>end
>
>args = {
>  Argument1 = [[c:\folder1]],
>  Argument2 = [[c:\folder2]],
>}
>
>cmd = [[ batch $Argument1 $Argument2 ]]
>
>print(subst(cmd, args))
>execute(subst(cmd, args))
>
>$ lua test.lua
>batch c:\folder1 c:\folder2
>
>Also have a look at 
>http://lua-users.org/wiki/HereDoc
>
>- Peter Shook
>
>
>brian@arandasys.com wrote:
>>That would work if i the folder names were always
>going to be c:\folder1 
>>and c:\folder2!
>>
>>The folder names will be decided at run time by
>the lua script so they will 
>>have to be held in two variables.
>>E.g. Argument1 & Argumnet2
>>
>>So for example Argument1 = c:\folder1
>>		  Argument2 = c:\folder2
>>
>>So calling execute[[ batch Argument1 Argumnet2 ]]
>>would pass the actual string='Argument1' to the
>batch file rather that the 
>>path held by the varialbe Argument1
>>
>>So you execute(batch Argument1 Argument2)
>>work?
>>
>>Thanks for your time
>>Brian
>>
>
>Add photos to your messages with MSN 8. Get 2
>months FREE*.	
>http://join.msn.com/?page=features/featuredemail
>___________________________________________________
>______________