473,396 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

execute() not working

Hello,

I have this code:
__________________________________________________ ______

if VarType(eval("inTotal" & arr(4,i1)))=0 then
response.write "ok, dim"
execute("dim inTotal" & arr(4,i1) & ":inTotal" & arr(4,i1) & "=" &
arr_(i1,i2))
'it is working, I have variable
else
execute("inTotal" & arr(4,i1) & " = inTotal" & arr(4,i1) & " + " &
arr_(i1,i2))
'here is not working any more.
end if
__________________________________________________ ______

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 308

What should be the problem?

Oct 13 '06 #1
6 1594

<iu*********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I have this code:
__________________________________________________ ______

if VarType(eval("inTotal" & arr(4,i1)))=0 then
response.write "ok, dim"
execute("dim inTotal" & arr(4,i1) & ":inTotal" & arr(4,i1) & "=" &
arr_(i1,i2))
'it is working, I have variable
else
execute("inTotal" & arr(4,i1) & " = inTotal" & arr(4,i1) & " + " &
arr_(i1,i2))
'here is not working any more.
end if
__________________________________________________ ______

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 308

What should be the problem?
The problem is your using Execute and Eval. Stop using them. Make inTotal
into an array then you don't need them. If arr(4, i1) returns a string then
use a Scripting.Dictionary object to store a name/value pairs.

Slap this in a VBS file and take a look at how it works:-

Dim arr_(2,2)
Dim temp
Dim Key
Dim i, j
Dim inTotal

For i = 0 to 2
arr_(0,i) = "ListOfValues" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next

Set inTotal = CreateObject("Scripting.Dictionary")

For i = LBound(arr_, 2) to UBound(arr_, 2)
temp = 0
For j = 1 To UBound(arr_, 1)
temp = temp + arr_(j, i)
Next
inTotal(arr_(0,i)) = inTotal(arr_(0,i)) + temp
Next

For Each Key In inTotal
MsgBox Key & " Total = " & inTotal(Key)
Next

Anthony.

Oct 13 '06 #2
I have to use those two (eval and execute), I have no other way to
resolve this because I can have 20 variables or more, just one or none.
So, obviously that I don't know what variables to define. I use option
explicit so it is mandatory to define them.

Another solution is to define an array with n elements (i.e.: arr(58))
and use only some of them (i.e.: arr(1), arr(32)) but in this case I
load in memory a full array. Is not a very good solution.

By the way: I made it work in the way I wanted.

Anthony Jones wrote:
<iu*********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I have this code:
__________________________________________________ ______

if VarType(eval("inTotal" & arr(4,i1)))=0 then
response.write "ok, dim"
execute("dim inTotal" & arr(4,i1) & ":inTotal" & arr(4,i1) & "=" &
arr_(i1,i2))
'it is working, I have variable
else
execute("inTotal" & arr(4,i1) & " = inTotal" & arr(4,i1) & " + " &
arr_(i1,i2))
'here is not working any more.
end if
__________________________________________________ ______

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 308

What should be the problem?

The problem is your using Execute and Eval. Stop using them. Make inTotal
into an array then you don't need them. If arr(4, i1) returns a string then
use a Scripting.Dictionary object to store a name/value pairs.

Slap this in a VBS file and take a look at how it works:-

Dim arr_(2,2)
Dim temp
Dim Key
Dim i, j
Dim inTotal

For i = 0 to 2
arr_(0,i) = "ListOfValues" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next

Set inTotal = CreateObject("Scripting.Dictionary")

For i = LBound(arr_, 2) to UBound(arr_, 2)
temp = 0
For j = 1 To UBound(arr_, 1)
temp = temp + arr_(j, i)
Next
inTotal(arr_(0,i)) = inTotal(arr_(0,i)) + temp
Next

For Each Key In inTotal
MsgBox Key & " Total = " & inTotal(Key)
Next

Anthony.
Oct 13 '06 #3

<iu*********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
I have to use those two (eval and execute), I have no other way to
resolve this because I can have 20 variables or more, just one or none.
So, obviously that I don't know what variables to define. I use option
explicit so it is mandatory to define them.

Another solution is to define an array with n elements (i.e.: arr(58))
and use only some of them (i.e.: arr(1), arr(32)) but in this case I
load in memory a full array. Is not a very good solution.

By the way: I made it work in the way I wanted.
Each to his own. But arr(58) would've been better it equates to ;ess than
1KB of memory and will significantly out perform Executes and Evals.

>
Anthony Jones wrote:
<iu*********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,
>
I have this code:
__________________________________________________ ______
>
if VarType(eval("inTotal" & arr(4,i1)))=0 then
response.write "ok, dim"
execute("dim inTotal" & arr(4,i1) & ":inTotal" & arr(4,i1) & "=" &
arr_(i1,i2))
'it is working, I have variable
else
execute("inTotal" & arr(4,i1) & " = inTotal" & arr(4,i1) & " + " &
arr_(i1,i2))
'here is not working any more.
end if
__________________________________________________ ______
>
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 308
>
What should be the problem?
>
The problem is your using Execute and Eval. Stop using them. Make
inTotal
into an array then you don't need them. If arr(4, i1) returns a string
then
use a Scripting.Dictionary object to store a name/value pairs.

