FREAKY -- 'loop' without 'do'

Results 1 to 3 of 3

Thread: FREAKY -- 'loop' without 'do'

  1. #1
    Joe Bankz Guest

    Default FREAKY -- 'loop' without 'do'

    HELP!!! I have tried everything I can think of being a familiar user of vbscript and asp. can anyone help me? <BR><BR>I get an error at<BR><BR>the code snippet that &#039;errors&#039; out looks like this:<BR><BR>Sub CalendarList<BR>Set conn0 = Server.CreateObject("ADODB.Connection")<BR> DB_CONN<BR>Set info = conn0.execute("select * from calendar where dowID = &#039;" & WeekDay(CurrentDate) & "&#039; AND " & SQLdate & " &#062;= StartDate AND " & SQLdate & " &#060;= EndDate order by time asc")<BR><BR>Do While Not info.eof<BR> StartDate = info(0)<BR> title = info(1)<BR> StartTime = info(2)<BR> blurb = info(3)<BR> Description = info(4)<BR> to_bring = info(5)<BR> catID = info(6)<BR> locID = info(7)<BR> ID = info(8)<BR> dowID = info(9)<BR> RepID = info(12)<BR><BR>If RepID = 1 And SQLdate = StartDate Then<BR> Call Dates<BR>ElseIf RepID = 2 Then<BR> If DayOfMonth = 1 AND Day(CurrentDate) &#060;= 7 Then<BR> Call Dates<BR> ElseIf DayOfMonth = 2 AND Day(CurrentDate) &#062; 7 AND Day(CurrentDate) &#060;= 14 Then<BR> Call Dates<BR> ElseIF DayOfMonth = 3 AND Day(CurrentDate) &#062; 14 AND Day(CurrentDate) &#060;= 21 Then<BR> Call Dates<BR> ElseIf DayOfMonth = 4 AND Day(CurrentDate) &#062; 21 AND Day(CurrentDate) &#060;= 28 Then<BR> Call Dates<BR> ElseIf DayOfMonth = 5 AND Day(CurrentDate) &#062; 28 AND Day(CurrentDate) &#060;= 31 Then<BR> Call Dates<BR> ElseIf DayOfMonth = 0 AND Day(CurrentDate) = Day(StartDate) Then<BR> Call Dates<BR> End If<BR>ElseIf RepID = 3 Then<BR>Call Dates<BR> info.MoveNext<BR>Loop<BR> conn0.close<BR> Set conn0 = Nothing<BR>End If<BR>End Sub<BR>

  2. #2
    Join Date
    Dec 1969

    Default Not freaky...expected...

    Look at the significant lines in your code *WITH* the proper indentation applied!<BR><BR>Do While Not info.eof<BR>&nbsp; &nbsp; If RepID = 1 And SQLdate = StartDate Then<BR>&nbsp; &nbsp; ElseIf RepID = 2 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; If DayOfMonth = 1 AND Day(CurrentDate) &#060;= 7 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<BR>&nbsp; &nbsp; &nbsp; &nbsp; End If<BR>&nbsp; &nbsp; ElseIf RepID = 3 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; Loop<BR>&nbsp; &nbsp; End If<BR><BR>???<BR><BR>See? There&#039;s no DO inside your "ElseIf RepID=3 Then...End If" code block, so you have a LOOP WITHOUT DO.<BR><BR>There *is* a reason for indentation. It helps find bugs like this.<BR><BR>By the way...What happens if RepID is equal to 1 but SQLDate does *NOT* equal startDate??? As your code sits now, you will generate no output whatsoever. <BR><BR>Where&#039;d you say you got this code from? Ummm...oh, you didn&#039;t. Is it your own?<BR><BR>

  3. #3
    Joe Banks Guest

    Default Thank You Mr.Wilkinson!

    Mr. Wilkinson,<BR>Thanks so much for your help! I have it indented in my page. It just didn&#039;t transfer when I copied it and pasted. I would like to know what the "proper" indentation method is, though. Could you direct me to an article?<BR><BR>All of this code is original with me. I am new and trying to learn the vbscript/asp ropes. <BR><BR>Thanks so much for your help. You&#039;re a great help!<BR><BR>Joe Banks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts