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 

Unexpected end-of-block error

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



Joined: 09 Feb 2006
Posts: 33

PostPosted: Sun Oct 01, 2006 6:56 pm    Post subject: Unexpected end-of-block error Reply with quote

Hello,

I've been writing a script for me, everything went ok but now I'm stuck.
I get this error:


Adding return doesn't help b/c I didn't use Gosub as far as I know.

Full script can be found here

Any help is welcome...
Tnx
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun Oct 01, 2006 7:01 pm    Post subject: Reply with quote

It is the "}", which does not have a "{" before.
Back to top
View user's profile Send private message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Sun Oct 01, 2006 7:11 pm    Post subject: Reply with quote

If I delete that I get this error:


It has something to do with GUI 4, I used a MsgBox before & everything was ok then.
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun Oct 01, 2006 7:21 pm    Post subject: Reply with quote

Maybe the pairing is wrong. Check that each "{" has a pairing "}" later. If you cannot find the problem post your code here.
Back to top
View user's profile Send private message
koro



Joined: 24 Sep 2006
Posts: 61

PostPosted: Sun Oct 01, 2006 7:24 pm    Post subject: Reply with quote

Try moving all the labels outside the nested braces using gosub-return (This will make the code much clearer too) . When something goes to "4ButtonYes", for instance, the program finds three consecutive closing braces which were never open (since you called that subroutine from other part of the code). (i don't see the script gosub-ing or goto-ing to that part ever, so i don't see what's the purpose of the labels, but i assume the script is incomplete yet).

Btw, nothing after the "Return" line in the "IfMsgBox, No" block will be executed, of course, so one more reason why i don't understand all that big block.

Edit: I double checked and your braces do match, there's no missing brace, but the way they are used is rather weird, so try what i said above. (and perhaps try using indentation to have a cleaner view of how the blocks are structured)
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun Oct 01, 2006 11:11 pm    Post subject: Reply with quote

Koro is right. You should not put subroutines inside blocks delimited by "{" and "}", but your GUI labels are put there. Try moving them at the end of the script.
Back to top
View user's profile Send private message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Sun Oct 01, 2006 11:55 pm    Post subject: Reply with quote

Laszlo wrote:
Koro is right. You should not put subroutines inside blocks delimited by "{" and "}", but your GUI labels are put there. Try moving them at the end of the script.
I've been on it for hours now, English isn't my native language so sorry for any stupid questions.
What subroutines are inside blocks?
Should I put all GUI's at the end of the script & refer to them via the Gosub thingy?
Can I refer to them directly by using there names (GUI, GUI2, ...)?

Any help is welcome since I'm a complete newbie at this Rolling Eyes

EDIT: if I change GUI4 to a MsgBox it works ok, I know my way isn't very good but it works. I'm still learning so I suppose I'll get it right some day.
The only reason I want to use a GUI instead of a MsgBox is b/c I wan't to add a button with the label 'Open folder'. I haven't found a good way to change the labels on a MsgBox so a GUI will have to do it.
The way to change labels found in AHK's help file isn't good b/c the button 'Yes' is for ex. in Dutch 'Ja', since this script should work on other computers (with a different language) it's not usefull for me.
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Mon Oct 02, 2006 9:59 am    Post subject: Reply with quote

Line 101, there is an extra }
Using a good editor like SciTE helps to find out these problems, because it shows pairing (or non-pairing) parentheses and braces, and allows to jump to the opening/closing counter-part.
BTW, improving your indenting should help you finding these problems.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Mon Oct 02, 2006 6:21 pm    Post subject: Reply with quote

An extra } ?

If I put an extra } there or if I delete it I get an error that 1 is missing.
For now I'm using the MsgBox again, I can't get GUI 4 to work.

If there is anybody that can help me, plz do Rolling Eyes

Tnx for suggesting SciTE, it is a lot easier this way Smile
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
koro



Joined: 24 Sep 2006
Posts: 61

PostPosted: Tue Oct 03, 2006 9:02 am    Post subject: Reply with quote

Whitespliff wrote:
Laszlo wrote:
Koro is right. You should not put subroutines inside blocks delimited by "{" and "}", but your GUI labels are put there. Try moving them at the end of the script.
I've been on it for hours now, English isn't my native language so sorry for any stupid questions.
What subroutines are inside blocks?


The ones from the gui... 4ButtonYes, etc.

Quote:

Should I put all GUI's at the end of the script & refer to them via the Gosub thingy?
Can I refer to them directly by using there names (GUI, GUI2, ...)?


The solution is to put all the *subroutines* associated to the guis outside the blocks (and with the necessary returns). As long as they have the appropriate label, it will work (i think).

Here's a copy of the first part of your code, with the unnecesary code removed, and commented so you can see what's wrong. Oh, and with some decent _indentation_!. I didn't double check it, but i think you'll get the idea.

Code:

IfExist, %A_WorkingDir%\muxman.ini
{
   MsgBox,    Something
   IfMsgBox, Cancel
      ExitApp   

   IfMsgBox, No    
   {
      FileInstall, stuff
      ;Notice that you didnt close this if, and you only close it many lines below
   
      Gui, 3:blabla
      Return ; Return to where? What's all the followng code for? You didn't close the "ifmsgbox, no" yet.

      3ButtonCancel:
         blabla
      ExitApp

      3ButtonOK:
         Gui, 3:Submit
      ;No return here? Then when one presses ok, the code will jump to here, and any "closing" brace that it finds
      ;will be unmatched in the subroutine.

      IniRead, OutputVar, %A_WorkingDir%\muxman.ini, root, path
      IniRead, InputVar, %A_WorkingDir%\muxman.ini, source, path

      if MyCheckboxN = 1
         Run, something
      ExitApp
   } ; Ok, you're closing the  "ifmsgbox, no" here? fine... no problem there... but...

; end of upgrade

   IfMsgBox, Yes
   {
      <do some stuff>
   
      if FolderSizeKB > 1
      {
         Gui, 4:blabla
         Return ; again, as before, you're not closing the if above.

         4ButtonNo:
         4GuiClose:
         4GuiEscape:
         ExitApp

         4ButtonOpenfolder:
            Run, explore %OutputVar%
         return

         4ButtonYes:
            Gui, 4:Submit
         ; no return here... same comment as before.
            FileRemoveDir, stuff
            FileDelete, more stuff
      } ; ok, this time there is no exitapp. The subroutine 4ButtonYes doesn't understand these 3 closing braces
   }
}
; end of if INI



Is it clear now? Neutral
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Tue Oct 03, 2006 11:10 am    Post subject: Reply with quote

Whitespliff wrote:
Tnx for suggesting SciTE, it is a lot easier this way Smile
Glad you like it. Smile Did you downloaded my SciLexer.dll with AutoHotkey support?
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Wed Oct 04, 2006 12:05 am    Post subject: Reply with quote

I think I've got it.
Tnx a lot for the help & tnx for suggesting SciLexer.dll with AutoHotkey support!

PS: code with indentations is a lot easier to read yes Wink
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Display posts from previous:   
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