Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Constant

Status
Not open for further replies.

nonprogrammer

Technical User
Dec 28, 2005
143
US
Hello,

I have a quick Question.

Can a constant have a dynamic value?
something like:
Code:
const FLV_STR = <% = FRT %>
 
No, a constant is called a constant because it does not change. A dynamic value changes, so it would need to be stored in a variable.
 
Well that example looks like you are using ASP to write a constant for client-side VBScript and so yeah you could do that.
 
the thing is that when I write

Code:
<%
some more code in here

const FLV_STR = <% = FRT %>

some more code in here

%>[code]

I get the following error


Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/fbp/common.asp, line 36, column 17
const FLV_STR = <% = FRT
----------------^
 
oh no you cant do that.. you are opening up script delimmiters when you are already inside script delimitters.

[tt]
<% [green]'<---- open here[/green]
some more code in here

const FLV_STR = <% = FRT %>

some more code in here

%>
[/tt]

it looks like you need a variable instead of a const... what rjoubert said.
 
how would I write the variable? can I pass a variable to another asp page? if so how?
 
hmmm give us some more information... based on what we have so far there is more than one approach but if you give us more of an idea of your existing code and what you are trying to accomplish then one technique might be far better than others... Also dont forget to mention whether this other page is on the same server.
 
Looks like you are mixing up server and client side code. Presumably FRT comes from the client. In that case
Code:
<%
some more code in here

const FLV_STR = request("FRT")

%>
If it comes from the server and you are writing code for the client then
Code:
<% 'server bits
%>
<!-- client bits -->
<script language="vbscript">
const FLV_STR=<%=FRT%>
...
</script>
<% 'more server bits
%>
 
Thank you I really appreciate the help

like xwb suggested I did
Code:
<%
some more code in here

const FLV_STR = request("FRT")

%>
 
please follow Scheco's comments for future reference with your next postings. i saw no reference to you passing form values to your constant nor did anyone else other than a guess.

Check the FAQ's for best posting practices also

General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top