Notifications
Clear all
[Closed] Some handy function | macroscript
Jan 15, 2009 9:27 pm
Hi all,
Finally made a function to retreive all registered macroscript in an usable array, thought I’d share it. Maybe someone has use for it.
fn getMacroScripts =
(
/*
<DOC> Description here.
Arguments:
no arguments
Return:
<array> Returns a big array of arrays with macro meta data
*/
-- Setup the in and output
local macroStream = stringStream ""
local macroArray = #()
macros.list to:macroStream
seek macroStream 0
while not eof macroStream do
(
-- Read a line
local macroLine = readline macroStream
-- Get the macro number as array
local macroItem = #(substring macroLine 1 5)
-- Get the rest of the line
local macroRest = substring macroLine 6 -1
-- Make an array of it, filter it by qoutes
local macroSplit = filterString macroRest "\""
-- Loop over the splitted array and clear the whitespace entries
local macroClean = for macro in macroSplit where macro != " " collect macro
-- Join the number and the rest of the items
join macroItem macroClean
-- Append to the final macroArray
append macroArray macroItem
)
-- return macro array
macroArray
)
-- Use it for macroscript management, menu building etc
getMacroScripts()
-Johan
1 Reply