ASP Concatenate string

B

Bob Barrows [MVP]

Raju said:
String a=Test
String [email protected]

How cn I concatenate this to get

String c ="""Test"" <[email protected]>"

Since you did not use quotes when defining a and b, I am going to assume you
want c to contain a string whose first 3 characters are quotes, followed by
Test, followed by two quotes, followed by b contained in angle brackets,
followed by a single quote.

Using vbscript you would do this:

dim a,b,c
const quote=""""
a="Test"
b= "(e-mail address removed)"
c=quote & quote & quote & a & quote & quote & "<" & _
b & ">" & quote
 
E

Evertjan.

Raju wrote on 06 jul 2007 in microsoft.public.inetserver.asp.general:
String a=Test
String [email protected]

How cn I concatenate this to get

String c ="""Test"" <[email protected]>"

This is one of those instances where,
even while using asp-vbscript in the main code,
I would use a piece of asp-jscript:

<% ' vbscript default
r = concatEmail("Test","(e-mail address removed)")
responce.write r
%>

<script language='Jscript' runat='Server'>
function concatEmail(x,y) {
return '"' + a + '" <' + b +'>';
};
</script>
 
A

Anthony Jones

Evertjan. said:
Raju wrote on 06 jul 2007 in microsoft.public.inetserver.asp.general:


This is one of those instances where,
even while using asp-vbscript in the main code,
I would use a piece of asp-jscript:

<% ' vbscript default
r = concatEmail("Test","(e-mail address removed)")
responce.write r
%>

<script language='Jscript' runat='Server'>
function concatEmail(x,y) {
return '"' + a + '" <' + b +'>';
};
</script>

Do you really think launching a different script engine is justifiable in
order to avoid the string """" ?
 
E

Evertjan.

