Randomly generated variables in ASP
Randomly generated variables in ASP
am 15.01.2007 17:24:59 von vadapallyraju
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.
Re: Randomly generated variables in ASP
am 15.01.2007 17:37:23 von Slim
wrote in message
news:1168878298.966062.147220@38g2000cwa.googlegroups.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.
>
Re: Randomly generated variables in ASP
am 15.01.2007 17:42:03 von Anthony Jones
wrote in message
news:1168878298.966062.147220@38g2000cwa.googlegroups.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.
Re: Randomly generated variables in ASP
am 15.01.2007 17:45:26 von exjxw.hannivoort
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)