Sharp Develop unexpected indent

Sharp Develop unexpected indent

stever66
Advisor Advisor
994 Views
4 Replies
Message 1 of 5

Sharp Develop unexpected indent

stever66
Advisor
Advisor

I have pasted some code into the Sharp Develop Macro editor from notepad.  I'm using python, and I keep getting "unexpected indent" errors even when all the code is correctly lined up.

 

I figured its something to do with spaces vs. tabs.  So I'll re-enter all the tabs on the lines.  (I start on the line with the error, and backspace to the line above, and hit enter and tab to the right position.)  That moves the error to the next line, and I have to do this with every single line.

 

Sometimes that moves the error to the next line, and I just keep doing this and the error just keeps moving around.   If I get it the error to the bottom line,it just won't go away.  I've tried retyping lines,  and everything else I can think of.  I've spent over an hour just trying to get about 12 lines to compile do to this one error.

 

Any suggestions?  This is making Sharp develop completely unusable.

 

Apparently I can't insert a screen shot.  The "Insert Image" button works, but then the "browze" button  doesn't work.  The browze button for attachments doesn't work either.

 

0 Likes
995 Views
4 Replies
Replies (4)
Message 2 of 5

rosalesduquej
Alumni
Alumni

Hi Steve, 

 

Not very familiar with Phython and Revit but I browsed around and I found a couple of good explanations in regards to your error that might give you an idea on how to fix it. 

 

http://stackoverflow.com/questions/1016814/what-to-do-with-unexpected-indent-in-python 

 

and one of the comments have the following suggestion "Besides that, I also spent indent Unexpected error when he mixed spaces with 'tab' and 'space bar' in NotePad ++, replace the 'tab' for 'spaces' and fixed" maybe can be something that will work for you. 

 

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 3 of 5

stever66
Advisor
Advisor

Thank you for the reply.   I also found and read that thread on stackoverflow.

 

I have been trying to use all tabs for whitespace, and no spaces.   They recommend the opposite - using spaces.  I believe either way should work if one stays consistent and doesn't mix tabs and spaces.

 

I was hoping SharpDevelop might have an option to show the whitespace formatting.   Or maybe even a fast way to format sections (indent a group of lines to the same level) or something like that.   Maybe in a future release.

 

I did have better luck backspacing to the begining of a line and re-entering tabs.  (That seemed to work better than backspacing to the line before, and pressing enter so Sharp automatically inserts the indent).

 

 

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

Notepad++ Allows you to view whitespace symbols and it can also perform block indenting by highlighting multiple lines and hitting tab to increase indent or shift tab to reduce indent. Give that a try. I could never understand why anyone thought indent-scoping was a good idea.

0 Likes
Message 5 of 5

stever66
Advisor
Advisor

But the problem really seems to be in SharpDevelop.  The reason I say that, is I can delete all the white space, re-align everything using only tabs, and Sharp still complains.

 

At least I've figured out how to get it to work, and I frequently just have to delete an entire line of code and retype it.  For some reason, these always seem to be the comment lines.

 

In case anyone else has this problem, here is what seems to hold true for me:

 

1.  If you get an unexpected indent error, and all the lines look indented correctly-

2.  Start at the end of the line before the error and delete all the white space so the 2 lines of code become a single long line.

3.  Press enter to separate the lines again. 

4a.  If Sharp automatically inserts the correct indent, that line should be fixed.   Rebuild the Macro, and you will probably have to repeat this process, working your way toward the end of the Macro. 

4b.  If Sharp automatically inserts an extra indent when you press enter, you will probably have to delete the line of code before the error and retype it. 

As I mentioned, these lines usually tend to be comment lines for some reason.

 

I can't figure out why Sharp thinks there should be an extra indent after the comment lines, and I can't figure out why deleting that extra whitespace doesn't work.

 

 

 

0 Likes