-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDelete All Local Notes.fh_lua
57 lines (54 loc) · 1.51 KB
/
Delete All Local Notes.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
--[[
@Title: Delete all local Notes
@Author: Jane Taubman
@Version: 0.1
@LastUpdated: March 2014
@Description: Deletes all Local Notes attached to Family or Individual Records.
]]
function main()
-- List everyitem in all record types
for ptr in allItems('INDI','FAM') do
if fhGetTag(ptr) == 'NOTE2' then
print(fhGetTag(ptr),fhGetDisplayText(ptr))
fhDeleteItem(ptr)
end
end
end
------------------------------------------------------ functions
function allItems(...)
local iTypeCount = nil
local iPos = 1
local p1 = fhNewItemPtr()
local p2 = fhNewItemPtr()
local tblRecTypes = {}
if arg['n'] == 0 then
-- No parameter do all Record Types
iTypeCount = fhGetRecordTypeCount() -- Get Count of Record types
for i = 1,iTypeCount do
tblRecTypes[i] = fhGetRecordTypeTag(i)
end
else
-- Got Parameters Process them instead
tblRecTypes = arg
iTypeCount = arg['n']
end
p1:MoveToFirstRecord(tblRecTypes[iPos])
return function()
repeat
while p1:IsNotNull() do
p2:MoveTo(p1)
p1:MoveNextSpecial()
if p2:IsNotNull() then
return p2
end
end
-- Loop through Record Types
iPos = iPos + 1
if iPos <= iTypeCount then
p1:MoveToFirstRecord(tblRecTypes[iPos])
end
until iPos > iTypeCount
end
end
------------------------------------------------------ main
main()