"mingle" variables with string literals

Hi in PHP you can do this:
echo "you're logged in as {$username}"

is something similar possible in ASP?
wassa [ Fr, 25 Januar 2008 23:30 ] [ ID #1916319 ]

Re: "mingle" variables with string literals

Presuming VBScript and a value having been assigned to username.....

Response.Write ("you're logged in as " & username)

Bob Lehmann

"nick" <wassage [at] gmail.com> wrote in message
news:8111a196-f591-43d7-8d1c-eb5cbe178179 [at] s8g2000prg.googleg roups.com...
> Hi in PHP you can do this:
> echo "you're logged in as {$username}"
>
> is something similar possible in ASP?
Bob Lehmann [ Sa, 26 Januar 2008 01:13 ] [ ID #1916894 ]

Re: "mingle" variables with string literals

On Jan 26, 12:13 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> Presuming VBScript and a value having been assigned to username.....
>
> Response.Write ("you're logged in as " & username)

Yes I know that, but is it possible to do something like "you're
logged in as {username}"?

>
> Bob Lehmann
>
> "nick" <wass... [at] gmail.com> wrote in message
>
> news:8111a196-f591-43d7-8d1c-eb5cbe178179 [at] s8g2000prg.googleg roups.com...
>
>
>
>
>
> > Hi in PHP you can do this:
> > echo "you're logged in as {$username}"
>
> > is something similar possible in ASP?
wassa [ Sa, 26 Januar 2008 08:32 ] [ ID #1916898 ]

Re: "mingle" variables with string literals

nick wrote:
> On Jan 26, 12:13 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
>> Presuming VBScript and a value having been assigned to username.....
>>
>> Response.Write ("you're logged in as " & username)
>
> Yes I know that, but is it possible to do something like "you're
> logged in as {username}"?
>
Frankly, I thought that his answer implied that you couldn't (Bob is a man
of few words).

What you CAN do is use the Replace function to substitute values for
placeholders:

s="you're logged in as {$username}"
username = "something"
Response.Write Replace(s, "{$username}", username)

.... which is likely to be what PHP is doing for you behind the scenes (just
guessing here - I've never used PHP).
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
reb01501 [ Sa, 26 Januar 2008 13:32 ] [ ID #1916899 ]

Re: "mingle" variables with string literals

>> but is it possible to do something like "you're logged in as {username}"?

No. In VBSscript, variables embedded in a string cannot be parsed as they
can in PHP.

Since VB doesn't use that nasty '$' prefix for variables, how would it
differentiate variables from text?

Bob Lehmann

"nick" <wassage [at] gmail.com> wrote in message
news:04d0e818-f488-4186-a925-330c1eed062f [at] q77g2000hsh.google groups.com...
> On Jan 26, 12:13 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> > Presuming VBScript and a value having been assigned to username.....
> >
> > Response.Write ("you're logged in as " & username)
>
> Yes I know that, but is it possible to do something like "you're
> logged in as {username}"?
>
> >
> > Bob Lehmann
> >
> > "nick" <wass... [at] gmail.com> wrote in message
> >
> > news:8111a196-f591-43d7-8d1c-eb5cbe178179 [at] s8g2000prg.googleg roups.com...
> >
> >
> >
> >
> >
> > > Hi in PHP you can do this:
> > > echo "you're logged in as {$username}"
> >
> > > is something similar possible in ASP?
>
Bob Lehmann [ Sa, 26 Januar 2008 16:31 ] [ ID #1916901 ]

Re: "mingle" variables with string literals

On Jan 27, 12:32 am, "Bob Barrows [MVP]" <reb01... [at] NOyahoo.SPAMcom>
wrote:
> nick wrote:
> > On Jan 26, 12:13 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> >> Presuming VBScript and a value having been assigned to username.....
>
> >> Response.Write ("you're logged in as " & username)
>
> > Yes I know that, but is it possible to do something like "you're
> > logged in as {username}"?
>
> Frankly, I thought that his answer implied that you couldn't (Bob is a man
> of few words).
>

Er.. if he really is a man of few words, all he had to say was "NO".

I think he just assumed I am a complete noob to ASP

> What you CAN do is use the Replace function to substitute values for
> placeholders:
>
> s="you're logged in as {$username}"
> username = "something"
> Response.Write Replace(s, "{$username}", username)
>

Thanks but no thanks.
wassa [ So, 27 Januar 2008 11:47 ] [ ID #1917307 ]

Re: "mingle" variables with string literals

nick wrote:
> On Jan 27, 12:32 am, "Bob Barrows [MVP]" <reb01... [at] NOyahoo.SPAMcom>
> wrote:
>> nick wrote:
>>> On Jan 26, 12:13 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
>>>> Presuming VBScript and a value having been assigned to
>>>> username.....
>>
>>>> Response.Write ("you're logged in as " & username)
>>
>>> Yes I know that, but is it possible to do something like "you're
>>> logged in as {username}"?
>>
>> Frankly, I thought that his answer implied that you couldn't (Bob is
>> a man of few words).
>>
>
> Er.. if he really is a man of few words, all he had to say was "NO".
>
> I think he just assumed I am a complete noob to ASP

Well, given the question, along with the lack of context, is it so hard to
understand why that assumption would be made?


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
reb01501 [ So, 27 Januar 2008 14:14 ] [ ID #1917308 ]

Re: "mingle" variables with string literals

Oh, you're a real piece of work.

>> all he had to say was "NO".

Except the answer isn't "NO" You said -
>> is something similar possible in ASP?

I showed you something similar.

>> I think he just assumed I am a complete noob to ASP

Not sure where you are the noob scale, buddy. But I think you would be hard
pressed to find someone, even moderately skilled, asking the question you
did. Especially since you knew exactly what you meant when you asked it.

Bob Lehmann


>>> is something similar possible in ASP?
"nick" <wassage [at] gmail.com> wrote in message
news:961cedf4-b59e-4eb6-8396-c7aeb1ae5c9b [at] i7g2000prf.googleg roups.com...
> On Jan 27, 12:32 am, "Bob Barrows [MVP]" <reb01... [at] NOyahoo.SPAMcom>
> wrote:
> > nick wrote:
> > > On Jan 26, 12:13 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> > >> Presuming VBScript and a value having been assigned to username.....
> >
> > >> Response.Write ("you're logged in as " & username)
> >
> > > Yes I know that, but is it possible to do something like "you're
> > > logged in as {username}"?
> >
> > Frankly, I thought that his answer implied that you couldn't (Bob is a
man
> > of few words).
> >
>
> Er.. if he really is a man of few words, all he had to say was "NO".
>
> I think he just assumed I am a complete noob to ASP
>
> > What you CAN do is use the Replace function to substitute values for
> > placeholders:
> >
> > s="you're logged in as {$username}"
> > username = "something"
> > Response.Write Replace(s, "{$username}", username)
> >
>
> Thanks but no thanks.
Bob Lehmann [ So, 27 Januar 2008 20:52 ] [ ID #1917309 ]

Re: "mingle" variables with string literals

On Jan 28, 7:52 am, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> Oh, you're a real piece of work.
>
> >> all he had to say was "NO".
>
> Except the answer isn't "NO" You said -
>
> >> is something similar possible in ASP?
>
> I showed you something similar.

No you didn't. You showed me how to do simple string concatenation,
when it should've been obvious to anyone that I was asking for a more
advanced syntax/technique of doing the same thing?

Well I guess if you only code in vbscript you will have trouble
understanding my question in the first place.

"you're logged in as {$username}"???? Is that legal????
wassa [ Mo, 28 Januar 2008 02:40 ] [ ID #1918179 ]

Re: "mingle" variables with string literals

>>> Well I guess if you only code in vbscript
ummm.... No.

>>> You showed me how to do simple string concatenation,
Which is effectively what you are doing in PHP.

>>> understanding my question in the first place.
I understood your question exactly as it was asked. Maybe you should work on
that.

*PLONK*

Bob Lehmann

"nick" <wassage [at] gmail.com> wrote in message
news:6603f6b5-926c-4511-b2eb-bd1b0ce1d821 [at] d21g2000prg.google groups.com...
> On Jan 28, 7:52 am, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> > Oh, you're a real piece of work.
> >
> > >> all he had to say was "NO".
> >
> > Except the answer isn't "NO" You said -
> >
> > >> is something similar possible in ASP?
> >
> > I showed you something similar.
>
> No you didn't. You showed me how to do simple string concatenation,
> when it should've been obvious to anyone that I was asking for a more
> advanced syntax/technique of doing the same thing?
>
> Well I guess if you only code in vbscript you will have trouble
> understanding my question in the first place.
>
> "you're logged in as {$username}"???? Is that legal????
Bob Lehmann [ Mo, 28 Januar 2008 03:09 ] [ ID #1918180 ]

Re: "mingle" variables with string literals

On Jan 28, 2:09 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> >>> Well I guess if you only code in vbscript
>
> ummm.... No.
>
> >>> You showed me how to do simple string concatenation,
>
> Which is effectively what you are doing in PHP.

Simple = "blah blah" . $var
Bit more advance = "blah blah {$var}" or "blah blah $var"

I asked: Can you do "blah blah {$var}"?
You "answered": Yes, how about "blah blah " & var

LOL!

>
> >>> understanding my question in the first place.
>
> I understood your question exactly as it was asked.

Whatever.
wassa [ Mo, 28 Januar 2008 03:45 ] [ ID #1918181 ]

Re: "mingle" variables with string literals

"nick" <wassage [at] gmail.com> wrote in message
news:912d44ae-2545-4369-ae2b-6ce9372e6507 [at] 1g2000hsl.googlegr oups.com...
> On Jan 28, 2:09 pm, "Bob Lehmann" <nos... [at] dontbotherme.zzz> wrote:
> > >>> Well I guess if you only code in vbscript
> >
> > ummm.... No.
> >
> > >>> You showed me how to do simple string concatenation,
> >
> > Which is effectively what you are doing in PHP.
>
> Simple = "blah blah" . $var
> Bit more advance = "blah blah {$var}" or "blah blah $var"
>
> I asked: Can you do "blah blah {$var}"?
> You "answered": Yes, how about "blah blah " & var
>
> LOL!
>


Actually, Nick, you asked for something 'similar'. In the VBScript and
JScript string concatenation is the closest you'll get to performing a
'similar' operation to the one you described.

Fundementally in PHP strings are treated as expressions that need evaluating
whereas in VBScript and JScript they are primitive values that require no
further processing.

Therefore to perform something similar in the common script languages used
by ASP you need to make your string appear as an expression that needs
evaluating. The simplest way to do that is break it up into a series of
concatentations.

Is there some nuance of PHP behaviour we are missing here that means that
this approach doesn't meet your needs?


--
Anthony Jones - MVP ASP/ASP.NET
Anthony Jones [ Di, 29 Januar 2008 10:54 ] [ ID #1919175 ]
Webserver » microsoft.public.inetserver.asp.general » "mingle" variables with string literals

Vorheriges Thema: Problem separating request.form("value") from record ID
Nächstes Thema: Americana asd and Piilz 45a 875