UserFunction; HW2Path - HWRM/KarosGraveyard Wiki

HW2Path()

Description

Finds the path of the Homeword2 folder. Returns nil if nothing is found.

Example

local path = HW2Path()
local filename = path..[[data\readthis.lua]]
local handle = openfile(filename,"r")
local filecontents = read(handle,"*a")
closefile(handle)

Notes

Declaration

function HW2Path()

    execute("dir > dir.txt")
    local handle = openfile([[dir.txt]],"r")
    local filestring = read(handle,"*a")
    closefile(handle)
    local start_of_string
    local count = 65
    while not start_of_string and count < (65+26) do
        start_of_string = strfind(filestring,strchar(count)..[[:]])
        count = count + 1
    end
    if start_of_string then
        return strsub(filestring,start_of_string,strfind(filestring,[[\Bin\Release]]))
    end
end

Authors

Related Pages

UserFunctionReference

Comments

Page Status

Updated Formatting? Initial
Updated for HWRM? Initial