Anthony Jones wrote on 06 jul 2007 in
microsoft.public.inetserver.asp.general:
Do you really think launching a different script engine is justifiable
in order to avoid the string """" ?

I doubt if it is a "different one", believing it is one and the same,
but in the context of SMTP sending of an email with CDO, JMail, etc,
the possible timing and processor load impact seems unimportant.

Other Jscript functions could be added too.

Using Jscript for quoting [like above] [and things like regex, btw] makes
coding mistakss fare less likely, and comparing that to processing impact
is a personal choice.

For working with serverside UTC, Jscript can even do what VBscript
cannot, like using .getTimezoneOffset()
 
A

Anthony Jones

Evertjan. said:
Anthony Jones wrote on 06 jul 2007 in
microsoft.public.inetserver.asp.general:


I doubt if it is a "different one", believing it is one and the same,
but in the context of SMTP sending of an email with CDO, JMail, etc,
the possible timing and processor load impact seems unimportant.

I wouldn't bet on that but you could be right.
Other Jscript functions could be added too.

Using Jscript for quoting [like above] [and things like regex, btw] makes
coding mistakss fare less likely,

I don't believe that at all. I can't count the number of times I've left
Then off a If statement cos my head was in JScript mode instead of VBScript.
Coding in both languages is bound to increase the number of mistakes not
reduce them.
and comparing that to processing impact
is a personal choice.

For working with serverside UTC, Jscript can even do what VBscript
cannot, like using .getTimezoneOffset()

What if you turned the tables and did most stuff in JScript, is there
anything in VBScript you'd be prepared to launch the VBScript engine for?

Anthony
 
D

Dave Anderson

Evertjan. said:
I doubt if it is a "different one", believing it is one and the
same, but in the context of SMTP sending of an email with CDO,
JMail, etc, the possible timing and processor load impact seems
unimportant.

Why do you suppose there are separate DLLs for them if they are the same
engine?

\windows\system32\jscript.dll
\windows\system32\vbscript.dll
 
E

Evertjan.

Anthony Jones wrote on 06 jul 2007 in
microsoft.public.inetserver.asp.general:
I doubt if it is a "different one", believing it is one and the same,
but in the context of SMTP sending of an email with CDO, JMail, etc,
the possible timing and processor load impact seems unimportant.

I wouldn't bet on that but you could be right.
Other Jscript functions could be added too.

Using Jscript for quoting [like above] [and things like regex, btw]
makes coding mistakss fare less likely,

I don't believe that at all. I can't count the number of times I've
left Then off a If statement cos my head was in JScript mode instead
of VBScript. Coding in both languages is bound to increase the number
of mistakes not reduce them.

As I said, I think it is a personal programming choice.

I am used to having some functions in jscript,
while programming in asp-vbs.

What if you turned the tables and did most stuff in JScript, is there
anything in VBScript you'd be prepared to launch the VBScript engine
for?

Not really.

Most preferences are just habit. There is nothing wrong wih habit.

Having used Basic dialects since the early '80s, VBS comes easily to me,
but using J[ava]cript is like the joyful jump to Pascal [compiler] once
was.

The ease and compactness of Javascript, and the joy of making such
compact code, is like playing chess, where vbscript is an leasurely
scroll though the woods.

However exlusively using vbs serverside and javscript clientside in the
same asp file has it's merits.
 
D

Dave Anderson

Anthony said:
What if you turned the tables and did most stuff in JScript, is
there anything in VBScript you'd be prepared to launch the
VBScript engine for?

I'll answer that one. I do all of my ASP in JScript, and I have come up
against two problems that stump me.

The first is the most common -- lack of object documentation. Most examples
are written in VBScript, the vast majority of which utilize default
properties. Unless I can find a reference, those examples are worthless. If
the example uses CreateObject, I can probably work out a way to score an
intellisense hit, but there is no hope if GetObject is used (as virtually
every script in the MS TechNet Script Repository does).

I have considered using VBScript for a couple of LDAP problems I have been
working on recently, but I am leaning more and more toward popping over to
ASP.NET.

The second thing to tempt me into using VBScript was implementing a pure ASP
upload. I spent a few days trying to read the binary data before other
priorities intervened, and when I took it back up, decided on a hybrid
ASP/ASP.NET solution, which was a snap.

So, it appears I resist VBScript at all costs. I was actually baffled by
Evertjan's response myself. JScript is a fine language, but I only advocate
changing languages when a task is simple in one language and nearly
impossible in the other.
 
E

Evertjan.

Dave Anderson wrote on 06 jul 2007 in
microsoft.public.inetserver.asp.general:
Why do you suppose there are separate DLLs for them if they are the same
engine?

\windows\system32\jscript.dll
\windows\system32\vbscript.dll

You tell me.
 
R

Raju

dim a,b,c
const quote=""""
a="Test"
b= "(e-mail address removed)"
Response.Write c=quote & quote & quote & a & quote & quote & "<" & _
b & ">" & quote


This will only give Test. It removes the email for some reason.
 
B

Bob Barrows [MVP]

Raju said:
dim a,b,c
const quote=""""
a="Test"
b= "(e-mail address removed)"
Response.Write c=quote & quote & quote & a & quote & quote & "<" & _
b & ">" & quote


This will only give Test. It removes the email for some reason.

It doesn't for me ... oh, wait, your code looks different from mine. Try
this:

<%
dim a,b,c
const quote=""""
a="Test"
b= "(e-mail address removed)"
c=quote & quote & quote & a & quote & quote & "<" & _
b & ">" & quote
response.write c
%>

I've just tested it and it does what you want
 
B

Bob Barrows [MVP]

Raju said:
dim a,b,c
const quote=""""
a="Test"
b= "(e-mail address removed)"
Response.Write c=quote & quote & quote & a & quote & quote & "<" & _
b & ">" & quote


This will only give Test. It removes the email for some reason.

And, as Anthony pointed out elsewhere, Fiew Source to see the actual
text.

Alternatively, use htmlencode:

Response.Write server.htmlencode(c)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,093
Messages
2,570,607
Members
47,227
Latest member
bluerose1

Latest Threads

Top