Warum "Error: ELSE with no matching IF" ?

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Warum "Error: ELSE with no matching IF" ?

12 Oct 2018, 11:17

Code: Select all

If !ErrorLevel
	WinGetActiveStats, Titel, Breite, Höhe, X, Y
Else
	Exit
Return
Eigentlich logisch, war aber zuerst ziemlich verblüfft!
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Warum "Error: ELSE with no matching IF" ?

12 Oct 2018, 11:49

Hier ist die Erklärung. Es sieht so aus, als ob es einen Makro verwendet, um den Befehl zu konvertieren, oh Liebes.
[Here is the explanation. It looks like it uses a macro to convert the command, oh dear.]

Code: Select all

;before:
WinGetActiveStats, Titel, Breite, Höhe, X, Y

;after:
WinGetTitle,Titel,A
WinGetPos,X,Y,Breite,Höhe,A

Code: Select all

Error:  ELSE with no matching IF

	Line#
	001: if !ErrorLevel  
	002: WinGetTitle,Titel,A
	002: WinGetPos,X,Y,Breite,Höhe,A
--->	003: Else
	004: Exit
	005: Return
	006: Exit
	007: Exit
	007: Exit
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: Warum "Error: ELSE with no matching IF" ?

12 Oct 2018, 12:05

Ja, ist schon leicht verblüffend, aber die Doks sagen tatsächlich:
This command is equivalent to the following sequence:
WinGetTitle, Title, A
WinGetPos, X, Y, Width, Height, A
Äquivalenz impliziert dann wohl, dass es tatsächlich als zwei einzelne Kommandos behandelt wird. Blockklammern um WinGetActiveStats herum scheinen daher zu helfen, den Fehler zu vermeiden. Die Folgen könnten, für meinen Geschmack, etwas klarer aus den Doks hervorgehen. Der Fall ist mir allerdings noch nie untergekommen, aber das mag an mir liegen... :think:

Offtopic:
jeeswg wrote:oh dear = oh Liebes
Drollig :)
@jeeswg: Just out of interest, what translator did you use? It seems, google gives a more adequate translation as "ach je". "Liebes" is what you would call your girlfriend, wife, perhaps kid. Someone who is dear to you. But it is funny... ;)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Warum "Error: ELSE with no matching IF" ?

12 Oct 2018, 12:34

Ich habe Google Translate benutzt. Ich mache die Übersetzung auch umgekehrt, als Scheck. Ich weiß, dass Sätze wie "Prost" und "Ach Gott" möglicherweise falsch übersetzt werden, also verwende ich nur einen pro Post.
[I used Google Translate. I do the translation in reverse also, as a check. I know that phrases like 'cheers' and 'oh dear' might be translated incorrectly, so I only use one per post.]
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
just me
Posts: 9451
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Warum "Error: ELSE with no matching IF" ?

12 Oct 2018, 12:36

AHK hat ja schon immer den Ruf, etwas skuril zu sein. Das aber schlägt dem Fass den Boden aus. :shock:

Da macht der Interpreter beim Einlesen des Skripts aus einer Anweisung deren zwei und bemängelt, wenn das auf ein If folgt, die fehlenden Blockklammern. Man sieht mich fassungslos!

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 79 guests