Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Proper Indent

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Rahalph

Bascom Member



Joined: 01 Mar 2014
Posts: 36

PostPosted: Sun Apr 20, 2014 9:18 am    Post subject: Proper Indent Reply with quote

Hi,

the new feature 'Proper Indent' is really great, thank you.

It saves a lot of work, but there are a few things that need to be improved:

1. The cases of a select case should not be indented. The 'case ...:' belongs to the 'select case', like the 'else' to the 'if'. This point might be debatable, so maybe as an option?
select case Anyvar
case 1:
__Blabla
case 2:
__Whatever
case else
__Nothing
end select

not:

select case Anyvar
__case 1:
____Blabla
__case 2:
____Whatever
__case else
____Nothing
end select

2. Comments which are placed at the start of the line should stay there if they next line is empty or a label. This point is a bit tricky. Example:
' DoAnyting does anything <- Correct
DoAnything:
__' Any comment <- This is okay
__SomeCode
__'return ' <--- This should stay at the start of the line

__' DoAnythingMore is for something else <--- Phew!
DoAnythingMore:
__SomeMoreCode
return

Thanks

Ralph

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
Frankeman

Bascom Member



Joined: 11 Aug 2004
Posts: 945
Location: the Netherlands

netherlands.gif
PostPosted: Sun Apr 20, 2014 9:51 am    Post subject: Reply with quote

I disagree with the Select case - case - end select.
Look at other programming IDE's they do it the same way as Bascom do.

Another thing i noticed:
Between a Label and a Return statement there are no lines drawn.
Back to top
View user's profile
PeterM

Bascom Member



Joined: 09 Jun 2008
Posts: 118

australia.gif
PostPosted: Sun Apr 20, 2014 9:52 am    Post subject: Reply with quote

Rohalph

Yes debatable, I suppose depends how you look at it and your Age in Computing over the years.
Partly how you described it makes sense somewhat, BUT Traditionaly thats how its always been.

Select Case NOT part of Case
Case Else is part of Select Case

Code:
Select Case Anyvar
    Case 1
       Blabla
    Case 2
       Whatever
Case Else
       Nothing
End Select


Code:
If A > 0 Then
   If A = 1 Then  
      Blabla
   ElseIf A = 2 Then Whatever
      ... Lets have rest
   End If
Else
   Nothing
End If


For each Major Statement is a Indent

If you look at most Source Code Beautifiers they follow the same model.

_________________
Peter
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5096
Location: Holland

blank.gif
PostPosted: Sun Apr 20, 2014 11:26 pm    Post subject: Reply with quote

I am used to VB and they format similar. I understand that this is all a matter of how you are used to it.
Change for next update :
- comment will never be moved. i found it better to leave comment at the designed position

_________________
Mark
Back to top
View user's profile Visit poster's website
Rahalph

Bascom Member



Joined: 01 Mar 2014
Posts: 36

PostPosted: Mon Apr 21, 2014 7:57 am    Post subject: Reply with quote

Hi Mark,

you're right. It's all a matter of what you are used to. I started with Delphi more than 20 years ago and that's how I thought it would make sense. When I got to VS and C# I simply changed the default setting for formatting. That's why I was asking for an option Smile

The idea regarding the comments is great, thank you very much!

Regards

Ralph
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum