[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Recursively getting a list of all files executed using dofile
- From: marbux <marbux@...>
- Date: Sat, 14 May 2011 07:25:00 -0700
Hi, all,
Before risking possible reinvention of the wheel, I ask whether anyone
knows of an existing snippet to return a list of file paths for all
files executed by a script and its chunk files using dofile? This is
for an app that embeds standard Lua, no add-on libraries.
Problem Context:
My use case is actually slightly different but closely analogous so if
code already exists as described above, it should be easy to modify to
my purpose. The app is an outliner. We've supported external Lua
scripts in text files for some time, but are now getting our feet wet
with support for embedded scripts.
We've developed a program API that is a counterpart to Lua's dofile,
which you might think of as "do-node", where the API executes the code
embedded in an outline node identifiable by a 22-character UID. That
UID in an embedded script running on our app corresponds to the path
of a Lua chunk file executed using dofile.
I have been tasked with developing utility scripts to aid users who
work with embedded scripts. Embedded scripting of the outliner is
going great, exceeding our original hopes. (We've had to create only
three new APIs so far for the purpose.) In relevant regard, one huge
advantage for our embedded scripts has been that we can stack a very
large number (limited only by practicality and system resources) of
scripts in a single document and break them down into very granular
modules/chunks stored in separate nodes for code recycling purposes
(and execute them via, inter alia, an abbreviation expansion trigger,
with the abbreviation derived from the node title.)
One big advantage is that a script can call only the modules needed;
we need not create and use a library file of multiple functions most
of which will not be needed for a particular script's execution. Only
the functions needed for the particular script are called by
"do-node".
But with greater granularity comes a dramatic increase in the number
of code modules summoned with "do-node" by a given script and its
submodules/chunks.
The Problem:
Which brings me to the problem I need to solve in an automated
fashion, export and import of all node modules executed by a given
script to embed the script and all of its submodules/nodes in a
different document. In other words, I need to remove a script-sharing
barrier.
This Missive's Goals:
Thus far, either I have not been smart enough to frame a web search
query to pop a Lua snippet that returns a list of files executed by
dofile, or there isn't one out there. So I ask whether: [i] anyone
knows of one; and if not [ii] anyone can suggest search terms that
might aid in my search; or [iii] anyone has a suggestion on a method
to create create such a snippet?
Thanks in advance,
Paul E. "Marbux" Merrell
---
NoteCase Pro
The Massively Multi-Platform Outliner
<http://notecasepro.com/>