Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

grey code

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 943
Location: France

france.gif
PostPosted: Sun Feb 02, 2020 12:20 pm    Post subject: grey code Reply with quote

hello,
I was wondering about the unused code.
It appears in grey in the code, it's very useful for cleaning up.
but is it compiled and is it stored in the flash? unfortunately yes.
I'm working on a big program that exists in 4 versions,
not all of them use the same variables so it's handy to keep the grey lines.

Would it be possible to have a compile_Greycode =yes/no
in future releases ?

JP :wink:

(BASCOM-AVR version : 2.0.8.2 )

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5077
Location: Holland

blank.gif
PostPosted: Mon Feb 03, 2020 11:17 am    Post subject: Reply with quote

it is intended for the reason to clean up.
typically you activate it when your project is done.

if you have different versions, you can best use conditional compilation like :
const myproject=1 'use different values for different projects

#if myproject=1
dim somevar as byte
#elseif myproject=2
dim othervar as byte
#else
dim whatever as byte
#endif

this is a common way to use source for multiple projects

but that said, a future update can remove dead code as it is working as expected now.

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

Bascom Member



Joined: 04 Apr 2009
Posts: 862
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Mon Feb 03, 2020 10:44 pm    Post subject: Reply with quote

Greyed code for me is very useful. When I loose kind of track when I changed my mind for the tenth time on how to solve a problem
or make the program more efficient. In other words, a good thing!

Best regards
Hubert
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 943
Location: France

france.gif
PostPosted: Tue Feb 04, 2020 10:56 am    Post subject: Reply with quote

YES Hubert !
Wink

I hope I didn't misunderstand.
I like Code Grey. It's really very useful. We have to keep it that way.
I know #if ... and I use it, but it's not the same use.

The request of my message was the possibility to compile it or not in the .bin file.

JP

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Andreas_Schima

Bascom Member



Joined: 13 Dec 2010
Posts: 2

blank.gif
PostPosted: Thu May 21, 2020 1:18 pm    Post subject: Reply with quote

albertsm wrote:
[...]
but that said, a future update can remove dead code as it is working as expected now.


Please, please, don't do that.

In fact I'm looking for an option to switch off "dead code detection", because it doesn't work properly. Is there a way to disable that feature?

Best Regards,
Andreas

Edit: Here is some sample code to demonstrate problems with dead code detection (Bascom-AVR 2.0.8.2):

Code:
dim a as byte
dim b as byte
dim c as byte
dim d as byte

a = 0
b = 0
c = 1
d = 0

for a = 0 to 1
  if b = c then
    exit for
  endif
  d = 1
next a
print d
 


Line "d = 1" will be marked as "dead" - which is an incorrect interpretation.

Please do not install features that can potentially add confusion (at least make these features configurable, with "disabled" as default. Please leave it to the programmer to mess up code. Smile
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5077
Location: Holland

blank.gif
PostPosted: Thu May 21, 2020 7:05 pm    Post subject: Reply with quote

Quote:
In fact I'm looking for an option to switch off "dead code detection", because it doesn't work properly. Is there a way to disable that feature?


It seems to work ok for me.
i would recommend to read the help and the history.txt files.
The Dead Code option can be found under the Edit menu. In fact it has been mentioned on this forum too.

And the reason it does not work for your code is that you do not use the proper syntax. you use endif which should be END IF with a space.
if you enabled reformatting the endif will be corrected automatic into End If.
When you have cases where it does not work, check The Code Explorer. And if you find a real problem inform support about it so it can be changed.

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

Bascom Member



Joined: 13 Dec 2010
Posts: 2

blank.gif
PostPosted: Thu May 21, 2020 7:24 pm    Post subject: Reply with quote

albertsm wrote:
Quote:
In fact I'm looking for an option to switch off "dead code detection", because it doesn't work properly. Is there a way to disable that feature?


It seems to work ok for me.
i would recommend to read the help and the history.txt files.
The Dead Code option can be found under the Edit menu. In fact it has been mentioned on this forum too.

And the reason it does not work for your code is that you do not use the proper syntax. you use endif which should be END IF with a space.
if you enabled reformatting the endif will be corrected automatic into End If.
When you have cases where it does not work, check The Code Explorer. And if you find a real problem inform support about it so it can be changed.


Thank you for your immediate reply. Yes, I should have checked better.

Best Regards,
Andreas
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR 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