Jump to content

Format used by AutoItTools:ExportLibrary()?


Recommended Posts

I looked at the description of AutoItTools:ExportLibrary() and added it to my Tools menu, but I can't seem to make it work. Perhaps the format of my UDF headers is wrong. Can anyone give a short sample that shows the format required?

I currently get the following lines (I added the region):

#Region Members Exported
#cs Exported Functions
#ce Exported Functions
#endregion

Thanks,

Frank

Frank

Link to comment
Share on other sites

ExportLibrary() is a routine included in the LUA file typically installed with AutoIt at:

C:Program Files (x86)AutoIt3SciTELUAAutoItTools.lua

The routines in the file can be added to the Tools menu in the AutoIt editor. (Some are there already.)

Frank

Frank

Link to comment
Share on other sites

Looks like you have it right as far as your headers goes:

function AutoItTools:ExportLibrary()
    -- These are constants used throughout.
    local region_text = "#Region Members Exported"
    local comment_start = "#cs Exported Functions"
    local comment_end = "#ce Exported Functions"

That is from the LUA file. It first checks for the region, then then comment_start, then reads to comment_end - written just like you have it.

Link to comment
Share on other sites

  • Developers

The delivered LUA scripts and au3.properties should give you ample examples on how to trigger a LUA function from SciTE.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I have been successful in triggering a few LUA functions from the Tools menu of SciTE, but that is not where I have a question. Sorry for the confusion, and thanks for AutoIt!

Currently, I have added the LUA routine AutoItTools:ExportLibrary() to the Tools menu (source file C:Program Files (x86)AutoIt3SciTELUAAutoItTools.lua), but when I run the tool, I don't see any routines added to the #Region Members Exported region. I looked at the LUA script, and I suspect my routines are missing some type of formatting required by the regular expression in ExportLibrary().

The LUA code is:

--------------------------------------------------------------------------------
-- ExportLibrary()
--
-- Creates an exports section in an AutoIt file containing comments describing
--     the functions in the file.
--
-- Tool: AutoItTools.ExportLibrary $(au3) savebefore:no,groupundo:yes Ctrl+Alt+E Export Library
--------------------------------------------------------------------------------
function AutoItTools:ExportLibrary()
    -- These are constants used throughout.
    local region_text = "#Region Members Exported"
    local comment_start = "#cs Exported Functions"
    local comment_end = "#ce Exported Functions"
    local nl = self:NewLineInUse()

    -- We work over the entire document.
    local doc = editor:GetText()
    if not doc:find(region_text, 1, true) then
        print("Error: Unable to find "" .. region_text .. "" in the library, no export list created.")
    else
        local from, to, found = false
        if not doc:find(comment_start, 1, true) then
            print("Warning: Unable to find "" .. comment_start .. "" in the library, there may be multiple export lists.")
            from = doc:match(region_text .. nl .. "()")
            to = from
        else
            from = doc:match(comment_start .. nl .. "()")
            to = doc:match("()" .. comment_end)
            found = true
        end
        -- This should never happen due to the checks above.
        if not from or not to then
            print("Error, unable to determine where to add the export list.")
        else
            -- Store the list in this variable.
            local text = ""
            -- We only build the list for functions we can find in the code.
            -- Orphaned comments will not be found.
            for pos, str in doc:gmatch(self.Pattern) do
                -- Pull the name out of string so we can build a pattern.
                local name = str:match("^(.-)[%(%s]")
                -- First check that the name doesn't start with __ which means
                -- it's private.
                if not str:find("^__") then
                    -- Build the pattern.  It's a bit complicated to keep it
                    -- from running over lines it shoudn't.
                    local pattern = ";%s+(" .. name .. "%s*%([^" .. nl .. "]+)" .. nl .. ";%s+;(.-);%s+Parameters"
                    -- Get the two parts.
                    local func, desc = doc:match(pattern)
                    -- Ensure they are valid.
                    if func and desc then
                        -- Clean up the text, put on a single line, remove trailing spaces.
                        func = func:gsub("%s*$", "")    -- Trailing spaces
                        desc = desc:gsub("%s*;%s*", " ")    -- Multiple lines
                        desc = desc:gsub("^%s*", "")    -- Leading spaces
                        desc = desc:gsub("%s*$", "")    -- Trailing spaces
                        -- Concatenate the formatted text.
                        text = text .. func .. " - " .. desc .. nl
                    end
                end
            end
            -- We have to offset our indices because SciTE is 0-based while Lua
            -- strings are 1-based.
            editor:SetSel(from - 1, to -1)
            -- If the exports section already exists, we are replacing it.
            if found then
                editor:ReplaceSel(text)
            -- Otherwise, we have to insert the exports section.
            else
                editor:ReplaceSel(comment_start .. nl .. text .. comment_end .. nl)
            end
            print("Exports list created. ")
        end
    end
end    -- ExportLibrary()

Frank
 

Frank

Link to comment
Share on other sites

  • 3 weeks later...

I looked at the description of AutoItTools:ExportLibrary() and added it to my Tools menu, but I can't seem to make it work. Perhaps the format of my UDF headers is wrong. Can anyone give a short sample that shows the format required?

I currently get the following lines (I added the region):

#Region Members Exported
#cs Exported Functions
#ce Exported Functions
#endregion

Thanks,

Frank

Frank

Link to comment
Share on other sites

  • Moderators

fspafford,

As you already have a thread running on this, why not stick with it. Threads merged. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...