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
looping problem
Moderator: General Moderators
-
suhailkaleem
- Forum Newbie
- Posts: 12
- Joined: Thu Nov 07, 2002 9:11 am
- Contact:
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
suhailkaleem
- Forum Newbie
- Posts: 12
- Joined: Thu Nov 07, 2002 9:11 am
- Contact:
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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
If you want help with ASP in future please post in the Miscellaneous forum (to which this message has been moved).
Mac
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 oneI'm quite sure getVal called is printed only once
( was as Integer as function type declaration necessary/valid in ASP? )
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( was as Integer as function type declaration necessary/valid in ASP? )