* Possible enhancement for Search and Replace
- BillH
- Megastar
- Posts: 2184
- Joined: 31 May 2010 03:40
- Family Historian: V7
- Location: Washington State, USA
Possible enhancement for Search and Replace
Jane,
Would it be possible to add the record name (individual name, place name, etc) to the top of the window? In this way we could know what record we are looking at which would help determine if we want to make the change or not on a particular record.
Thanks,
Bill
ID:6823
Would it be possible to add the record name (individual name, place name, etc) to the top of the window? In this way we could know what record we are looking at which would help determine if we want to make the change or not on a particular record.
Thanks,
Bill
ID:6823
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Possible enhancement for Search and Replace
I'll have a look the Record is not a problem, but it could get quite complicated to look up a place, as text can be found on any level in any record format.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Possible enhancement for Search and Replace
Jane, this may be an example of where it would be useful to have an FH API Function that translates a Pointer into a Data Reference string (or similar) that LUA can manipulate.
See my thread Save/Load FH Item Pointer.
See my thread Save/Load FH Item Pointer.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Possible enhancement for Search and Replace
I think there is a code spinet which does that, it just needs enhancing to do the indexes, it's easy enough to move back up the tree, the problem is for me to work out a good global display option.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Possible enhancement for Search and Replace
I'll have a look at the Build Data Reference Function (code spinet) [sic]!
See if I can incorporate instance indexes.
See if I can incorporate instance indexes.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Possible enhancement for Search and Replace
Jane, I have modified the Code Snippet function to cope with instance indexes, and written a complementary function to convert the Data Ref back to a Pointer.
Could you review and test them please, before I add them to Code Snippet library?
Could you review and test them please, before I add them to Code Snippet library?
Code: Select all
--[[
@function: TblDataRef
@description: Get Full Data Reference for Pointer
@parameters: Item Pointer
@returns: Table of RecId, RecTag, DataRef
@requires: None
]]
function TblDataRef(ptrRef)
local tblRef = { RecId=0, RecTag='', DataRef='' }
-- getDataRef() is called recursively per level of the Data Ref
-- ptrRef points to the upper Date Ref levels yet to be analysed
-- strRef compiles the lower Data Ref levels including instances
local function getDataRef(ptrRef,strRef)
local ptrTag = ptrRef:Clone()
local strTag = fhGetTag(ptrTag) -- Current level Tag
ptrTag:MoveToParentItem(ptrTag)
if ptrTag:IsNotNull() then -- Parent level exists
local intSib = 1
local ptrSib = ptrRef:Clone() -- Pointer to siblings with same Tag
ptrSib:MovePrev('SAME_TAG')
while ptrSib:IsNotNull() do -- Count previous siblings with same Tag
intSib = intSib + 1
ptrSib:MovePrev('SAME_TAG')
end
if intSib > 1 then strTag = strTag..'['..intSib..']' end
getDataRef(ptrTag,'.'..strTag..strRef) -- Now analyse the parent level
else
tblRef.RecId = fhGetRecordId(ptrRef) -- Record level reached, so set table data fields
tblRef.RecTag = strTag
tblRef.DataRef = strTag..strRef
if not fhIsValidDataRef(tblRef.DataRef) then print(tblRef.DataRef..' is Invalid') end
end
end -- local function getDataRef
if type(ptrRef) == 'userdata' then getDataRef(ptrRef,'') end
return tblRef
end -- function TblDataRef
--[[
@function: PtrDataRef
@description: Get Pointer for Full Data Reference
@parameters: Table of RecId, RecTag, DataRef
@returns: Item Pointer
@requires: None
]]
function PtrDataRef(tblRef)
local tblRef = tblRef or {} -- Ensure table and its fields exist
local intId = tblRef.RecId or 0
local strTag = tblRef.RecTag or ''
local strRef = tblRef.DataRef or ''
local ptrRef = fhNewItemPtr()
ptrRef:MoveToRecordById(strTag,intId) -- Lookup the Record by Id
ptrRef:MoveTo(ptrRef,strRef) -- Move to the Data Ref
return ptrRef
end -- function PtrDataRef
-- Example of Use
local ptrRec = fhNewItemPtr()
local ptrRef = fhNewItemPtr()
local tblRef = {}
for intRec, strRec in ipairs({'INDI','FAM','NOTE','SOUR','REPO','SUBR','SUBM','OBJE'}) do
ptrRec:MoveToFirstRecord(strRec)
ptrRef = ptrRec:Clone()
while ptrRef:IsNotNull() do
tblRef = TblDataRef(ptrRef)
ptrRef = PtrDataRef(tblRef)
if ptrRef:IsNull() then
print(tblRef.DataRef..' Is Null')
else
print(tblRef.DataRef..' '..fhGetDisplayText(ptrRef))
end
ptrRef:MoveNextSpecial()
fhSleep(2,1)
end
end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Possible enhancement for Search and Replace
Mike I think that's OK. Obviously if someone edits the data between saving and loading the references, there could be a problem.
Bill, I have modified the Search & Replace routine to give more information on the Replace Prompt.
https://www.dropbox.com/s/q30ry7741zrx5 ... ace.fh_lua
Can you give it a try before I publish it to the store.
Thanks
Bill, I have modified the Search & Replace routine to give more information on the Replace Prompt.
https://www.dropbox.com/s/q30ry7741zrx5 ... ace.fh_lua
Can you give it a try before I publish it to the store.
Thanks
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Possible enhancement for Search and Replace
Jane, would it be OK to simply replace the existing Build Data Reference Function (code snippet) with both my new functions?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- BillH
- Megastar
- Posts: 2184
- Joined: 31 May 2010 03:40
- Family Historian: V7
- Location: Washington State, USA
Possible enhancement for Search and Replace
Jane,
That looks great. That will really help.
Thanks!
Bill
That looks great. That will really help.
Thanks!
Bill
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Possible enhancement for Search and Replace
I was thinking about the return from TblDataRef and wonder if it would be more 'Lua' to return the three values rather than a table with them in, that way it could be called BuildDataRef and return the 3 values as ref, recId, tagtatewise said:
Jane, would it be OK to simply replace the existing Build Data Reference Function (code snippet) with both my new functions?
That way it would be a direct exchange for the current one.
With the extra parameters available if needed
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Possible enhancement for Search and Replace
Or we could redefine BuildDR as and add both my new functions.
Otherwise, if we adopt your proposal, would the complementary function become PtrDataRef(strDataRef,strRecTag,intRecId) and are you happy with that name?
Code: Select all
function BuildDR(ptrRef)
local tblRef = TblDataRef(ptrRef)
return tblRef.DataRef, tblRef.RecTag, tblRef.RecId
endOtherwise, if we adopt your proposal, would the complementary function become PtrDataRef(strDataRef,strRecTag,intRecId) and are you happy with that name?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Possible enhancement for Search and Replace
I am happy with the name, but wondered if it might be more fh function like as
getPtrFromReference ?
getPtrFromReference ?
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Possible enhancement for Search and Replace
OK, the existing FH API functions are:
ptr = fhGetItemPtr(...)
ptr = fhNewItemPtr()
so perhaps a better matching name is:
ptr = GetDataRefPtr(strDataRef,strRecTag,intRecId)
Even better would be a method:
ptr:MoveToDataRef(strDataRef,strRecTag,intRecId)
but I have not been able to work out how to do that.
ptr = fhGetItemPtr(...)
ptr = fhNewItemPtr()
so perhaps a better matching name is:
ptr = GetDataRefPtr(strDataRef,strRecTag,intRecId)
Even better would be a method:
ptr:MoveToDataRef(strDataRef,strRecTag,intRecId)
but I have not been able to work out how to do that.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- johnmorrisoniom
- Megastar
- Posts: 882
- Joined: 18 Dec 2008 07:40
- Family Historian: V7
- Location: Isle of Man
Re: Possible enhancement for Search and Replace
Is it possible for this plug to search and replace dates in source citations.
Mike's statistics plugin has highlighted a lot of invalid dates have somehow crept into my file (over 200 31 Nov 2008) I don't like have to use notepad to do the job.
Mike's statistics plugin has highlighted a lot of invalid dates have somehow crept into my file (over 200 31 Nov 2008) I don't like have to use notepad to do the job.
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: Possible enhancement for Search and Replace
It's not idea to replace dates using the Text search and replace, but a Date search and replace should be possible.
There is already a plugin which searches and returns a result set
http://www.family-historian.co.uk/plugi ... try?id=289
Can you take a look and see if it can find your problem dates.
If so it should be possible to produce a replacing version.
There is already a plugin which searches and returns a result set
http://www.family-historian.co.uk/plugi ... try?id=289
Can you take a look and see if it can find your problem dates.
If so it should be possible to produce a replacing version.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- johnmorrisoniom
- Megastar
- Posts: 882
- Joined: 18 Dec 2008 07:40
- Family Historian: V7
- Location: Isle of Man
Re: Possible enhancement for Search and Replace
I have already tried that plugin as well. Neither will deal with a source citation date. (Not the date of the fact itself)
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Possible enhancement for Search and Replace
I have written a quick and dirty update to Search and Replace available from my SkyDrive Search and Replace MBT.
Double-click on popup to download and install.
It should cope with most Dates in any field, just leave the Dates option ticked to be on the safe side.
[EDIT]
I believe this version is now quite robust, and copes with any option settings, and works for any date formats, and validates the replacement date with optional override.
Double-click on popup to download and install.
It should cope with most Dates in any field, just leave the Dates option ticked to be on the safe side.
[EDIT]
I believe this version is now quite robust, and copes with any option settings, and works for any date formats, and validates the replacement date with optional override.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: Possible enhancement for Search and Replace
Strange I have just put in a citation date of 2018 and the search found the citation date fine.
Are the dates you are looking for actually date phrases?
Are the dates you are looking for actually date phrases?
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Possible enhancement for Search and Replace
John said
I have just tried the Plugin with a Citation Entry Date of 32 November 2000.
It would only find this date if I entered just the year 2000, but not if I entered November 2000 or 32 November 2000.
It did find such full dates in Fact Date fields, so something about Citation Entry Dates is not working.
The explanation is that this Plugin does not recognise invalid Dates and that is exactly what John is looking for!!
If I change the line: then it finds the invalid Dates OK.
So, they can't be Date Phrases if my Show Project Statistics Plugin reported them as invalid Dates.Mike's statistics plugin has highlighted a lot of invalid dates
I have just tried the Plugin with a Citation Entry Date of 32 November 2000.
It would only find this date if I entered just the year 2000, but not if I entered November 2000 or 32 November 2000.
It did find such full dates in Fact Date fields, so something about Citation Entry Dates is not working.
The explanation is that this Plugin does not recognise invalid Dates and that is exactly what John is looking for!!
If I change the line:
Code: Select all
local days = {39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39}Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- johnmorrisoniom
- Megastar
- Posts: 882
- Joined: 18 Dec 2008 07:40
- Family Historian: V7
- Location: Isle of Man
Re: Possible enhancement for Search and Replace
I had a similar date problem with the Change any fact plugin.
If i use the exact date of the fact I want to change, no facts are found. But putting in just the year does work.
Likewise with the place match option. If I put in just "Manchester", then no matches are found. The field has to be input as "Manchester, Lancashire, England" to be an exact match with my file
If i use the exact date of the fact I want to change, no facts are found. But putting in just the year does work.
Likewise with the place match option. If I put in just "Manchester", then no matches are found. The field has to be input as "Manchester, Lancashire, England" to be an exact match with my file
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Possible enhancement for Search and Replace
Replies to this last posting continue in thread Change Any Fact Tag filters (10861)...
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Possible enhancement for Search and Replace
A revised update to Search and Replace is available from my SkyDrive Search and Replace MBT.
Double-click on popup to download and install.
It should cope with dates in any field.
I believe this version is now quite robust, copes with any option settings, works for any date formats, and validates the replacement date with optional override.
Double-click on popup to download and install.
It should cope with dates in any field.
I believe this version is now quite robust, copes with any option settings, works for any date formats, and validates the replacement date with optional override.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Possible enhancement for Search and Replace
John has successfully used this enhanced Plugin version, and I have run a few tests.
Jane, perhaps you could also give it the once over.
There are very few actual changes, and I have clearly marked them.
If all OK, perhaps you could put it in the Plugin Store.
Jane, perhaps you could also give it the once over.
There are very few actual changes, and I have clearly marked them.
If all OK, perhaps you could put it in the Plugin Store.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: Possible enhancement for Search and Replace
Hi Mike,
A couple of comments.
1. If you do something silly like swap JUN for HLP and click do all, you then can't abort the process when the invalid date field errors come up.
2. I have noticed the source is now double spaced in some places, if you look in an hex editor it has two line feeds followed by a carriage return. Are you using a text editor which is causing this as I can't get them in the Plugin editor.
A couple of comments.
1. If you do something silly like swap JUN for HLP and click do all, you then can't abort the process when the invalid date field errors come up.
2. I have noticed the source is now double spaced in some places, if you look in an hex editor it has two line feeds followed by a carriage return. Are you using a text editor which is causing this as I can't get them in the Plugin editor.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Possible enhancement for Search and Replace
1. Good point - Have changed the buttons to Yes No Cancel and included the context Details in message.
2. I am using the standard FH Plugins editor, but I tend to use tab chars a lot to indent code instead of space chars, so perhaps SkyDrive is wrapping the text. I have now converted all tabs back to spaces.
I have tried SkyDrive downloads and nothing gets changed for me.
Checked text using Notepad++ in Hex.
I could not find two LF (0A) and one CR (0D), but there are plenty of two CR (0D) and one LF (0A), and only in your original code, as my newly inserted code only appears to have one CR (0D) and one LF (0A).
All my own Plugins have one CR (0D) and one LF (0A).
Your original 'Search and Replace' appears to have two CR (0D) and one LF (0A) everywhere.
So not sure what is happening there.
2. I am using the standard FH Plugins editor, but I tend to use tab chars a lot to indent code instead of space chars, so perhaps SkyDrive is wrapping the text. I have now converted all tabs back to spaces.
I have tried SkyDrive downloads and nothing gets changed for me.
Checked text using Notepad++ in Hex.
I could not find two LF (0A) and one CR (0D), but there are plenty of two CR (0D) and one LF (0A), and only in your original code, as my newly inserted code only appears to have one CR (0D) and one LF (0A).
All my own Plugins have one CR (0D) and one LF (0A).
Your original 'Search and Replace' appears to have two CR (0D) and one LF (0A) everywhere.
So not sure what is happening there.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry