I'm unable to figure out what it wrong with this

Func Hypotenuse($a, $b)
    Return sqrt($a * $a + $b * $b)
EndFunc

Error is

Func Hypotenuse($a, $b)
Func Hypotenuse($a, $b)^ERROR

Error: Illegal text at end of statement (one statement per line).

EDIT: It appears to have been a hidden character

有帮助吗?

解决方案 2

You copied code from AutoIt forum or some other Invision Power Board driven forum.

If that is correct, you copy the end-of-line HTML-character if you don't pop out the code box. Easiest fix for many lines is to CTRL + A, copy & paste into Notepad, then copy that and paste back into SciTE.

其他提示

Well, nothings wrong there :O

This:

Func Hypotenuse($a, $b)
    Return sqrt($a * $a + $b * $b)
EndFunc


ConsoleWrite(Hypotenuse(2,2))

Works perfect for me? And for you? Whats the rest of the Code?

This sort of thing can happen when you call your function from the incorrect If..Then statement. For example, the code

If Hypotenuse(1,1) > 0 Then ConsoleWrite("test" & @CRLF) EndIf

gives you an "Illegal text at end of statement" error, whereas the code

If Hypotenuse(1,1) > 0 Then ConsoleWrite("test" & @CRLF)

or

If Hypotenuse(1,1) > 0 Then
   ConsoleWrite("test" & @CRLF)
EndIf

works just fine.

I had the same issue when I had an extra ) at the end of the call.

Real code issue:

LogProgram("(SM) Selected Image SM: " & $imageList[$smPicName]))  

Correct:

LogProgram("(SM) Selected Image SM: " & $imageList[$smPicName])
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top