JScript help with 'collections'
GenoPro Home  |  Get Started With My Genealogy Tree  |  Buy  |  Login  |  Privacy  |  Search  |  Site Map
 
GenoPro Support Forum
Home        Members    Who's On
Welcome Guest ( Login | Register )
        



JScript help with 'collections' Expand / Collapse
Author
Message
Post #21375 Posted 4/15/2008 5:06:17 PM


Famous Writer

Famous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous Writer This user is a contributor to FamilyTrees.GenoPro.com This user is an important contributor to the translation of GenoPro This user is an important contributor to the GenoPro community 

Group: Customers
Last Login: Today @ 3:47:33 AM
GenoPro Version: 2.0.1.6
Posts: 438, Visits: 1,170
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
Post #21378 Posted 4/15/2008 8:27:09 PM


IT Director GenoPro

IT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoPro  

Group: Customers
Last Login: Today @ 1:09:47 PM
GenoPro Version: 2.0.1.6
Posts: 447, Visits: 5,850
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


If the facts don't fit the theory, change the facts.
-- Albert Einstein

Jean-Claude Morin
Information Technology Director, GenoPro.
http://www.genopro.com

Post #21379 Posted 4/15/2008 8:34:44 PM


Legendary Master

Legendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary Master This user is an important contributor to the translation of GenoPro 

Group: Administrators
Last Login: Today @ 2:29:20 PM
GenoPro Version: 2.0.1.6
Posts: 3,450, Visits: 14,359
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.

Post #21382 Posted 4/16/2008 6:51:20 AM


Grand Master

Grand MasterGrand MasterGrand MasterGrand MasterGrand MasterGrand MasterGrand MasterGrand Master This user is a contributor to FamilyTrees.GenoPro.com This user is an important contributor to the GenoPro community 

Group: Customers
Last Login: Today @ 2:36:42 PM
GenoPro Version: 2.0.1.6
Posts: 1,093, Visits: 5,015
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"
Post #21386 Posted 4/16/2008 8:58:51 AM


Legendary Master

Legendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary MasterLegendary Master This user is an important contributor to the translation of GenoPro 

Group: Administrators
Last Login: Today @ 2:29:20 PM
GenoPro Version: 2.0.1.6
Posts: 3,450, Visits: 14,359
Ron is a very smart man.

Post #21389 Posted 4/16/2008 11:36:23 AM


Famous Writer

Famous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous Writer This user is a contributor to FamilyTrees.GenoPro.com This user is an important contributor to the translation of GenoPro This user is an important contributor to the GenoPro community 

Group: Customers
Last Login: Today @ 3:47:33 AM
GenoPro Version: 2.0.1.6
Posts: 438, Visits: 1,170
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

Post #21445 Posted 4/21/2008 2:08:21 PM


Famous Writer

Famous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous WriterFamous Writer This user is a contributor to FamilyTrees.GenoPro.com This user is an important contributor to the translation of GenoPro This user is an important contributor to the GenoPro community 

Group: Customers
Last Login: Today @ 3:47:33 AM
GenoPro Version: 2.0.1.6
Posts: 438, Visits: 1,170
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

  Post Attachments 
Customized_Display_Multi-Lang_Fields.zip (0 views, 3.97 KB)

Post #21446 Posted 4/21/2008 2:25:40 PM


IT Director GenoPro

IT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoProIT Director GenoPro  

Group: Customers
Last Login: Today @ 1:09:47 PM
GenoPro Version: 2.0.1.6
Posts: 447, Visits: 5,850
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