After experiencing a lot of down time, We decided to move this site to
CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.
Problem with execute command
|
Author |
Message
|
tjodalv
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/4/2009
-
Status: offline
|
Problem with execute command
Friday, December 04, 2009 1:25 AM
( permalink)
Hello I want to create variable dynamically in runtime, so I tried to use Execute command but I always get an error saying: Expected end of statement This is what I am trying to do: x = "my_variable_name" y = "this is variable value" Execute(x & " = " & y) '<- Error is in this line Response.Write my_variable_name When I try to execute class than it's working fine for eg. like this: my_class_var = "blog" class_name = "cBlog" Execute("set " & my_class_var & " = New " & class_name) Can anyone help me pls.
|
|
|
|
centauricw
-
Total Posts
:
42
- Scores: 2
-
Reward points
:
0
- Joined: 2/20/2006
-
Status: offline
|
Re:Problem with execute command
Friday, December 04, 2009 1:59 AM
( permalink)
You cannot create a variable dynamically. The statement Execute( x & " = " & y) fails because what you are really doing is an assignment statement between two strings as your statement is actually this: Execute( "my_variable_name" & " = " & "this is variable value" ) which is the same as "my_variable_name" = "this is variable value" therefore the error message: Microsoft VBScript compilation error: Expected end of statement
<message edited by centauricw on Friday, December 04, 2009 2:00 AM>
|
|
|
|
tjodalv
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/4/2009
-
Status: offline
|
Re:Problem with execute command
Friday, December 04, 2009 2:06 AM
( permalink)
Yes but then I could write just like this: my_variable_name = this is variable value What is the point of Execute then. I need to create variables dynamically.
|
|
|
|
tjodalv
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/4/2009
-
Status: offline
|
Re:Problem with execute command
Friday, December 04, 2009 3:14 AM
( permalink)
I've managed to solve the problem this is magic line :D Execute(x & "=""" & y & """")
|
|
|
|
ebgreen
-
Total Posts
:
8088
- Scores: 95
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:Problem with execute command
Friday, December 04, 2009 3:28 AM
( permalink)
I will point out that I have yet to have anyone show me a case where execute is required for dynamic variables. With the information that you have provided, a dictionary would work just fine with no need for the use of execute at all. Execute is bad in a purely client side script. In a web environment, it is anathema.
|
|
|
|
Online Bookmarks Sharing: