* Map Life Facts

Writing and using plugins for Version 5 and above.
User avatar
tatewise
Megastar
Posts: 20571
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts

Post by tatewise » 17 Feb 2021 21:13

I think it is a false assumption that travelling in more or less straight lines between places is the most efficient route.
Especially in cities, knowing the rapid transit layout & timetable may provide more efficient routes.

Anyway, the number of points in the table is irrelevant as long as they are evenly spaced.
The 33 entry table has 11.25 degree intervals but if the intervals were N then the formula becomes:
local index = math.floor( (azim / N) + 0.5 ) + 1
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 678
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Facts

Post by Ron Melby » 18 Feb 2021 18:06

mike,

here is a simple straightforward test program, as I promised that shows some disturbing behavior in a fhSetLabelledText under v 6.72. I would like to see if it does the same under version 7.

Please read before execution,
Although it should blow up and do nothing whatsoever if you run without reading...............lol. but most of my programs blow up.

Code: Select all

--[[

READ THIS FIRST PLEASE:

  please create a minimal source record that is easy to find and delete after the test
  I do not feel comfortable creating and deleting records in your file even if they are test files yet.
  I made a source named delete and put text in the text field and note  in the note field
  
  ****      THEN:
  ]]
local srcID = 0000000000 -- **** put your source number here  

local one = 'one value'
local two = 'two value'
local three 
--[[
defined but nil if not initialized 
but lets pretend we have it coming 
back from a function with a value nil,
or had a thousand records 
with the labelled text field and we didnt need it or wanted 
to change the label? 
in an array, or in a table, set it to nil
so, that sounds like a good idea------------- OR NOT

from the api:
fhSetLabelledText

bOK = fhSetLabelledText(ptr, strLabel, strValue)

Parameters

ptritem pointerstrLabelstring: label to usestrValuestring or nil: if a string, it will be the value set (which can bean empty string). Must not contain any paragraph breaks. If nil, the label and its current value, will be deleted, if found.

yup, looks like it works like it is expected, but does it?
in my version -- windows 10, fh6.7.2 it gives me a rather unexpected result, I would think that since I have no ability to change offsets within pointer note, the system has it handled, and knows how to deal with it.
mine works fine until label three, wipes out NOTE altogether.
how does yours work on v7? 
]]



--MAIN()
local dbg = '' --convenient place to bkp to examine ptrNOTE value
local ptrSOUR = fhNewItemPtr()
local ptrNOTE = fhNewItemPtr()
ptrSOUR:MoveToRecordById('SOUR', srcID)
if ptrSOUR:IsNotNull() then
  ptrNOTE = fhGetItemPtr(ptrSOUR, '~.NOTE2')

  fhSetLabelledText(ptrNOTE, 'label_one = ', one) 
  dbg = fhGetDisplayText(ptrNOTE)

  fhSetLabelledText(ptrNOTE, 'label_two = ', two) 
  dbg = fhGetDisplayText(ptrNOTE)

  fhSetLabelledText(ptrNOTE, 'label_three = ', three)
  dbg = fhGetDisplayText(ptrNOTE)
end

return
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 20571
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts

Post by tatewise » 18 Feb 2021 18:37

You are correct. If the label does not exist, and the value is nil, then the entire Note text is deleted.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 678
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Facts

Post by Ron Melby » 18 Feb 2021 18:53

in your opinion is that considered incorrect behavior and worth me putting in a ticket for 6 and 7?

or am I totally missing something in my programming? (not an unusual situation)
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 20571
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts

Post by tatewise » 18 Feb 2021 20:58

Yes, that is a fault that must be reported to CP.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 678
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Facts

Post by Ron Melby » 18 Feb 2021 21:21

inquiry (#453205) is in our customer support queue

I will apprise all here of any response, or corrections (if known).
FH V.6.2.7 Win 10 64 bit

User avatar
David2416
Famous
Posts: 197
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Map Life Facts

Post by David2416 » 19 Feb 2021 08:21

Certainly should not do that. But Is there a function to test for the existence of a labelled text?

So logic wise
if exists(labelled text) then set(labelled text)

User avatar
tatewise
Megastar
Posts: 20571
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Map Life Facts

Post by tatewise » 19 Feb 2021 11:14

The short answer to your question David is 'YES'. But that should be an unnecessary workaround if the function behaved as specified. What is surprising is it has been 'broken' at least throughout FH V6 and probably FH V5 when it was added.

The long answer is the fhGetLabelledText(...) function returns any value following such a label and an empty string otherwise.
If it returns a value the label exists. If not then the label may or may not exist but has no value so there is still doubt.

The function fhGetValueAsText(...) will return the entire text string which can be searched using string.match(...) for the label.
That is conclusive.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 678
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Facts

Post by Ron Melby » 20 Feb 2021 13:51

Regarding the failure:

Martin sez:

Thank you for reporting that and for providing the very helpful example script. We have confirmed the issue you raise. It will be fixed in the next minor upgrade.

So, you big spenders will get the fix, in your unspecified distant future timeline. I, on 6.7.2, will remain your poor American cousin. Looks like another gob of exception code for those authors using labeled text fields in their plugins, prior to and including current version. I do not use it except in conjunction with map life facts, so I corrected on the order of fhSetLabelledText(ptrNOTE, 'label_three = ', (three or '')) in my partner program in all cases I have set a label.

However I have just realized that I have not added a value 'correctly' in my script, and subsequently set it to nil. and observed what it wiped has eaten. I will report back, correct or not.
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Megastar
Posts: 678
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Facts

Post by Ron Melby » 22 Feb 2021 20:25

fhSetLabelledText works as expected when value is nil and the label exists.

also, mike--

for the start index choosing code, I backed off the /3.75 and also removed the .05 addition keeping the + 1
I changed it to a decimal and multiplied. its at .265 and ran thru my thousand plus addresses, and thousand or so places, with no errors, .266 would overrun it. putting it at 1/3.77 and some change. there were one or two of my azims that it would overrun translated to integer index leading to errors, centered around the mid 40 and mid 60 indexs (which may simply be a function of my addr/plac azims. now I may have several azims that start 2 entries below index, but it it considerably faster than starting at index 1 all the time.
FH V.6.2.7 Win 10 64 bit

Post Reply