lua-users home
lua-l archive

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


Thanks for the answers.

> Danilo wrote:
> 
> "If there is any error executing the string, then dostring returns nil.
> Otherwise, it returns the values returned by the chunk, or a non-nil 
> value if the chunk returns no values" (userdata(0) actually).

   function Test_Version() return 001 end

      Name = 'Test'
   Version = 002

   if dostring('return '..Name..'_Version()')<Version then
      print('Version to old')
   end


If there is an error executing this dostring, e.g. if Name = 'Other'
then dostring shows an error message:
"error: attempt to call global 'Other_Version' (a nil value)"
and then
"error: attempt to compare nil with number"
How can both suppressed?


Please note: this is only the example extract from my environment. The
real problem is that I would like to write a few library management
functions. So the function names and version numbers are given in
the parameter list:

   Library_Initialise('Example',001)

   1. If 'Example' library isn't loaded the load it
      If 'Example' library not available then show an error message
   2. Check version of 'Example' library
      If 'Example' library to old then show an error message
   3. If 'Example' library isn't initialised then initialise it

Thank you very much for your help. If I missed to read some
documentation please let me know.


Markus