Is there a component to Read in/ write out a VCard file lazarus / 31-LCL ---------------------------------------------------------------------- WTDdallas · 2016-05-29 02:39 Is there a component to Read in/ write out a VCard file(.vcf)?? ---------------------------------------------------------------------- Thaddy · 2016-05-29 07:08 Quote from: WTDdallas on May 29, 2016, 04:39:46 amIs there a component to Read in/ write out a VCard file(.vcf)?? Not that I know, but there is this one for Delphi: http://torry.net/quicksearchd.php?String=ACEVCard&Title=Yes ---------------------------------------------------------------------- WTDdallas · 2016-05-29 13:19 Quote from: Thaddy on May 29, 2016, 09:08:56 amQuote from: WTDdallas on May 29, 2016, 04:39:46 amIs there a component to Read in/ write out a VCard file(.vcf)?? Not that I know, but there is this one for Delphi: http://torry.net/quicksearchd.php?String=ACEVCard&Title=Yes Thanks downloaded it , No Examples  It seems to be written for Delphi.  Is there one written for Lazarus? Seems most of the Products for sale on that site, their websites are not longer around. ---------------------------------------------------------------------- balazsszekely · 2016-05-29 13:26 Quote@WTDallas Is there one written for Lazarus?Did you try to convert it? It shouldn't be to difficult. ---------------------------------------------------------------------- zeljko · 2016-05-29 14:45 Just visually inspected that source and IMO, that should work out of the box on lazarus. There's nothing platform specific inside ... just remove Windows and Messages unit and that's it. ---------------------------------------------------------------------- WTDdallas · 2016-05-29 16:52 Quote from: GetMem on May 29, 2016, 03:26:56 pmQuote@WTDallas Is there one written for Lazarus?Did you try to convert it? It shouldn't be to difficult. Not yet, but I will, I just saw the .dcu files. Will have to figure out how to use it, no examples included. ---------------------------------------------------------------------- Leledumbo · 2016-05-29 18:30 ACEVCCls.pas -> compiles straight ACEVCard.pas -> remove Windows and Messages, replace GetLastError with GetLastOSError Use mode delphi when compiling of course ---------------------------------------------------------------------- molly · 2016-05-29 21:14 In addition to what Leledumbo wrote: - Mode OBJFPC also works - With respect to original author: The code is buggy and contains logical errors. So either you need to correct the mistakes or try create your own (i was unable to locate another vcard implementation in pascal) Some issues: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {Explode any string to a TStringSet, using Delim as a splitter,  unless the Delim Character is escaped}Function Explode(Input: String; Delim: Char): TStrings;var  P: Integer;  UnEsc: String;  Sub: String;begin  Result := nil;  if Delim = '%' then Sub := '$ESCAPEDCHAR$' else Sub := '%ESCAPEDCHAR%';  Result.Clear;  UnEsc := AnsiReplaceText(Input, '\' + Delim, Sub);  while Pos(Delim, UnEsc) > 0 do  begin    P := Pos(Delim, UnEsc);    Result.Add(Copy(UnEsc, 1, P-1));    Delete(UnEsc, 1, P);  end;  if UnEsc <> '' then Result.Add(UnEsc);  for P := 0 to Result.Count - 1 do    Result.Strings[P] := AnsiReplaceText(Result.Strings[P], Sub, '\' + Delim);end;  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TACEVCard.LoadFromFile(Filename: string);var  I, V: TStrings;  FV, FFN, FN: Boolean;  A: Integer;  S, D1, D2: String;begin  I := TStringList.Create;  V := TStringList.Create;  try    I.LoadFromFile(FileName);    I.Text := AnsiReplaceStr(I.Text, #13#10#32, '');    I.Text := AnsiReplaceStr(I.Text, #13#10#9, '');    A := I.Count;        if (I[1] <> 'BEGIN:VCARD') OR (I[A-1] <> 'END:VCARD') then    Raise EVCardLoadError.CreateFmt('%s is not a valid VCard File', [FileName]);        FV := False;    FFN := False;  FN := False;    for A := 0 to I.Count - 1 do    begin      if AnsiLeftStr(I[A], 8) = 'VERSION:' then FV := True;      if AnsiLeftStr(I[A], 3) = 'FN:' then FFN := True;      if AnsiLeftStr(I[A], 2) = 'N:' then FN := True;    end;    if NOT FV then      Raise EVCardLoadError.CreateFmt('%s does not contain a valid Version Identifier', [FileName]);    if NOT FFN then      Raise EVCardLoadError.CreateFmt('%s does not contain a valid Formatted Name Identifier', [FileName]);    if NOT FN then      Raise EVCardLoadError.CreateFmt('%s does not contain a valid Name Identifier', [FileName]);    FIdentInfo.LoadFromStringList(I);    FAddressInfo.LoadFromStringList(I);    FPhoneNumbers.LoadFromStringList(I);    FEmails.LoadFromStringList(I);    FAdditional.LoadFromStringList(I);  for A := 0 to I.Count - 1 do    begin      S := I[A];      if AnsiLeftStr(S, 8) = 'VERSION:' then        FVersion := Copy(S, 9, Length(S));      if AnsiLeftStr(S, 4) = 'REV:' then      begin        S := Copy(S, 5, Length(S));        if Pos('T', S) = 0 then        begin          D2 := '00:00:00';          V := Explode(S, '-');        D1 := V[2] + '-' + V[1] + '-' + V[0];        end        else        begin          V := Explode(Copy(S, 1, Pos('T', S) - 1), '-');        D1 := V[2] + '-' + V[1] + '-' + V[0];          D2 := Copy(S, Pos('T', S) + 1, Pos('Z', S) - 1);        end;        FRevision := StrToDateTime(D1 + ' ' + D2);      end;    end;  finally    I.Free;  V.Free;  end;end;  As for an example (FPC commandline): Code: [Select]program testvcard; {$MODE OBJFPC}{$H+} Uses   AceVCard; Procedure Test(FileName: string); Var   VCard: TAceVCard; begin   WriteLn;   WriteLn('###### ', FileName, ' #####');   WriteLn;   VCard := TAceVCard.Create(nil);   VCard.LoadFromFile(Filename);   with VCard.Personal do   begin     with Name do     begin       WriteLn('VCard.Personal.Name.FamilyName               = ', FamilyName);       WriteLn('VCard.Personal.Name.GivenName                = ', GivenName);       WriteLn('VCard.Personal.Name.AdditionalNames          = ', AdditionalNames);       WriteLn('VCard.Personal.Name.Prefix                   = ', Prefix);       WriteLn('VCard.Personal.Name.Suffix                   = ', Suffix);     end;     WriteLn('VCard.Personal.FormattedName                 = ', FormattedName);     WriteLn('VCard.Personal.SortString                    = ', SortString);     with Company do     begin       WriteLn('VCard.Personal.Company.CompanyName           = ', CompanyName);       WriteLn('VCard.Personal.Company.CompanyUnit           = ', CompanyUnit);       WriteLn('VCard.Personal.Company.SubUnit1              = ', SubUnit1);       WriteLn('VCard.Personal.Company.SubUnit2              = ', SubUnit2);       WriteLn('VCard.Personal.Company.SubUnit3              = ', SubUnit3);       WriteLn('VCard.Personal.Company.SubUnit4              = ', SubUnit4);       WriteLn('VCard.Personal.Company.Title                 = ', Title);       WriteLn('VCard.Personal.Company.Role                  = ', Role);     end;   end;   with VCard.Addresses do   begin     With Address1 do     begin       WriteLn('VCard.Addresses.Address1.Attributes          = ', Integer(Attributes));       WriteLn('VCard.Addresses.Address1.Postbox             = ', PostBox);       WriteLn('VCard.Addresses.Address1.ExtendedAddress     = ', ExtendedAddress);       WriteLn('VCard.Addresses.Address1.Street              = ', Street);       WriteLn('VCard.Addresses.Address1.Localeity           = ', Locality);       WriteLn('VCard.Addresses.Address1.Region              = ', Region);       WriteLn('VCard.Addresses.Address1.PostalCode          = ', PostalCode);       WriteLn('VCard.Addresses.Address1.Country             = ', Country);     end;        // there are 3 additional addresess   end;   with VCard.PhoneNumbers do   begin     with Phone1 do     begin       WriteLn('VCard.PhoneNumbers.Phone1.Attributes         = ', Integer(Attributes));       WriteLn('VCard.PhoneNumbers.Phone1.Number             = ', Number);     end;     // there are 7 additional numbers.   end;   with VCard.EMailAddresses do   begin     with EmailAddress1 do     begin       WriteLn('VCard.EMailAddresses.EmailAddress1.EmailType = ', Ord(EmailType));       WriteLn('VCard.EMailAddresses.EmailAddress1.Address   = ', Address);     end;     // there are 7 additional email addresses   end;   with VCard.Additional do   begin     WriteLn('VCard.Additional.Comment                     = ', Comment.Text);     WriteLn('VCard.Additional.URL1                        = ', URL1);     WriteLn('VCard.Additional.URL2                        = ', URL2);   end;   Writeln('VCard.Version                                = ', VCard.Version);   Writeln('VCard.Revision                               = ', VCard.Revision);   VCard.Free; end; begin   Test('examples1/john-doe.vcf'); end. ---------------------------------------------------------------------- CM630 · 2023-02-18 16:51 Maybe there is something new in the recent years? ---------------------------------------------------------------------- jamie · 2023-02-18 17:12 Looks like a spam generator! ---------------------------------------------------------------------- wp · 2023-02-18 17:16 VCard files are supported by TvPlanIt, units VpBaseDataFiles and VpVCard (there is some dependence on other TvPlanIt units, but i think this can be circumvented easily). ---------------------------------------------------------------------- jamie · 2023-02-18 17:19 whats the big deal here? https://en.wikipedia.org/wiki/VCard