"mingle" variables with string literals
am 25.01.2008 23:30:23 von wassaHi in PHP you can do this:
echo "you're logged in as {$username}"
is something similar possible in ASP?
Hi in PHP you can do this:
echo "you're logged in as {$username}"
is something similar possible in ASP?
Presuming VBScript and a value having been assigned to username.....
Response.Write ("you're logged in as " & username)
Bob Lehmann
"nick"
news:8111a196-f591-43d7-8d1c-eb5cbe178179@s8g2000prg.googleg roups.com...
> Hi in PHP you can do this:
> echo "you're logged in as {$username}"
>
> is something similar possible in ASP?
On Jan 26, 12:13 pm, "Bob Lehmann"
> 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"
>
> news:8111a196-f591-43d7-8d1c-eb5cbe178179@s8g2000prg.googleg roups.com...
>
>
>
>
>
> > Hi in PHP you can do this:
> > echo "you're logged in as {$username}"
>
> > is something similar possible in ASP?
nick wrote:
> On Jan 26, 12:13 pm, "Bob Lehmann"
>> 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"
>> 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"
news:04d0e818-f488-4186-a925-330c1eed062f@q77g2000hsh.google groups.com...
> On Jan 26, 12:13 pm, "Bob Lehmann"
> > 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"
> >
> > news:8111a196-f591-43d7-8d1c-eb5cbe178179@s8g2000prg.googleg roups.com...
> >
> >
> >
> >
> >
> > > Hi in PHP you can do this:
> > > echo "you're logged in as {$username}"
> >
> > > is something similar possible in ASP?
>
On Jan 27, 12:32 am, "Bob Barrows [MVP]"
wrote:
> nick wrote:
> > On Jan 26, 12:13 pm, "Bob Lehmann"
> >> 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.
nick wrote:
> On Jan 27, 12:32 am, "Bob Barrows [MVP]"
> wrote:
>> nick wrote:
>>> On Jan 26, 12:13 pm, "Bob Lehmann"
>>>> 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"
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"
news:961cedf4-b59e-4eb6-8396-c7aeb1ae5c9b@i7g2000prf.googleg roups.com...
> On Jan 27, 12:32 am, "Bob Barrows [MVP]"
> wrote:
> > nick wrote:
> > > On Jan 26, 12:13 pm, "Bob Lehmann"
> > >> 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.
On Jan 28, 7:52 am, "Bob Lehmann"
> 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????
>>> 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"
news:6603f6b5-926c-4511-b2eb-bd1b0ce1d821@d21g2000prg.google groups.com...
> On Jan 28, 7:52 am, "Bob Lehmann"
> > 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????
On Jan 28, 2:09 pm, "Bob Lehmann"
> >>> 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.
"nick"
news:912d44ae-2545-4369-ae2b-6ce9372e6507@1g2000hsl.googlegr oups.com...
> On Jan 28, 2:09 pm, "Bob Lehmann"
> > >>> 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