Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with looping construct

Status
Not open for further replies.

seddies

Programmer
Aug 8, 2001
5
US
I am trying to get some inserts going based on a number of formfield paramaeters that look like this.

UsrId = 2
Date = 10/19/2001
Time = 8
Shift = 1
WeekNum =
QcNum = 35, 36, 37
SampleFreq = 4, 2, 2
NumMeas = 5, 2, 3
TestGroup = 1, 1, 1
MachineID = 8, 8, 8
Measurement1 = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3

in this case there are 30 measurements to enter
what I have done is made arrays of all the pertaining fields
The number of measurements correspond to the elements in the samplefreq and the nummeas fields.

ie. qcNum 35, samplefreq(0) * nummeas(0) = 20

So I need to insert the measurement: 1 20 times

there are 3 qc nums so I have to get the next number of inserts to do qcnum 36, samplefreq(1) * nummeas(1) = 4

insert measurement: 2 4 times

etc etc.

hope you get the picture.

I can get the first insert to go but Im stuck on how to walk down each array and be able to multiply the 2 values together to get my number of inserts to do.

code:
' -- array of the number of machinneids
Mach = Split(Request.Form("MachineId"), ",")

'-- array of frequencies
Freqs = Split(Request.Form("SampleFreq"), ",")
nMeas1 = Split(Request.Form("Measurement1"), ",")
Samplesize = Split(Request.Form("NumMeas"), ",")


nStop = Samplesize(0) * Freqs(0)


Response.write &quot;nstop = &quot; & nstop & &quot;<P></P>&quot;

z = 0
Do until z = nStop
Response.write z & &quot;SQL = Insert INTO dbo.[Tests] (&quot;
response.write &quot;UsrId,Date,Time,Shift,Week,Measurement1&quot;
Response.write &quot;)
Values (&quot; & Request(&quot;UsrId&quot;) & &quot;,&quot; & Request(&quot;Date&quot;) & &quot;,&quot; & Request(&quot;Time&quot;) & &quot;,&quot; & Request(&quot;Shift&quot;) & &quot;,&quot; & nWeek & &quot;,&quot; & nMeas1(z) & &quot;)
&quot;
z = z + 1
LOOP

I'm hoping everyone understands this and if you could share some pseudocode or point me in the &quot;write&quot; direction I would be grateful.

Thanks.

Dave

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top