GenoPro Home
GenoPro Home  |  Get Started With My Genealogy Tree  |  Buy  |  Login  |  Privacy  |  Search  |  Site Map
 

GenoPro Support Forum




JScript help with 'collections'

Click to view RSS...
Author Is it possible to access these fields, one by one, in order to process them in a loop
Posted Tuesday, April 15, 2008 - Post #21375
Famous Writer

Famous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous Writer

Important Contributors
FamilyTrees.GenoPro.com
Customers
Translator
GenoPro version: 2.0.1.6

Last Login: Tuesday, December 16, 2008
Posts: 390, Visits: 1,271
This post is, I suppose, directed to Ron because JScript programming related.
I'm trying to create a utility (similar to 'Display all Comments') regarding display of 'all Multi-Language Fields'.
If I was a 'JScript' guru, it would surely be done by now but I'm not. I also read some WWW Ref sites articles but I couln't found any clear explanations of what I would like to achieve.
For info, I used to be fully conversant for manipulating fields associated with 'relational databases' such as Foxpro. Having said that, I don't master at all your 'Collections' even after reading you various SDK help articles.
What I'm trying to do is to access some fields names (and values) in your various collections.
Say each Ind record in the Ind collection has many fields: name.first, birth.date, birth.place, ...
Question: Is it possible to access these fields, one by one, in order to process them in a loop, e.g.
field(1).name = name.first  ; field(1).value = "Jean-Claude" ; field(1).type = string/text (say the 1st field in an Ind record)
field(2).name = birth.date  ; field(2).value = "7 Mar 1950" ; field(2).type = date
field(3).name = birth.place ; field(3).value = "Paris" ; field(3).type = string/text
... and so on, till the field().count (the last field in that Ind record).
You'll probably have to substitute the words 'record' and 'field' to suit your 'collection' language, i.e. keys and whatever.
The above is perhaps a bit simplistic but I really would like to know if it is achievable! At the moment I cannot 'visualize' the structure of a collection, compared to a database with clear records (rows) and fields (columns).
Thank you.
JC


Edited: Tuesday, April 15, 2008 by GenoProSupport
Posted Tuesday, April 15, 2008 - Post #21378
Forum Master

Forum MasterForum MasterForum MasterForum MasterForum MasterForum MasterForum MasterForum MasterForum Master

Gamma
Moderators
Administrators
FamilyTrees.GenoPro.com
Customers
GenoPro version: 3.1.0.1

Last Login: Monday, May 12, 2025
Posts: 952, Visits: 10,077
My understanding of your question is: "Can you enumerate all the properties or fields for a given object".

To the best of my knowlegde, the answer is NO. The properties of an object are listed in the Tag Definition dialog, where each tab displays the property of the selected object (individual, family, picture, occupation, source, ...).

For instance, if you wish to write the name and birth date of every individuals you could use the following code:

for (var i = 0; i < Individuals.Count; i++)
{
  var ind = Individuals(i);
  if (!ind.IsDead) // Exclude any individual deceased
  {
     // The individual is alive, so fetch his/her birthday
     var strBirthday = ind.Birthday.ToString("MMMM d");
     if (strBirthday != "")
     {
        Report.Write3Br("<br/><b>", strBirthday, "</b>");
        // Write the name of the individual in the page
        Report.WriteBr(ind.Name);
      }
   }
}


This example has been slightly modified from the build-in skin "Birthday Listing" in GenoPro


Edited: Tuesday, April 15, 2008 by JcMorin
Posted Tuesday, April 15, 2008 - Post #21379
Legendary Master

Legendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary Master

Administrators
Moderators
Customers
Gamma
FamilyTrees.GenoPro.com
Translator
GenoPro version: 3.1.0.1

Last Login: Monday, June 2, 2025
Posts: 4,886, Visits: 22,796
The only way to get all the fields is to extract the XML and parse the XML content.  This is what Ron did for displaying the custom tags in the Narrative Report.
Posted Wednesday, April 16, 2008 - Post #21382
Legendary Master

Legendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary Master

Administrators
Customers
Important Contributors
FamilyTrees.GenoPro.com
GenoPro version: 3.1.0.1

Last Login: Friday, July 11, 2025
Posts: 3,428, Visits: 26,569
If you just want to obtain the values from a predefined list of fields then you can using a GenoObject's TagValue method to get its value.

The following script will create a two dimensional array of records and fields, with each field createed an a javascript object having a name and value property. It then displays the data into the GenoPro Message Log. (but note that genopro skips duplicate messages in the log). The fields to be selected are preset in the array fieldnames.

<%[
var fieldnames = new Array('Name', 'Name.Display','Name.First', 'Name.Middle', 'Name.Last','MyCustomTag'); // create list of required fields (change as required)
var i, records=new Array(Individuals.Count);
for (var iCnt = 0; iCnt < Individuals.Count; iCnt++) {               // loop over Individuals collection
 records[iCnt] = new Array();
 i = Individuals(iCnt);
 for (fCnt in fieldnames) {
 records[iCnt][fCnt] = new Object();
  try {                                                                           // trap error when Custom tag field does not exist for this record
   records[iCnt][fCnt].name = fieldnames[fCnt];                    // store field name
   records[iCnt][fCnt].value = i.TagValue(fieldnames[fCnt]);   // store field contents
  } catch(e) {
  // Report.LogError(e.description);
  }
 }
 Report.LogWarning('Data for ' + i.Name);
 for (var fCnt in records[iCnt]) {       // display selected field for each Individual
  Report.LogWarning('  '+records[iCnt][fCnt].name + '=' + records[iCnt][fCnt].value);
 }
}
Report.AbortReport();
]%>

