Page 1 of 1

looping problem

Posted: Thu Nov 07, 2002 9:11 am
by suhailkaleem
hi!
i know the belwo code is in asp can be easily be converted to php , but that does not make much difference .


<%
n=0
'j=1
for i=0 to j

if n<>90 then
j=j+1
response.write "<br>j= "&j
end if
n=n+1
response.write "<br>n= "&n
next

'This must loop 90 times but it loops 1 time why is that ?
'anyhelp ?
%>

suhailkaleem

Posted: Thu Nov 07, 2002 9:19 am
by twigletmac
Are you looking for help in having this converted to PHP or do you want help with the ASP?

Mac

Posted: Thu Nov 07, 2002 9:24 am
by suhailkaleem
twigletmac wrote:Are you looking for help in having this converted to PHP or do you want help with the ASP?

Mac

n=0
'j=1
for i=0 to j

if n<>90 then
j=j+1
response.write "<br>j= "&j
end if
n=n+1
response.write "<br>n= "&n
next

'This must loop 90 times but it loops 1 time why is that ?
'anyhelp ?

Posted: Thu Nov 07, 2002 9:33 am
by twigletmac
OK, if this question is not about PHP then it does not belong in the PHP forum.

If you want help with ASP in future please post in the Miscellaneous forum (to which this message has been moved).

Mac

Posted: Fri Nov 08, 2002 2:44 am
by volka
It's been a while that I used ASP and no IIS is as hand right now.
But afaik then end-value of an for-loop is calculated only once.
You may change the counter but not the loop-edges.
To be sure try this one

Code: Select all

Function getVal(j As Integer) As Integer
  getVal = j
  response.write "getVal called<br>"
End Function

n = 0
j = 10
For i = 0 To getVal(j)
  If n <> 90 Then
    j = j + 1
  End If
  n = n + 1
Next
I'm quite sure getVal called is printed only once
( was as Integer as function type declaration necessary/valid in ASP? )