473,387 Members | 1,844 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,387 software developers and data experts.

Randomly generated variables in ASP

Hi Friends,
I am relatively new to this generation of variables in ASP. I am unable
to proceed from here. Can somebody advise ?

Challenge :

I get number of participants in an exam, from a sql statement and
stored into a variable called headcount.

After that, I am using the following to initialize randomly generated
variables. For example if there are 4 students in the class, I intend
to get student1, student2, student3 and student4, all of them
initialized to 0.

For j=1 To CLng(headcount)
Eval Execute("student" & j & "=" & 0)
Next

Now we are trying to find out question wise defaults in the test. I
have a for loop that does traverse through all the questions in the
test. As I go question by question, if there is any failure I would
like to increment the errorcounter of that participant.

Which means

Q1. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.
Q2. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.

and so on.
<% do while not rs4.eof %>
<%
ctr = ctr + 1
if rs3("actualscore") = rs4("individualscore") then
Eval Execute("student" & "ctr" & " = " & "student" & "ctr" + 1)
end if
rs4.movenext
loop
ctr = 0
%>

My question is as ctr increases in the for loop, i want to append it to
student and take some values into it. i.e. student1=0, student2=1 etc.

So i am using this Eval Execute("student" & "ctr" & " = " & "student"
& "ctr" + 1).

Can someone help me please ???

Kind Regards,
raj.

Jan 15 '07 #1
3 1489

<va***********@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Hi Friends,
I am relatively new to this generation of variables in ASP. I am unable
to proceed from here. Can somebody advise ?

Challenge :

I get number of participants in an exam, from a sql statement and
stored into a variable called headcount.

After that, I am using the following to initialize randomly generated
variables. For example if there are 4 students in the class, I intend
to get student1, student2, student3 and student4, all of them
initialized to 0.

For j=1 To CLng(headcount)
Eval Execute("student" & j & "=" & 0)
Next

Now we are trying to find out question wise defaults in the test. I
have a for loop that does traverse through all the questions in the
test. As I go question by question, if there is any failure I would
like to increment the errorcounter of that participant.

Which means

Q1. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.
Q2. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.

and so on.
<% do while not rs4.eof %>
<%
ctr = ctr + 1
if rs3("actualscore") = rs4("individualscore") then
Eval Execute("student" & "ctr" & " = " & "student" & "ctr" + 1)
end if
rs4.movenext
loop
ctr = 0
use an array, somthing like this

dim anArray( headcount)
anArray(ctr) = whatever

%>

My question is as ctr increases in the for loop, i want to append it to
student and take some values into it. i.e. student1=0, student2=1 etc.

So i am using this Eval Execute("student" & "ctr" & " = " & "student"
& "ctr" + 1).

Can someone help me please ???

Kind Regards,
raj.

Jan 15 '07 #2

<va***********@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Hi Friends,
I am relatively new to this generation of variables in ASP. I am unable
to proceed from here. Can somebody advise ?

Challenge :

I get number of participants in an exam, from a sql statement and
stored into a variable called headcount.

After that, I am using the following to initialize randomly generated
variables. For example if there are 4 students in the class, I intend
to get student1, student2, student3 and student4, all of them
initialized to 0.

For j=1 To CLng(headcount)
Eval Execute("student" & j & "=" & 0)
Next

Now we are trying to find out question wise defaults in the test. I
have a for loop that does traverse through all the questions in the
test. As I go question by question, if there is any failure I would
like to increment the errorcounter of that participant.

Which means

Q1. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.
Q2. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.

and so on.
<% do while not rs4.eof %>
<%
ctr = ctr + 1
if rs3("actualscore") = rs4("individualscore") then
Eval Execute("student" & "ctr" & " = " & "student" & "ctr" + 1)
end if
rs4.movenext
loop
ctr = 0
%>

My question is as ctr increases in the for loop, i want to append it to
student and take some values into it. i.e. student1=0, student2=1 etc.

So i am using this Eval Execute("student" & "ctr" & " = " & "student"
& "ctr" + 1).

Can someone help me please ???
What need is an array.

ReDim aStudents(HeadCount)

ctr = 0
Do Until rs4.EOF
ctr = ctr + 1
If rs3("actualscore") = rs4("individualscore") Then
aStudents(ctr) = aStudents(ctr) + 1
End If
rs4.MoveNext
Loop
If you find yourself using the keywords Eval or Execute in your code, know
that you ARE doing something wrong. Not being aware of the existance of a
fundemental programming construct such as the Array is a common cause of
this error.
Jan 15 '07 #3
wrote on 15 jan 2007 in microsoft.public.inetserver.asp.general:
Hi Friends,
I am relatively new to this generation of variables in ASP. I am unable
to proceed from here. Can somebody advise ?
I suppose you want to generate a random value to a variable, not a random
variable.

Software can only generate pseudo random values, btw.
Challenge :

I get number of participants in an exam, from a sql statement and
stored into a variable called headcount.

After that, I am using the following to initialize randomly generated
variables. For example if there are 4 students in the class, I intend
to get student1, student2, student3 and student4, all of them
initialized to 0.

For j=1 To CLng(headcount)
Eval Execute("student" & j & "=" & 0)
Next
Do not, I mean never, never,
use eval() or execute() and both is out of the question.

Why not use an array?

student(j) = 0

and initiate the array with: dim student()
Now we are trying to find out question wise defaults in the test. I
have a for loop that does traverse through all the questions in the
test. As I go question by question, if there is any failure I would
like to increment the errorcounter of that participant.

Which means

Q1. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.
Q2. student1= 0, student2= 0, student3= 0, student4= 0 if all the
answers are fine.

and so on.
<% do while not rs4.eof %>
<%
why the %<% ?
ctr = ctr + 1
if rs3("actualscore") = rs4("individualscore") then
what is rs3 ?????????? thought you were using rs4
Eval Execute("student" & "ctr" & " = " & "student" & "ctr" + 1)
see above
end if
rs4.movenext
loop
ctr = 0
%>

My question is as ctr increases in the for loop, i want to append it to
student and take some values into it. i.e. student1=0, student2=1 etc.

So i am using this Eval Execute("student" & "ctr" & " = " & "student"
& "ctr" + 1).
student(ctr) = student(ctr+1)

btw:

I have not the faintest idea what you are getting at.

And I did not see any attempt to use a random number.

Perhaps by "random" you simply ment "dynamic",
the the number of students being unknown
and so variable at programming time?

dim student()

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 15 '07 #4

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

Similar topics

5
by: rich00 | last post by:
i am developing an asp.net web based application using javascript as the server side scripting language. The application makes constant use of an access database and session variables. in a random...
1
by: Suresh369 | last post by:
HI, I have a need to randomly access a Map element. For this I tried: int entry ; //Randomly generated map<int, int> blah; map<int, int>::iterator blahI; blahI = element + blah.begin();
3
Nert
by: Nert | last post by:
hi everyone, Could anyone please teach me how to make the randomly generated text as an image? same as the image we have seen when we were signing up in this forum (www.thescripts.com). this is my...
8
by: SAL | last post by:
Hello, I have a web app (asp.net 2.0) that I'm loosing Session variables in. I implemented: Application_End in Global.asax using the following code: Sub Application_End(ByVal sender As Object,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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,...
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...

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.