' MakeVcf - Author: The Holistic Searcher - 6th of June 2019 ' ' Dato un file di input sequenziale Numeri.txt, di associazione nome e numeri di telefono, del seguente formato: ' Mario Rossi 3333333333 ' Antonio Bianchi 444444444 555555555 ' produce un file di output Numeri.vcf del seguente fomato: ' BEGIN:VCARD ' N:Mario Rossi ' TEL:3333333333 ' END:VCARD ' BEGIN:VCARD ' N:Antonio Bianchi ' TEL:444444444 ' TEL:555555555 ' END:VCARD ' '''''''''' ' MAIN '''''''''' ' Public objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") APPL="Slash-Return" Const ForWriting = 2 InputFile="C:Numeri.txt" OutputFile="C:Numeri.vcf" Const TelMax = 10 Dim TELEFONO() ReDim TELEFONO(TelMax) NumRec=0 ' Inizializzazione ' If objFso.FileExists (InputFile) Then ' InputExists=True MsgBox "Elaborazione in corso: ESISTE il file di input "&InputFile,,Appl NumRec=0 Set objFileInp = objFSO.OpenTextFile(InputFile) Set objFileOut = objFso.OpenTextFile(OutputFile,ForWriting,True) Do While objFileInp.AtEndOfStream <> True NumRec=NumRec+1 ' ' Inizio gestione dei dati nel record NumRec record = objFileInp.ReadLine LunRec=len(record) If LunRec > 0 Then NumChar=0 TelNum=0 NOME="" ' ' Inizio parsing del record Do While NumChar < LunRec NumChar=NumChar+1 Char=Mid(record,NumChar,1) If Char=Chr(9) Or Char=Chr(32) Then 'MsgBox"Trovato carattere di separazione",,APPL CharDopo=Mid(record,NumChar+1,1) If CharDopo="0" _ Or CharDopo="1" Or _ CharDopo="2" Or _ CharDopo="3" Or _ CharDopo="4" Or _ CharDopo="5" Or _ CharDopo="6" Or _ CharDopo="7" Or _ CharDopo="8" Or _ CharDopo="9" _ Then If TelNum=0 Then NOME=Stringa 'MsgBox"Elaborato nome " & NOME & " TelNum " & TelNum,,APPL Stringa="" Else TELEFONO(TelNum)=Stringa 'MsgBox"Elaborato telefono " & TELEFONO(TelNum) & " TelNum " & TelNum & " (NOME " & NOME & ")",,APPL Stringa="" End If TelNum=TelNum+1 Else Stringa=Stringa & Char End If Else Stringa=Stringa & Char End If Loop TELEFONO(TelNum)=Stringa Stringa="" ' Fine parsing del record ' ' Collezionati il NOME e i TelNum numeri di telefono, li scrive come VCARD nel file di output 'MsgBox"Record numero "&NumRec,,APPL 'MsgBox"Record = "&record,,APPL objFileOut.Write("BEGIN:VCARD"+chr(13)+chr(10)) objFileOut.Write("N:"+NOME+chr(13)+chr(10)) ContaTel=0 Do While ContaTel < TelNum ContaTel=ContaTel+1 objFileOut.Write("TEL:"+TELEFONO(ContaTel)+chr(13)+chr(10)) 'objFileOut.Write("TEL:"+TELEFONO+chr(13)+chr(10)) Loop objFileOut.Write("END:VCARD"+chr(13)+chr(10)) ' Fine della scrittura dei dati del record NumRec come VCARD nel file di output End If ' Fine gestione dei dati del record NumRec ' NOME="" ' Reset TelNum=0 ' Reset Loop objFileInp.Close objFileOut.Close Else MsgBox "NON ESISTE il necessario file di input "&InputFile,,Appl End If MsgBox "Programma terminato dopo aver elaborato record: "&NumRec,,APPL ''''''''''''' ' FINE MAIN ''''''''''''