Dim DetLocalIdentifier$(), TSNID$(), IdentifiedBy$(), DateIdentified$(), IdentificationRemarks$(), Family$(), Genus$(), SpecificEpithet$(), InfraspecificEpithet$(), TaxonRank$(), ScientificNameAuthorship$() Dim CurrentLicenseType, ValidClickEvent, NDeterminations Private Sub Form_Load() ' Turn on error handling to detect the "File not found" condition if this is a new 'implementation and the default file hasn't been set up On Error GoTo trap Open "guid-o-matic-defaults.txt" For Input As #1 ' Turn off error handling since this program isn't really bullet-proof On Error GoTo 0 Line Input #1, T$ txtDomainName.Text = T$ Line Input #1, T$ txtSpecimenInstitutionCode.Text = T$ Line Input #1, T$ txtSpecimenInstitutionURI.Text = T$ Line Input #1, T$ txtImageInstitutionCode.Text = T$ Line Input #1, T$ txtImageInstitutionURI.Text = T$ Line Input #1, CurrentLicenseType ' Preven a bogus click event ValidClickEvent = False optLicense(CurrentLicenseType).Value = True ValidClickEvent = True Line Input #1, T$ txtMetadataLanguage.Text = T$ Line Input #1, T$ txtLogoURL.Text = T$ Line Input #1, T$ txtAttributionURL.Text = T$ Line Input #1, T$ txtCopyright.Text = T$ Line Input #1, T$ txtImageCreditLine.Text = T$ Line Input #1, T$ txtRootDirectory.Text = T$ Close #1 Exit Sub 'This is an error trap whose sole purpose is to handle a "File not found" error if this 'is the first time the program is run and there are no default settings trap: ' Open up the file and save the default values from the screen Open "guid-o-matic-defaults.txt" For Output As #1 Print #1, txtDomainName.Text Print #1, txtSpecimenInstitutionCode.Text Print #1, txtSpecimenInstitutionURI.Text Print #1, txtImageInstitutionCode.Text Print #1, txtImageInstitutionURI.Text Print #1, 4 'License value for CC BY-NC-SA Print #1, txtMetadataLanguage.Text Print #1, txtLogoURL.Text Print #1, txtAttributionURL.Text Print #1, txtCopyright.Text Print #1, txtImageCreditLine.Text Print #1, txtRootDirectory.Text Close #1 ' return to the input routine and input these values that were just written Resume End Sub Private Sub cmdSaveSettings_Click() Open "guid-o-matic-defaults.txt" For Output As #1 Print #1, txtDomainName.Text Print #1, txtSpecimenInstitutionCode.Text Print #1, txtSpecimenInstitutionURI.Text Print #1, txtImageInstitutionCode.Text Print #1, txtImageInstitutionURI.Text Print #1, CurrentLicenseType Print #1, txtMetadataLanguage.Text Print #1, txtLogoURL.Text Print #1, txtAttributionURL.Text Print #1, txtCopyright.Text Print #1, txtImageCreditLine.Text Print #1, txtRootDirectory.Text Close #1 End Sub Private Sub cmdCreateGuids_Click() Quote$ = Chr$(34) Open "c:/guid-o-matic-determinations.csv" For Input As #1 Input #1, NDeterminations Line Input #1, T$ 'Read in the rest of the header line and do nothing with it ReDim DetLocalIdentifier$(NDeterminations), TSNID$(NDeterminations), IdentifiedBy$(NDeterminations), DateIdentified$(NDeterminations), IdentificationRemarks$(NDeterminations), Family$(NDeterminations), Genus$(NDeterminations), SpecificEpithet$(NDeterminations), InfraspecificEpithet$(NDeterminations), TaxonRank$(NDeterminations), ScientificNameAuthorship$(NDeterminations) For Determination = 1 To NDeterminations Input #1, T1$, T2$, TSNID$(Determination), IdentifiedBy$(Determination), DateIdentified$(Determination), IdentificationRemarks$(Determination), Family$(Determination), Genus$(Determination), SpecificEpithet$(Determination), InfraspecificEpithet$(Determination), TaxonRank$(Determination), ScientificNameAuthorship$(Determination) DetLocalIdentifier$(Determination) = T1$ + "/" + T2$ Next Determination Close #1 Open "c:/guid-o-matic-specimens.csv " For Input As #1 Input #1, NSpecimens Line Input #1, T$ 'Read in the rest of the first line (headers) and do nothing with them For specimen = 1 To NSpecimens ' Read in the elements that vary among specimens Input #1, NameSpace$, Identifier$, CatalogNumber$, EstablishmentMeans$, DocumentsDistribution$, OccurrenceRemarks$, RecordedBy$, RecordNumber$, EventDate$, DecimalLatitude$, DecimalLongitude$, GeodeticDatum$, CoordinateUncertaintyInMeters$, GeoreferenceRemarks$, Continent$, CountryCode$, StateProvince$, County$, Locality$, created$, BQAccessURL$, BQImageWidth$, BQImageHeight$, BQXSamplingFrequency$, GQAccessURL$, GQImageWidth$, GQImageHeight$, LQAccessURL$, LQImageWidth$, LQImageHeight$, TNAccessURL$, TNImageWidth$, TNImageHeight$ BaseGUID$ = "http://" + txtDomainName.Text + "/" + NameSpace$ + "/" + Identifier$ LocalIdentifier$ = NameSpace$ + "/" + Identifier$ ' Open the RDF file Open txtRootDirectory.Text + NameSpace$ + "\" + Identifier$ + ".rdf" For Output As #2 Print #2, "" Print #2, "" ' Information about the organizational structure of the RDF and how it was created Print #2, "" ' RDF container opening tag. The namespace definitions include every possible one that might be used in the RDF Print #2, "" 'Individual container element Print #2, "" Print #2, " " + txtMetadataLanguage.Text + "" Print #2, " " LatestDet = 0 Test$ = "0000" For Determination = 1 To NDeterminations If DetLocalIdentifier$(Determination) = LocalIdentifier$ Then If DateIdentified$(Determination) > Test$ Then LatestDet = Determination End If Next Determination Print #2, " Field individual of "; Genus$(LatestDet); " "; SpecificEpithet$(LatestDet); Select Case TaxonRank$(LatestDet) Case "varietas" Print #2, " var. "; InfraspecificEpithet$(LatestDet); Case "subspecies" Print #2, " ssp. "; InfraspecificEpithet$(LatestDet); End Select Print #2, " with GUID: "; BaseGUID$; "#ind" Print #2, " " Print #2, " " Print #2, " " Print #2, " "; EstablishmentMeans$; "" If IndividualRemarks$ <> "" Then Print #2, " "; IndividualRemarks$; "" End If Print #2, "" Print #2, " " Print #2, " " Print #2, " " Print #2, " " Print #2, "" Print #2, " " For Determination = 1 To NDeterminations If DetLocalIdentifier$(Determination) = LocalIdentifier$ Then Print #2, " " End If Next Determination ' closing tag for the individual Print #2, "" Print #2, "" ' now create the rdf for each determination For Determination = 1 To NDeterminations If DetLocalIdentifier$(Determination) = LocalIdentifier$ Then ' identification property elements Print #2, "" Print #2, " " Print #2, " Determination of "; Genus$(Determination); " "; SpecificEpithet$(Determination); Select Case TaxonRank$(Determination) Case "varietas" Print #2, " var. "; InfraspecificEpithet$(Determination); Case "subspecies" Print #2, " ssp. "; InfraspecificEpithet$(Determination); End Select Print #2, " for the individual "; BaseGUID$ + "#" + TSNID$(Determination); "" Print #2, " " Print #2, " "; IdentifiedBy$(Determination); "" Print #2, " "; DateIdentified$(Determination); "" If IdentificationRemarks$(Determination) <> "" Then Print #2, " "; IdentificationRemarks$(Determination); "" End If Print #2, "" Print #2, " " Print #2, " " Print #2, " " Print #2, "" Print #2, " " Print #2, " "; Family$(Determination); "" Print #2, " "; Genus$(Determination); "" Print #2, " "; SpecificEpithet$(Determination); "" If InfraspecificEpithet$(Determination) <> "" Then Print #2, " "; InfraspecificEpithet$(Determination); "" Print #2, " "; TaxonRank$(Determination); "" Print #2, " "; ScientificNameAuthorship$(Determination); "" ' determination container closing tag Print #2, "" End If Next Determination Print #2, "" 'Specimen container element Print #2, "" Print #2, " " + txtMetadataLanguage.Text + "" Print #2, " " Print #2, " Preserved specimen of "; Genus$(LatestDet); " "; SpecificEpithet$(LatestDet); Select Case TaxonRank$(LatestDet) Case "varietas" Print #2, " var. "; InfraspecificEpithet$(LatestDet); Case "subspecies" Print #2, " ssp. "; InfraspecificEpithet$(LatestDet); End Select Print #2, "" Print #2, " " Print #2, " " Print #2, " "; txtSpecimenInstitutionCode.Text; "" Print #2, " " Print #2, " " Print #2, " "; EventDate$; "" Print #2, " " Print #2, " " Print #2, " " Print #2, " " Print #2, " "; EstablishmentMeans$; "" ' Note: This assumes that all specimens that are the subject of this program document distribution Print #2, " true" If OccurrenceRemarks$ <> "" Then Print #2, " " + OccurrenceRemarks$ + "" End If Print #2, " "; RecordedBy$; "" Print #2, " "; RecordNumber$; "" Print #2, " " + EventDate$ + "" Print #2, " " + txtSpecimenInstitutionCode.Text + "" Print #2, " " Print #2, " " Print #2, " "; Family$(LatestDet); "" Print #2, " "; Genus$(LatestDet); "" Print #2, " "; SpecificEpithet$(LatestDet); "" If InfraspecificEpithet$(LatestDet) <> "" Then Print #2, " "; InfraspecificEpithet$(LatestDet); "" Print #2, " "; TaxonRank$(LatestDet); "" Print #2, " "; ScientificNameAuthorship$(LatestDet); "" Print #2, " " Print #2, " " Print #2, " " Print #2, " " For Determination = 1 To NDeterminations If DetLocalIdentifier$(Determination) = LocalIdentifier$ Then Print #2, " " End If Next Determination Print #2, " " ' Don't create image links if there isn't at least a hires image If BQAccessURL$ <> "" Then Print #2, " " Print #2, " " Print #2, " " End If For Determination = 1 To NDeterminations If DetLocalIdentifier$(Determination) = LocalIdentifier$ Then Print #2, " " End If Next Determination Print #2, " " ' Leave out the georeference terms if there isn't a decimal latitude If DecimalLatitude$ <> "" Then Print #2, " " + DecimalLatitude$ + "" Print #2, " " + DecimalLongitude$ + "" Print #2, " " + GeodeticDatum$ + "" Print #2, " " + CoordinateUncertaintyInMeters$ + "" Print #2, " " + GeoreferenceRemarks$ + "" End If Print #2, " " + Continent$ + "" Print #2, " " + CountryCode$ + "" Print #2, " " + StateProvince$ + "" Print #2, " " + County$ + "" Print #2, " " + Locality$ + "" Print #2, "" Print #2, "" ' Skip the image metadata section if there isn't at least a hires image If BQAccessURL$ <> "" Then Print #2, "" Print #2, " " + txtMetadataLanguage.Text + "" Print #2, " " Print #2, " " Print #2, " " Print #2, " "; txtSpecimenInstitutionCode.Text; "" Print #2, " " Print #2, " " Print #2, " "; created$; "" Print #2, " " Print #2, " " Print #2, " " Print #2, " DigitalStillImage" ' Note: Specimens images don't document distribution Print #2, " false" Print #2, " " + txtSpecimenInstitutionCode.Text + "" Print #2, " " Print #2, " " Print #2, " "; ' if in public domain, over-ride existing value and make this "public domain" If CurrentLicenseType = 0 Then Print #2, "Image in the public domain"; Else Print #2, txtCopyright.Text; End If Print #2, "" Print #2, " " Print #2, " " Print #2, " "; txtSpecimenInstitutionCode.Text; "" Print #2, " " Print #2, " " Print #2, " "; txtImageCreditLine.Text; "" Print #2, " 77407" 'This is the view for herbarium specimens Print #2, " " Print #2, " Preserved specimen of "; Genus$(LatestDet); " "; SpecificEpithet$(LatestDet); Select Case TaxonRank$(LatestDet) Case "varietas" Print #2, " var. "; InfraspecificEpithet$(LatestDet); Case "subspecies" Print #2, " ssp. "; InfraspecificEpithet$(LatestDet); End Select Print #2, "" Select Case CurrentLicenseType Case 0 ut$ = "License not required (in the public domain)" ws$ = "http://creativecommons.org/licenses/publicdomain/" Case 1 ut$ = "Available under Creative Commons Attribution 3.0 license" ws$ = "http://creativecommons.org/licenses/by/3.0/us/" Case 2 ut$ = "Available under Creative Commons Attribution-Share Alike 3.0 license" ws$ = "http://creativecommons.org/licenses/by-sa/3.0/us/" Case 3 ut$ = "Available under Creative Commons Attribution-Noncommercial 3.0 license" ws$ = "http://creativecommons.org/licenses/by-nc/3.0/us/" Case 4 ut$ = "Available under Creative Commons Attribution-Noncommercial-Share Alike 3.0 license" ws$ = "http://creativecommons.org/licenses/by-nc-sa/3.0/us/" End Select Print #2, " "; ut$; "" Print #2, " "; ws$; "" Print #2, " Image of a "; Genus$(LatestDet); " "; SpecificEpithet$(LatestDet); Select Case TaxonRank$(LatestDet) Case "varietas" Print #2, " var. "; InfraspecificEpithet$(LatestDet); Case "subspecies" Print #2, " ssp. "; InfraspecificEpithet$(LatestDet); End Select Print #2, " specimen" Print #2, " "; txtAttributionURL.Text; "" Print #2, " "; txtLogoURL.Text; "" Print #2, " 0" Print #2, " 5" Print #2, "" Print #2, " " Print #2, " " Print #2, " " Print #2, " " For sap = 1 To 4 Print #2, " " Next sap ' image container closing tag/end of line Print #2, "" Print #2, "" End If Print #2, "" 'Service Access Points for the image ' I'm supporting four sizes of image: bestQuality (original),thumbnail,lowerQuality, and goodQuality For sap = 1 To 4 ' Test whether there is a SAP for a particular variant type Select Case sap Case 1 URL$ = BQAccessURL$ Case 2 URL$ = TNAccessURL$ Case 3 URL$ = LQAccessURL$ Case 4 URL$ = GQAccessURL$ End Select If URL$ <> "" Then ' Service Access Point property elements ' Service Access Point container opening tag Select Case sap Case 1 T$ = "bq" Case 2 T$ = "tn" Case 3 T$ = "lq" Case 4 T$ = "gq" End Select Print #2, "" Select Case sap Case 1 T$ = "Best Quality" Case 2 T$ = "Thumbnail" Case 3 T$ = "Lower Quality" Case 4 T$ = "Good Quality" End Select Print #2, " "; T$; "" Print #2, " "; URL$; "" Select Case Right$(LCase$(URL$), 3) Case "jpg", "jpe" T1$ = "image/jpeg" Case "gif" T1$ = "image/gif" Case "bmp" T1$ = "image/bmp" Case "tif" T1$ = "image/tiff" Case Else T1$ = "unknown" End Select Print #2, " "; T1$; "" Select Case sap Case 1 'full size T$ = BQImageWidth$ Case 2 'thumbnail T$ = TNImageWidth$ Case 3 'low quality T$ = LQImageWidth$ Case 4 'good quality T$ = GQImageWidth$ End Select Print #2, " "; T$; "" Select Case sap Case 1 'full size T$ = BQImageHeight$ Case 2 'thumbnail T$ = TNImageHeight$ Case 3 'low quality T$ = LQImageHeight$ Case 4 'good quality T$ = GQImageHeight$ End Select Print #2, " "; T$; "" ' Note: it is assumed that the X and Y pixels have the same size If BQXSamplingFrequency$ <> "" Then Select Case sap Case 1 'full size T$ = BQXSamplingFrequency$ Case 2 'thumbnail T$ = LTrim$(Str$(Int(Val(BQImageHeight$) / Val(TNImageHeight$) * Val(BQXSamplingFrequency$) + 0.5))) Case 3 'low quality T$ = LTrim$(Str$(Int(Val(BQImageHeight$) / Val(LQImageHeight$) * Val(BQXSamplingFrequency$) + 0.5))) Case 4 'good quality T$ = LTrim$(Str$(Int(Val(BQImageHeight$) / Val(GQImageHeight$) * Val(BQXSamplingFrequency$) + 0.5))) End Select Print #2, " "; T$; "" Print #2, " "; T$; "" Print #2, " cm" End If ' service access point container closing tag/end of row Print #2, "" End If Next sap Print #2, "" '--------------------------------- ' metadata about the rdf file itself Print #2, "" Print #2, "" Print #2, " RDF formatted description of the preserved specimen "; BaseGUID$; "" Print #2, " " Print #2, " " Print #2, " "; txtImageInstitutionCode.Text; "" Print #2, " " Print #2, " " Print #2, " en" T$ = Format(Date, "yyyy-mm-dd") + "T" + Format(Time, "hh:mm:ss") Print #2, " "; T$; "" Print #2, " "; T$; "" Print #2, " " Print #2, " " Print #2, " " Print #2, " " Print #2, "" Print #2, "" Close #2 Next specimen Close #1 End Sub Private Sub optLicense_Click(Index As Integer) T$ = "" If ValidClickEvent = True Then 'this prevents bogus click events generated by setting option button 'values from having unintended consequences CurrentLicenseType = Index End If End Sub Private Sub cmdQuit_Click() cmdSaveSettings_Click End End Sub