Macro Exceute Tag - $MEX

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Macro Exceute Tag - $MEX

Post by jussij »

The latest version of Zeus adds a $MEX macro tag which allows the creation of a tag value based on the results of a macro script.

This macro execute tag can be used in this basic format:

Code: Select all

$MEX<macro_script>
Alternatively, the tag can be used in this arguments format:

Code: Select all

$MEX<macro_script arguments>
The macro_script represents the name of the script to be run and the arguments represent space delimited argument values passed to the macro.

Here is an example of a typical script:

Code: Select all

function key_macro()
    local arguments = "";

    local count = argc();

    if count > 0 then
        count = count - 1;
        for i = 0, count, 1 do
            arguments = arguments .. argv(i)
            arguments = arguments .. ' '
        end
    end

    local message = "This output generated was by the 'mex-test.lua' macro."

    if (string.len(arguments) > 0) then
         message = message .. " Arguments Supplied: " .. arguments
    end

    -- this will be the result of the macro expansion
    print(message)
end

key_macro() -- run the macro
This actual macro comes as part of the latest installation and can be found in the Zeus zScript folder in the mex-test.lua file.

Here is an example of how this macro script can be used using the basic format:

Code: Select all

$MEX<mex-test.lua>
Here is an example of how this macro script can be used using the arguments format:

Code: Select all

$MEX<mex-test.lua arg1 arg2 arg3>
To see how these work, use the Tools, DOS Command Line menu and run this echo command:

Code: Select all

echo $MEX<mex-test.lua>
That will result in the following output:

Code: Select all

This output generated was by the 'mex-test.lua' macro.
And when this command is run:

Code: Select all

echo $MEX<mex-test.lua arg1 arg2 arg3>
That will result in the following output:

Code: Select all

This output generated was by the 'mex-test.lua' macro. Arguments Supplied: arg1 arg2 arg3  
Another example is the mex-dir.py macro, which lists the files in a folder based on file filter.

For example, this echo will list all text files in the current directory:

Code: Select all

echo $MEX<mex-dir.py *.txt>
This echo example lists all text files in the c:\temp directory:

Code: Select all

echo $MEX<mex-dir.py c:\temp\ *.txt>
Cheers Jussi
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: Macro Exceute Tag - $MEX

Post by sturt »

Thanks for that (may have replied to that in wrong thread).
Post Reply