Slap this in a VBS file and take a look at how it works:-

Dim arr_(2,2)
Dim temp
Dim Key
Dim i, j
Dim inTotal

For i = 0 to 2
arr_(0,i) = "ListOfValues" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next

Set inTotal = CreateObject("Scripting.Dictionary")

For i = LBound(arr_, 2) to UBound(arr_, 2)
temp = 0
For j = 1 To UBound(arr_, 1)
temp = temp + arr_(j, i)
Next
inTotal(arr_(0,i)) = inTotal(arr_(0,i)) + temp
Next

For Each Key In inTotal
MsgBox Key & " Total = " & inTotal(Key)
Next

Anthony.

Oct 13 '06 #4
obviously we can't help as we don't know what line 308 is.....
<iu*********@gmail.comwrote in message news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I have this code:
__________________________________________________ ______

if VarType(eval("inTotal" & arr(4,i1)))=0 then
response.write "ok, dim"
execute("dim inTotal" & arr(4,i1) & ":inTotal" & arr(4,i1) & "=" &
arr_(i1,i2))
'it is working, I have variable
else
execute("inTotal" & arr(4,i1) & " = inTotal" & arr(4,i1) & " + " &
arr_(i1,i2))
'here is not working any more.
end if
__________________________________________________ ______

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 308

What should be the problem?

Oct 13 '06 #5

Anthony Jones wrote:
<iu*********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
I have to use those two (eval and execute), I have no other way to
resolve this because I can have 20 variables or more, just one or none.
So, obviously that I don't know what variables to define. I use option
explicit so it is mandatory to define them.

Another solution is to define an array with n elements (i.e.: arr(58))
and use only some of them (i.e.: arr(1), arr(32)) but in this case I
load in memory a full array. Is not a very good solution.

By the way: I made it work in the way I wanted.

Each to his own. But arr(58) would've been better it equates to ;ess than
1KB of memory and will significantly out perform Executes and Evals.


Anthony Jones wrote:
<iu*********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I have this code:
__________________________________________________ ______

if VarType(eval("inTotal" & arr(4,i1)))=0 then
response.write "ok, dim"
execute("dim inTotal" & arr(4,i1) & ":inTotal" & arr(4,i1) & "=" &
arr_(i1,i2))
'it is working, I have variable
else
execute("inTotal" & arr(4,i1) & " = inTotal" & arr(4,i1) & " + " &
arr_(i1,i2))
'here is not working any more.
end if
__________________________________________________ ______

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 308

What should be the problem?

>
The problem is your using Execute and Eval. Stop using them. Make
inTotal
into an array then you don't need them. If arr(4, i1) returns a string
then
use a Scripting.Dictionary object to store a name/value pairs.
>
Slap this in a VBS file and take a look at how it works:-
>
Dim arr_(2,2)
Dim temp
Dim Key
Dim i, j
Dim inTotal
>
For i = 0 to 2
arr_(0,i) = "ListOfValues" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next
>
Set inTotal = CreateObject("Scripting.Dictionary")
>
For i = LBound(arr_, 2) to UBound(arr_, 2)
temp = 0
For j = 1 To UBound(arr_, 1)
temp = temp + arr_(j, i)
Next
inTotal(arr_(0,i)) = inTotal(arr_(0,i)) + temp
Next
>
For Each Key In inTotal
MsgBox Key & " Total = " & inTotal(Key)
Next
>
Anthony.
Anthony, if I use arr(n) is more efficiently than using execute("dim
var...") ?

Oct 22 '06 #6
iu*********@gmail.com wrote:
Anthony, if I use arr(n) is more efficiently than using execute("dim
var...") ?
Absolutely. Execute should be avoided like the plague.

http://blogs.msdn.com/ericlippert/ar.../01/53329.aspx
http://blogs.msdn.com/ericlippert/ar.../04/53335.aspx

--
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"
Oct 22 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Doohan W. | last post by:
Hi, I'm now working with DB2, and I can't find out how to execute the contents of a string Statement, without using a Java/... procedure, only using SQL statements. I know that some SQBDs such...
2
by: Norman Fritag | last post by:
Hi there The below code executes some queries. As newbie I was wondering weather you are better of using connection execute or command execute to execute queries? I am asking as...
2
by: Norman Fritag | last post by:
Hi there The below code executes some queries. As newbie I was wondering weather you are better of using connection execute or command execute to execute queries? I am asking as...
1
by: mikegolden | last post by:
An application I'm working on makes extensive use of output parameters and return values, thus forcing me to use the ADODB Command object to execute the stored procs. For recordset returning stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.