Steven Wells
asked on
Replace tag list with words
Hi,
I am working on some vbscript where I want to have a set list of tags that people can use to customise an automated email. So far I have about 5 tags that are in the format of %username%, %TicketNo% etc. These are then substitued for the real values.
I am trying to come up with a nice way of replacing the %tagname% with the value from the database. Currently I am using the vb replace, but with 5 tags that is ok, but I want to use about 15-20. I was thinking there must be a better way of loading the tag list into some function and use that.
The script is vbs, however happy to rewrite if VB.net has a better solution (on my list of things to do)
Any ideas on a better way to achive this?
Steve
I am working on some vbscript where I want to have a set list of tags that people can use to customise an automated email. So far I have about 5 tags that are in the format of %username%, %TicketNo% etc. These are then substitued for the real values.
I am trying to come up with a nice way of replacing the %tagname% with the value from the database. Currently I am using the vb replace, but with 5 tags that is ok, but I want to use about 15-20. I was thinking there must be a better way of loading the tag list into some function and use that.
The script is vbs, however happy to rewrite if VB.net has a better solution (on my list of things to do)
Any ideas on a better way to achive this?
Steve
You can create an array of tags and then using loop you can find and replace the content which you got from database.
ASKER
Sounds like a good start, are you able to give quick example?
Post the working code you have so far, and it should be pretty easy to incorporate an array with loop.
ASKER
Ok,
So currently I have a string that has all the tags inside
supdattext = GetEmailText(1)
supdattext = (Replace(supdattext,"%disp layName%", SDisplayNa me))
supdattext = (Replace(supdattext,"%FltN o%",sFltno ))
supdattext = (Replace(supdattext,"%PriD esc%",sPri Desc))
supdattext = (Replace(supdattext,"%FlTD esc%",SFlT Desc))
supdattext = (Replace(supdattext,"%FltO pen%",sFlt Open))
supdattext = (Replace(supdattext,"%Upda teLink%",U pdatelink) )
WScript.Echo supdattext
I think I need to load all %words% into an array and then subsitute with it's correct value.
Any ideas?
So currently I have a string that has all the tags inside
supdattext = GetEmailText(1)
supdattext = (Replace(supdattext,"%disp
supdattext = (Replace(supdattext,"%FltN
supdattext = (Replace(supdattext,"%PriD
supdattext = (Replace(supdattext,"%FlTD
supdattext = (Replace(supdattext,"%FltO
supdattext = (Replace(supdattext,"%Upda
WScript.Echo supdattext
I think I need to load all %words% into an array and then subsitute with it's correct value.
Any ideas?
May be you can write a function which accepts the parameter and returns the actual string
So replace %username% with %GetValue("username")%
Private Function GetValue(input as String) As String
If input = "username" Then
Return ...
ElseIf input = "ticketno" Then
Return ...
...
End If
End Function
So replace %username% with %GetValue("username")%
Private Function GetValue(input as String) As String
If input = "username" Then
Return ...
ElseIf input = "ticketno" Then
Return ...
...
End If
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I will incorporate this. It makes it easy to add lots more tags too.