AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error: A Goto/Gosub must not jump into a block that doesn't

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
feejo



Joined: 16 Jun 2007
Posts: 245

PostPosted: Tue Jan 22, 2008 8:35 pm    Post subject: Error: A Goto/Gosub must not jump into a block that doesn't Reply with quote

Error: A Goto/Gosub must not jump into a block that doesn't enclose it.

Code:

PixelGetColor, 3NB, 232, 195 ; 3e prix

If (3nb = 0x0080FF) ; Si le 3e chiffre est Orange, c'est un niveau 1 (JVO)
{
  num:=1
  Goto, fin
}

Else ; Pas détecté il recherche niveau 2.

...


Fin:
...
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 383
Location: Berlin

PostPosted: Tue Jan 22, 2008 8:42 pm    Post subject: Reply with quote

You should rework your script. AutoHotkey checks the whole scripts labels (but not that ones in a function). I have no clue how to solve this.

But why do you need this? Try to change the IF structure.
Back to top
View user's profile Send private message Send e-mail
Superfraggle



Joined: 02 Nov 2004
Posts: 970
Location: London, UK

PostPosted: Tue Jan 22, 2008 8:57 pm    Post subject: Reply with quote

If you enclose the if and else code correctly the goto is not required.

Example
Code:

If A=1
{
Do this
}
Else
{
Do this instead
}
Finish:

Which is what tuncay said Smile
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
feejo



Joined: 16 Jun 2007
Posts: 245

PostPosted: Wed Jan 23, 2008 9:38 pm    Post subject: Reply with quote

Here is my full script, I put a
*************ERROR HERE**************
where the script block.


Code:

1:

PixelGetColor, 3NB, 232, 195 ; 3e
If (3nb = 0x0080FF) ;Orange
{
  num:=1  ; nombre de beep.
  ;Tooltip, Niveau 1 détecté. JVO.
 

  ;Sleep, 1000 ; pour attendre avant de rechèquer.



  Goto, Fin ; *************ERROR HERE**************
}
Else ; Pas détecté il recherche niveau 2.



;Chèque pour le niveau 2 (JVV), il y a 2 conditions: vert sur 2e et 3e.
PixelGetColor, 2NB, 232, 180
If (2nb = 0x00FF00) ;vert
{
  PixelGetColor, 3NB, 232, 195
  If (3nb = 0x00FF00) ;Vert
  {
 
  num=3
    Goto, fin
  }

}
Else ;Chèque niveau 3



; Il va chèquer niveau 3: JJV

If (2nb = 0x00FFFF) ;J
{
  If (3nb = 0x00FF00) ;V
  {
    num:=3  ; nombre de beep.
    Goto, Fin
  }
}

Else ; c'est niveau 4 ou rien.



;Va chèquer pour un niveau 4
PixelGetColor, 3NB, 232, 195
If (3nb = 0x00FFFF) ;J
{
  num:=4  ; nombre de beep.
  ;Tooltip, Niveau 1 détecté. JVO.
 

  ;Sleep, 1000 ; pour attendre avant de rechèquer.



  Goto, Fin
 
}
Else

Fin:
Loop
{
   ;InputBox, Num, Select, The number   of beeps
   If !Num or (Num = OldNum)
      Continue
   OldNum := Num
   Loop %Num%
      SoundBeep
   }
  Goto, 1
Exit
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Jan 23, 2008 10:30 pm    Post subject: Reply with quote

Hi,
Is it the whole code?
The "1" label has no "Return" and there are useless "Elses".
Use proper code indentation to spot the errors.
Back to top
feejo



Joined: 16 Jun 2007
Posts: 245

PostPosted: Thu Jan 24, 2008 5:30 pm    Post subject: Reply with quote

Why when I execute this when it reach ******HERE******** num = empty.

Code:
1:
num:=1

Fin:
 ;InputBox, Num, Select, The number   of beeps
   Sleep, 1
   Msgbox, num = %num% oldnum = %OldNum%
   If (num:=OldNum)
   {
   goto, 1
   }
 
   Else
   
   {
   Sleep, 1000 ; Pour laisser le temps d'entendre lorsqu'il peut y avoir changement.
     Msgbox, num = %num% oldnum = %OldNum% ******HERE********
   
    SoundBeep 3000
    num:=OldNum
    Msgbox, num = %num% oldnum = %OldNum%
    Goto, 1
         }
Exit
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Jan 24, 2008 5:54 pm    Post subject: Reply with quote

this line "If (num:=OldNum)" should be "If (num=OldNum) or If num=%OldNum%".
The way it is you assigning to num the value stored in OldNum(blank)
Back to top
feejo



Joined: 16 Jun 2007
Posts: 245

PostPosted: Thu Jan 24, 2008 6:39 pm    Post subject: Reply with quote

Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group