473,799 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

execute() not working

Hello,

I have this code:
_______________ _______________ _______________ ___________

if VarType(eval("i nTotal" & 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("inTota l" & 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 1607

<iu*********@gm ail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hello,

I have this code:
_______________ _______________ _______________ ___________

if VarType(eval("i nTotal" & 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("inTota l" & 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.Dicti onary 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) = "ListOfValu es" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next

Set inTotal = CreateObject("S cripting.Dictio nary")

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*********@gm ail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hello,

I have this code:
_______________ _______________ _______________ ___________

if VarType(eval("i nTotal" & 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("inTota l" & 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.Dicti onary 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) = "ListOfValu es" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next

Set inTotal = CreateObject("S cripting.Dictio nary")

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*********@gm ail.comwrote in message
news:11******** **************@ e3g2000cwe.goog legroups.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*********@gm ail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hello,
>
I have this code:
_______________ _______________ _______________ ___________
>
if VarType(eval("i nTotal" & 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("inTota l" & 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.Dicti onary 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) = "ListOfValu es" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next

Set inTotal = CreateObject("S cripting.Dictio nary")

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*********@gm ail.comwrote in message news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hello,

I have this code:
_______________ _______________ _______________ ___________

if VarType(eval("i nTotal" & 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("inTota l" & 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*********@gm ail.comwrote in message
news:11******** **************@ e3g2000cwe.goog legroups.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*********@gm ail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hello,

I have this code:
_______________ _______________ _______________ ___________

if VarType(eval("i nTotal" & 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("inTota l" & 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.Dicti onary 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) = "ListOfValu es" & i
arr_(1,i) = i
arr_(2,i) = i * 2
Next
>
Set inTotal = CreateObject("S cripting.Dictio nary")
>
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*********@gma il.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
5393
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 as SQL Server allows it as the exemple bellow shows : EXECUTE 'SELECT * FROM Test' Is there any way to do so with DB2 ?
2
7624
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 Gcnndoh.Execute "AppendDataEntrySummaryLevel2" causes a Run-time error '-2147217900 (80040e14). If I execute the query from the query editor it's working ok!! No messages!!!
2
1987
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 Gcnndoh.Execute "AppendDataEntrySummaryLevel2" causes a Run-time error '-2147217900 (80040e14). If I execute the query from the query editor it's working ok!! No messages!!!
1
7207
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 procs, calling Execute() is no problem using JavaScript: var rs = cmd.Execute(); However, for non-recordset returning stored procs -- and this app has many -- I need to call Execute() passing adExecuteNoRecords for the Options parameter,...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.