Resolved Another issue from a beginner C# programmer.

C# learner

Active member
Joined
Dec 22, 2022
Messages
40
Programming Experience
Beginner
I created a method that uses a value parameter to be used to find a record in a file and out parameters. I learned how to get the out parameters initialized, but having trouble with the first parameter, idIndividualID. I don't want to null the field because the value is used in the if statement to find the correct record. Why is the field highlighted in red? Error says " The name idIndividualID does not exist in the current context".
C#:
 static void FindIndRecord (string idIndividualID, // field in question
                                          out string idSurname,
                                          out string idGivenName,
                                          out string idBirthDate,
                                          out string idBirthPlace,
                                          out string idMarriageDate,
                                          out string idMarriagePlace,
                                          out string idDeathDate,
                                          out string idDeathPlace,
                                          out string idSex,
                                          out string idChildCode,
                                          out string idParentCode)
                             
                {
                   
                    idSurname = null;
                    idGivenName = null;
                    idBirthDate = null;
                    idBirthPlace = null;
                    idMarriageDate = null;
                    idMarriagePlace = null;
                    idDeathDate = null;
                    idDeathPlace = null;
                    idSex = null;
                    idChildCode = null;
                    idParentCode = null;
                }

                {   
                    // While control variable
                    string recordLine;
                   

                    string path = (@"C:\Users\steve\OneDrive\Documents\Donna's Documents\Steves stuff\Family Tree Development Folder\GEDCOM Individual Data.csv");
                    using StreamReader id = new StreamReader(path, true);
                    {
                        while ((recordLine = id.ReadLine()) != null)
                        {
                           
                            // using the split method to parse "line" into lineParts array
                            string[] lineParts = recordLine.Split(',');

                            //string trimIndividualID = null;
                             if (lineParts[1] = idIndividualID  //field in question
                            {
                                string idSurname = (lineParts[2] != null && lineParts[2] != " ") ? lineParts[2] : " ";
                                string idGivenName = (lineParts[3] != null && lineParts[3] != " ") ? lineParts[3] : " ";
                                string idBirthDate = (lineParts[4] != null && lineParts[4] != " ") ? lineParts[4] : " ";
                                string idBirthPlace = (lineParts[5] != null && lineParts[5] != " ") ? lineParts[5] : " ";
                                string idMarriageDate = (lineParts[6] != null && lineParts[6] != " ") ? lineParts[6] : " ";
                                string idMarriagePlace = (lineParts[7] != null && lineParts[7] != " ") ? lineParts[7] : " ";
                                string idDeathDate = (lineParts[8] != null && lineParts[8] != " ") ? lineParts[8] : " ";
                                string idDeathPlace = (lineParts[9] != null && lineParts[9] != " ") ? lineParts[9] : " ";
                                string idSex = (lineParts[10] != null && lineParts[10] != " ") ? lineParts[10] : " ";
                                string idChildCode = (lineParts[11] != null && lineParts[11] != " ") ? lineParts[11] : " ";
                                string idParentCode = (lineParts[12] != null && lineParts[12] != " ") ? lineParts[12] : " ";

                                Array.Clear(lineParts, 0, lineParts.Length);
                                return;
                            }
                           
                        }
                    }
                }
 
Unless you are really intent on rolling your own GEDCOM parser, perhaps use someone else's instead:

As an aside, that data format looks like something someone who was using PowerBuilder would have created. Maybe in my spare time, I might read up on the origin of the GEDCOM file format.
 
The file format du jour is JSON.

Based my fast GEDCOM reading, apparently GEDCOM 5.5.5 is the de facto standard, so I guess you are stuck with that until GEDCOM 7 takes over.
 
the CSV library, are you talking about the beginning of the program with using statements?
If you installed a library using nuget package manager (typical) or added a reference to one(less typical these days) then yes, you'd using it to provide a shortcut instead of having to declare the full name of its classes
 
The repeating of those columns is on purpose. The marriage and divorce records happen in both the individual section and the family section. They could be totally different.
 
When I take the individual file that I created and marry it up to the family file I will use it to give desired results in a web page. I know that this has been done before but I want to show where individuals were born to where thay died.
 
What is the error associated with the red underline?

As a quick aside, never fully trust Intellisense (e.g. the red underlines). It's usually better to actually compile and see what the actual compiler error is. Intellisense was unreliable for Visual Studio 2012 and earlier when writing C/C++ code. For C#, it was kind of unreliable in VS2010 and earlier and then became pretty reliable except for exotic cases. Lately, with VS2022 17.4.2 and .3 I've been seeing Intellisense also being unreliable for C# again.
 
Back
Top Bottom