Variable to Constant

Results 1 to 2 of 2

Thread: Variable to Constant

  1. #1
    Join Date
    Dec 1969

    Default Variable to Constant

    Heres the problem. (i looked on 4guys and couldnt find a solution but i know it must be an easy one cause this is quite common im guessing)<BR><BR>I want to assign a variable as a constant<BR><BR>eg: <BR><BR>const file = filename<BR>const strFileName = Server.MapPath("/rants/" & file & ".txt")<BR><BR>But i then get the error message:<BR>Expected literal constant<BR>/rants.asp, line 14, column 21<BR>const file = filename<BR>--------------------^<BR><BR>Anyone able to help me out?<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default The constant must be a literal

    You cannot assign a variable value to a literal...<BR><BR>eg...<BR>const file = filename<BR><BR>would not work b/c filename is a variable name...<BR>slam quotes around it and there is your literal...<BR><BR>const file = "c:filename.txt"<BR><BR><BR>-- Whol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts