I'm trying to create a little tool to help make .csv files based on user input.
I have ~40 edit controls, where the user inputs ID numbers for staff. These write to variables %Id1%, %Id2%, %Id3% . . . %Id38%, %Id39%, %Id40%.
Then I have a section of the script which creates a .csv file like this:
Code: Select all
FileAppend,
(
%FirstName1%,%LastName1%,%Id1%
%FirstName2%,%LastName2%,%Id2%
%FirstName3%,%LastName3%,%Id3%
. . .
%FirstName38%,%LastName38%,%Id38%
%FirstName39%,%LastName39%,%Id39%
%FirstName40%,%LastName40%,%Id40%
), %Filename%.csv
What I'm now trying to do is add a third variable using the ID numbers, to create email addresses. This will be a case of adding @emailaddress.com to the end of each ID variable, however I've encountered two issues with this.
First of all, from what I can tell, I would have to process each ID variable separately with something like this:
Code: Select all
Email1 := Id1 "@emailaddress.com"
Email2 := Id2 "@emailaddress.com"
Email3 := Id3 "@emailaddress.com"
. . .
Email38 := Id38 "@emailaddress.com"
Email39 := Id39 "@emailaddress.com"
Email40 := Id40 "@emailaddress.com"
I'm aware that I can fix this by doing something like
Code: Select all
if (Id1 != "")
Email1 := Id1 "@emailaddress.com"
if (Id2 != "")
Email2 := Id2 "@emailaddress.com"
if (Id3 != "")
Email3 := Id3 "@emailaddress.com"
. . .
if (Id38 != "")
Email38 := Id38 "@emailaddress.com"
if (Id39 != "")
Email39 := Id39 "@emailaddress.com"
if (Id40 != "")
Email40 := Id40 "@emailaddress.com"
Is there a way to write the script more simply so that every Id# variable gets appended with the email address if its not empty? I feel like there should be a way to do this with a loop? But unfortunately I don't know enough about what I'm doing to know where to really start.
Please let me know if I haven't explained anything properly!
Thanks in advance