Code: Select all
BEGIN:VCARD
VERSION:3.0
FN:Person 1's Full name
N:Last Name;First Name;;;
TEL;TYPE=CELL:01234567890123
NOTE:friend
CATEGORIES:myContacts
END:VCARD
BEGIN:VCARD
VERSION:3.0
FN:Person 2's Full name
N:Last Name;First Name;;;
TEL;TYPE=CELL:98765432109876
TEL;TYPE=HOME:8765432109876
CATEGORIES:myContacts
END:VCARD
The idea is to use a Loop and a FileReadLine to check the form of each line. If it matches BEGIN:VCARD, then I know it has reached a new entry (so I can increment a count, for example); if it matches the regex ^FN:.+, then I'll know it's the person's full name; if it matches the regex ^TEL;TYPE=\w{4}:.+, I'll know it's the phone number.
So I thought about using Switch:
Code: Select all
contact_count := 0
Loop, {
FileReadLine, line, contacts.vcf, A_Index
Switch line
{
Case "BEGIN:VCARD":
MsgBox, New contact begins here
contact_count += 1
Default:
MsgBox, Didn't find anything fancy on this line.
}
[...]
Code: Select all
contact_count := 0
Loop, {
FileReadLine, line, contacts.vcf, A_Index
Switch line
{
Case "BEGIN:VCARD":
MsgBox, New contact begins here.
contact_count += 1
Case "RegexMatch(line, `"(?<=FN:)(.+)$`", out_var)":
MsgBox, This is the contact's name.
contact_count += 1
Default:
MsgBox, Didn't find anything fancy on this line.
}
[...]