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

# Re: [femm] Lua questions: scripts and functions

- To: femm@yahoogroups.com
- Subject: Re: [femm] Lua questions: scripts and functions
- From: David Meeker <dmeeker@ieee.org>
- Date: Thu, 17 Jul 2003 16:57:19 -0400
- In-reply-to: <bf6vn3+o5ge@eGroups.com>
- References: <bf6vn3+o5ge@eGroups.com>
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4; MultiZilla v1.4.0.4A) Gecko/20030624

masteringmatlab wrote: `Is it possible to call one lua script from another? For example, from the inside of test1.lua can I tell lua to open a file test2.lua and execute the instructions found there by acting the same as if the instructions found in test2.lua were copied into test1.lua before it was run? I see that one can call post processor scripts from preprocessor scripts, but I want to encapsulate several chunks of geometry drawing code without having all the code being in one lua file.` Yes, you can do this via the dofile command in Lua. For example, if you put the line: dofile("c:\\temp\\junk.lua") in your script, Lua would execute some file called c:\temp\junk.lua `Do user-created functions in a lua script have to appear at the beginning of the script file? Or can they be at the end as well?` You need to put your user-created functions in the beginning of the script so that these functions get defined before you call them in your script. `Or can they be separate files in the same directory on disk?` If you have a library of lua functions, you can load it at the beginning of a script via a dofile() call. `Does femm plan to upgrade to LUA version 5? (If so, much code will have to be rewritten!)` I wasn't planning on changing to Lua 5.0, becuase it isn't clear to me that switching to 5.0 would be a big advantage--if it ain't broke, don't fix it. Only some big increase in functionality would merit forcing everyone to redo scripts for Lua 5 compatibility. As it see it, my main (only serious?) gripe about Lua is its klunky support of complex numbers (For example, see http://www.lua.org/notes/ltn007.html -- there is a different (and possibly better) implementation of complex numbers at http://members.chello.nl/~w.couwenberg/ ) However, I don't think that complex numbers are any easier under Lua 5. However, there will eventually be some fairly mild changes to the FEMM-specific lua functions. In the MDI version of FEMM that I am working on, the Lua functions have to have a prefix added onto them so that Lua knows which type of document the command is supposed to apply to. I had to do this because there are many function names that are duplicated in the pre-and post-processor and in the femm and bela implementations--I had to have some way of differentiating the various implementations. `p.s., I am working on lua scripts for drawing PMSMs having arbitrary pole and slot counts as well as several magnet shapes. They are meant to compliment the material in my latest book Brushless Permanent Magnet Motor Design.` Cool! It will be interesting to check them out. Dave. -- David Meeker email: dmeeker@ieee.org www: http://femm.berlios.de/dmeeker

- References:
  - Lua questions: scripts and functions
    - From: "masteringmatlab" <masteringmatlab@yahoo.com>

- Prev by Date: Lua questions: scripts and functions
- Next by Date: feeping creaturism
- Previous by thread: Lua questions: scripts and functions
- Next by thread: feeping creaturism
- Index(es):
  - Date
  - Thread