-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAncestral Sources Census Entry.fh_lua
62 lines (60 loc) · 1.99 KB
/
Ancestral Sources Census Entry.fh_lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--[[
@Title: Launch Ancestral Sources for Census Entry
@Author: Jane Taubman
@LastUpdated: July 2011
@Version: 1.6
@Description: Launches Ancestral Sources for the Current Project
and with the current selected person, for Census entry.
@Changes
1.5: Added automatic search for Ancestral Sources in Both possible locations on x64 systems
1.6: Added check for the Autotext file which only exists in V2.
]]
-- Check if file exists
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true
else
return false
end
end
strProjectFile = fhGetContextInfo("CI_GEDCOM_FILE")
strProgramFiles = os.getenv('PROGRAMFILES')
strBaseProgram = '\\Ancestral Sources\\Ancestral Sources.exe'
bAsFound = false
-- Find Ancestral Sources in Program Files or Program Files x86
if file_exists(strProgramFiles..strBaseProgram) then
bAsFound = true
else
strProgramFiles = os.getenv('PROGRAMW6432')
if strProgramFiles ~= nil and strProgramFiles ~= '' then
if file_exists(strProgramFiles..strBaseProgram) then
bAsFound = true
end
end
end
if bAsFound then
--- Check for AS V2
strProgram = strProgramFiles..strBaseProgram
strCheckFile = strProgramFiles..'\\Ancestral Sources\\Autotext.xml'
if not(file_exists(strCheckFile)) then
fhMessageBox('Ancestral Sources Is Not Version 2')
return
else
strType = ' -SOURCE CENSUS'
-- Get Currently Selected Record
tblIndi = fhGetCurrentRecordSel('INDI')
if #tblIndi > 0 then
strInd = ' -IND '..fhGetRecordId(tblIndi[1])
else
strInd = ' '
end
bOK, iErrorCode, strErrorText = fhShellExecute(strProgram , ' -FILE "' .. strProjectFile .. '"'..strInd..strType)
if bOK then
return
else
fhMessageBox(strErrorText..' ('..iErrorCode..')')
end
end
else
fhMessageBox('Ancestral Sources Not Found')
end