How do I set up a VB script for a single line with four optional phone numbers and a pipe symbol between each phone number?

EDOCBUILDER > eDocBuilder FAQs
Scenario:
I have a business card that has four optional phone numbers - phone, cell, toll free and fax.  If all fields are present it looks like this:

p 555.555.1111 | c 555.555.2222 | tf 555.555.3333 | f 555.555.4444
 
I need each field to have a phone type label.  I also need a pipe symbol between each phone number.  How do I write a vb script to accommodate each possible combination of phone numbers so that the pipe symbol correctly appears?
 
Solution:
You would start by setting up a chart that accounts for each possible combination of phone numbers.  Here is our chart.  If there is an "x" in a column it means that that field is present/filled in by the user.  

 
Pipe 1
Using this chart, you will see that the first pipe is missing every time that phPhone is blank except when phPhone is filled in and all three of the other fields are blank.  Therefore, our script for the first pipe is:
 ifs(phPhone="" or (phCell="" and phFax=""and phTollFree="")), "", "| ")
 
Pipe 2
You will see that the second pipe is missing every time phCell is blank except when phCell is filled in but the three other fields are blank and when only the phPhone and phCell fields are filled in.  Therefore, our script for the second pipe is:
ifs(phCell="" or (phPhone="" and phFax="" and phTollFree="") or (phTollFree="" and phCell=""), "", "| ")
 
Pipe 3
You will see that the third pipe is missing any time that phFax or phTollFree fields are blank.  Therefore, our script for the third pipe is:
ifs(phFax="" or phTollFree="", "", "| ")
 
The three scripts for the pipes were combined with the ifs statements removing the phone label for each optional phone field.  The complete script for the entire field is:
ifs(phPhone<>"", "p " & phPhone,"") & ifs(phPhone="" or (phCell="" and phFax=""and phTollFree=""), "", "| ") & ifs(phCell<>"", "c " & phCell,"") & ifs(phCell="" or (phPhone="" and phFax="" and phTollFree="") or (phTollFree="" and phCell=""), "", "| ") & ifs(phTollFree<>"", "tf " & phTollFree,"") & ifs(phFax="" or phTollFree="", "", "| ") & ifs(phFax<>"", "f " & phFax,"")