The error is in the line:`
If number>high Then high=number
The statement high=number should be on its own line (no characters after the Then !)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I hope someone can point me in the right direction. I want to record the highest number in the variable "high"
I'm getting this error:
"I found 'high' when I was not expecting it", for line 76 which reads : If number>high Then high=number
Variables high and number set earlier in programme
Any ideas?
Section of code where error seems to be:
number1=textwindow.ReadNumber()
evens=0
odds=0
count=0
high=0
number=number1
While number<>"1"
'count steps
count=count+1
'Establish whether number entered is odd or even
rem= Math.Remainder (number,2)
If (rem = 0) Then
TextWindow.ForegroundColor="Yellow"
TextWindow.Write( number + " is even, so divide by 2 ")
evens=evens+1
number = number/2
TextWindow.CursorLeft=40
TextWindow.WriteLine("result = " + number)
TextWindow.ForegroundColor="White"
Else
TextWindow.ForegroundColor="White"
TextWindow.Write( number + " is odd, so x 3 and + 1 ")
odds=odds+1
number = number*3
number = number+1
If number>high Then high=number
EndIf
TextWindow.CursorLeft=40
TextWindow.WriteLine("result = " + number)
Program.Delay(300)
EndIf
EndWhile
The error is in the line:`
If number>high Then high=number
The statement high=number should be on its own line (no characters after the Then !)
I cracked it :-)
I used the MAX function in MATH
high=Math.Max(number,high)
I wonder whether having an if-then line within another if-then was the problem??