lua-users home
lua-l archive

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

In reference to my previous question about passing arguments to a program
which is invoked via "loadfile", here is the complete source to the calling
program.  The "dummy2" is a "hello, world" program which also prints the two
arguments that were passed to it.

Here is the calling program:

pgm = "c:\\lua\\source\\dummy2.lua"

  arg1 = "Apple"

  arg2 = "Banana"
  print(" ")
  print(" ")
  print("Program Name ==> ", pgm)
  print("Arg 1        ==> ", arg1)
  print("Arg 2        ==> ", arg2)
  print(" ")

  print("Call # 1 --------------------------------")
  assert(loadfile(pgm))(arg1, arg2)  --(arg1, arg2))
  print("Call # 2 --------------------------------")
  print("Call # 3 --------------------------------")
  assert(loadfile("C:\\lua\\source\\dummy2.lua"))("apple", "banana") 

When I execute this program (Win/XP, version 5.1.2), I get no output for
call 2, and messages that arg1 & arg2 are nil from calls 1 and 3. I do
understand that the actual "args" are written as "arg[1]" and "arg[2]".

I can invoke dummy2 from the command line with:

C:\lua\source\dummy2.lua "apple" "banana" 

I will get the expected output this way.  The purpose of this exercise is to
programmatically build and pass the "parms" to successor programs, i.e.
another form of modularization.


CONFIDENTIALITY NOTICE:  This E-mail message and all attachments, which originated from Sealy Management Company Inc, are intended solely for the use of the intended recipient or entity and may contain legally privileged and confidential information.  If the reader of this message is not the intended recipient, you are hereby notified that any reading, disclosure, dissemination, distribution, copying or other use of this message is strictly prohibited.  If you have received this message in error, please notify the sender of the message immediately and delete this message and all attachments, including all copies or backups thereof, from your system.  You may also reach us by phone at 205-391-6000.  Thank you.