Collections can be considered as sets of records, with properties of each object/record in the collection corresponding to fields or 'tags'. Some of the 'fields' i.e. custom tags are optional and may not appear in all records.


'lego audio video erro ergo disco' or "I read, I listen, I watch, I make mistakes, therefore I learn"


Edited: Wednesday, April 16, 2008 by Ron
Posted Wednesday, April 16, 2008 - Post #21386
Legendary Master

Legendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary Master

Administrators
Moderators
Customers
Gamma
FamilyTrees.GenoPro.com
Translator
GenoPro version: 3.1.0.1

Last Login: Monday, June 2, 2025
Posts: 4,886, Visits: 22,796
Ron is a very smart man.
Posted Wednesday, April 16, 2008 - Post #21389
Famous Writer

Famous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous Writer

Important Contributors
FamilyTrees.GenoPro.com
Customers
Translator
GenoPro version: 2.0.1.6

Last Login: Tuesday, December 16, 2008
Posts: 390, Visits: 1,271
Thank you all but I gave up.

As I said, I cannot properly 'visualize' how a collection is built/structured so there's no point in continuing further.

Thanks again,

JC

Edited: Wednesday, April 16, 2008 by jcguasp

Posted Monday, April 21, 2008 - Post #21445
Famous Writer

Famous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous Writer

Important Contributors
FamilyTrees.GenoPro.com
Customers
Translator
GenoPro version: 2.0.1.6

Last Login: Tuesday, December 16, 2008
Posts: 390, Visits: 1,271
I finally didn't give up because I don't like unfinished business.
I produced the attached file but it's far from perfect. This utility jscript will allow Users interested in Multi-Linguistic Fields (MLFs) to check-up their fields.
After realizing that tags cannot easily be accessible/enumerated from collections, I added some 'Tags Arrays', as seen on Ron's code, based on the Tag Definitions panel tabs.
I selected some 'Text' fields which should be candidate for MLFs. I hope I didn't forget any!

Various obs noticed during the script implementation:
1) The 'Unions' collection is not supported. In order to enumerate the Unions MLFs, I created a collection during the 'Families' process. Unless I miss something, this Fam Unions collection should exist, similar to an Ind Edu or Occu.
2) The 'ID' tag of the Emotional Relationships, Social Relationships, Labels, Shapes and Pedigree Links are not generated by Genopro.
3) Picture object: the 'Comment' and 'Description' Tags are the same. One tag, to my opinion, is therefore redundant. I only processed the 'Comment' tag in the attached file as it's the one shown in the Pict layout panel. Also for info, the tag recorded in the .xml file is 'Description'!
4) The Shape 'Position' tag doesn't seem to be supported. It's blank in the report. For the report, I used the 'Position.Points' tag.
5) Regarding the 'Custom Tags' (CTs), I noticed a 'Tag' tag within the Document root object but nothing appears in the report so I suspect this 'Tag' tag feature is not supported/implemented. In consequence, the attached file doesn't include any CTs MLFs.

For the Users using MLFs, extract the .zip file, copy/move the extracted Dir into your Skins Dir and run a report.
I tested the attached with my own tree, including many additional dummy MLFs, and the Report looks fine.
Thank you,
JC

Update: the attached file 12th May 2008

Customized_Display_Multi-Lang_Fields.zip (73 views, 3.97 KB)

Edited: Monday, May 12, 2008 by jcguasp

Posted Monday, April 21, 2008 - Post #21446
Forum Master

Forum MasterForum MasterForum MasterForum MasterForum MasterForum MasterForum MasterForum MasterForum Master

Gamma
Moderators
Administrators
FamilyTrees.GenoPro.com
Customers
GenoPro version: 3.1.0.1

Last Login: Monday, May 12, 2025
Posts: 952, Visits: 10,077
2) The 'ID' tag of the Emotional Relationships, Social Relationships, Labels, Shapes and Pedigree Links are not generated by Genopro.

GenoPro 2007 does not have a tag ID for those objects.  The rationale is those IDs were unused by GenoPro, since no object would link them.  For instance, it is impossible to create a link to a label or a shape.  The lack of a unique identifier for every object prevents a third party to store the XML in a relational database.

We have fixed this issue for the next version.  The version we are currently using has a dedicated ID for every object - this is a requirement for the collaboration module since we need to compare and merge objects based on the XML content from the client and the master copy on the server.

Edited: Tuesday, July 29, 2008 by GenoProSupport

Posted Friday, April 25, 2008 - Post #21503
Legendary Master

Legendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary Master

Administrators
Customers
Important Contributors
FamilyTrees.GenoPro.com
GenoPro version: 3.1.0.1

Last Login: Friday, July 11, 2025
Posts: 3,428, Visits: 26,569
jcguasp (4/21/2008)
I finally didn't give up because I don't like unfinished business.

Well done for persevering with this, unless you try, how do you know what you can achieve?

I like a challenge too so I hope you don't mind me messing with your script to add the missing Custom Tag , Tagdata  and Document fields.

I used perhaps a bit of trickery but left one or two cryptic clues in the script. I have only noticed one minor issue: It will also report phrase templates in Document Custom Tags because of the '{?' test. This could be circumvented using a regular expression test instead. I'll leave that for another day or perhaps as an exercise for the reader Smile


'lego audio video erro ergo disco' or "I read, I listen, I watch, I make mistakes, therefore I learn"


Customized_Display_Multi-Lang_Fields.zip (70 views, 3.96 KB)


Similar Topics

Click to view RSS...
Expand / Collapse

Reading This Topic

Expand / Collapse
Active: 2 - 1 guest, 0 members, 0 anonymous.
Refresh
No members currently viewing this topic!