-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPossible Problem - Set Ignore Markers.fh_lua
96 lines (93 loc) · 3.04 KB
/
Possible Problem - Set Ignore Markers.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
--[[
@Title: Possible Problem Marker
@Author: Jane Taubman
@LastUpdated: May 2012
@Version: 1.1
@Description: Companion to Possible Problem Marker,
this allows Events to be marked as "Ignore" so that they are
not listed on the Possible Problem Report.
1.1 Update for Store
]]
require "iuplua"
require "scraps._tableloadsave"
function getAllFacts(ptr)
local ptrItems = {}
local dspList = {}
local markList = {}
local recordList = {ptr}
local ptrEvent = fhNewItemPtr()
local ptrDate = fhNewItemPtr()
for i,ptr in ipairs(recordList) do
ptrEvent:MoveToFirstChildItem(ptr)
while ptrEvent:IsNotNull() do
if fhIsFact(ptrEvent) then
ptrDate:MoveTo(ptrEvent,'~.DATE')
warning = ""
if ptrDate:IsNotNull() then
warning = fhCallBuiltInFunction('GetDataWarning',ptrDate,1)
if warning ~= "" then
warning=" ~~Warning~~"
end
end
local tblRecord = {recordid=fhGetRecordId(ptr),
type=fhGetTag(ptr),
date=fhGetItemText(ptrEvent,'~.DATE'),
plac=fhGetItemText(ptrEvent,'~.PLAC'),
tag=fhGetTag(ptrEvent),
value=fhGetItemText(ptrEvent,'~')}
table.insert(ptrItems,tblRecord)
table.insert(dspList,fhGetDisplayText(ptrEvent)..'('..fhGetTag(ptrEvent)..')'..warning)
table.insert(markList,checkMark(tblRecord))
end
if fhGetTag(ptrEvent) == 'FAMS' then
table.insert(recordList,fhGetValueAsLink(ptrEvent))
end
ptrEvent:MoveNext('ANY')
end
end
return ptrItems,dspList,markList
end
function buildIndex(record)
return (record.type..'|'..record.recordid..'|'..record.tag..'|'..record.date..'|'..record.plac..'|'..record.value)
end
function checkMark(record)
local mark = 0
if Settings[buildIndex(record)] ~= nil then
mark = 1
end
return mark
end
--------------------------------------------------------------Main Code
strSettings = fhGetPluginDataFileName()
-- Fix File name
strSettings =strSettings:gsub('Data\\.-\.dat','Data\\Possible Problem Manager.dat')
Settings = table.load(strSettings)
if Settings == nil then Settings = {} end -- First Run set empty Settings File
-- Get Current Record abort if none.
ptrList = fhGetCurrentRecordSel('INDI')
if ptrList[1] == nil then
error('No Record - Currently Selected')
end
ptrItems,dspList,markList = getAllFacts(ptrList[1])
table.insert(dspList,1,'Clear All Marks')
table.insert(markList,1,0)
error = iup.ListDialog(2,"Mark Events To Be Ignored - Ctrl Click to select more than one",#dspList,dspList,0,40,15,markList)
bClear = false
if error == -1 then
return
else
for i,mark in ipairs(markList) do
if i == 1 and mark == 1 then
bClear = true
end
if i > 1 then
idx = buildIndex(ptrItems[i-1])
if (mark == 1) and not(bClear) then
Settings[idx] = 1
else
Settings[idx] = nil
end
end
end
end
table.save(Settings,strSettings)