Launch Ancestral Sources Update
Posted: 13 Jul 2011 11:29
May I propose the following update to the Launch Ancestral Sources for ... Entry scripts.
This caters for A.S. 64-bit / 32-bit installation in either X:Program Files or X:Program Files(x86), where X: is usually C: drive, but may be different.
It also checks that A.S. Version 2 is installed by testing for a file that only exists in Version 2.
It finally checks that the FH GEDCOM file exists.
ID:5223
This caters for A.S. 64-bit / 32-bit installation in either X:Program Files or X:Program Files(x86), where X: is usually C: drive, but may be different.
It also checks that A.S. Version 2 is installed by testing for a file that only exists in Version 2.
It finally checks that the FH GEDCOM file exists.
Code: Select all
-- 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
-- Program Files OS Path
strProgramFiles = os.getenv('PROGRAMFILES')
-- Ancestral Sources executable in Program Files
strASexe = '\Ancestral Sources\Ancestral Sources.exe'
-- Ancestral Sources Version 2 xml in Program Files
strASxml = '\Ancestral Sources\Autotext.xml'
-- Program Files path to A.S. Version 2 xml
strASxmlPath = strProgramFiles..strASxml
if not file_exists(strASxmlPath) then
-- Alternative Program Files OS Path on 64-bit PC
strProgramFiles = os.getenv('PROGRAMW6432')
strASxmlPath = strProgramFiles..strASxml
end
if not file_exists(strASxmlPath) then
error('Ancestral Sources Version 2 not installed.')
end
strProgram = strProgramFiles..strASexe
if not file_exists(strProgram) then
error('Ancestral Sources executable not found.')
end
strProjectFile = fhGetContextInfo('CI_GEDCOM_FILE')
if not file_exists(strProjectFile) then
error('Family Historian GEDCOM file not found.')
end
strType = ' -SOURCE CENSUS'
-- Get Currently Selected Record
tblIndi = fhGetCurrentRecordSel('INDI')
if #tblIndi > 0 then
strInd = ' -IND '..fhGetRecordId(tblIndi[1])
else
strInd = ' '
end
strCmd = 'start '' ''..strProgram..'' -FILE '' .. strProjectFile .. '''..strInd..strType
os.execute(strCmd)