Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

what does: #if varexist("nnnn") do?

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

Bascom Member



Joined: 13 Aug 2007
Posts: 414

newzealand.gif
PostPosted: Tue Dec 31, 2019 6:32 am    Post subject: what does: #if varexist("nnnn") do? Reply with quote

I cant seem to find any reference to this anywhere ??

(BASCOM-AVR version : 2.0.8.2 )

_________________
Neil
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 730

poland.gif
PostPosted: Tue Dec 31, 2019 9:12 am    Post subject: Reply with quote

Help-> "#IF" topic. On the bottom.

It means "If variable is defined then you can use it but if not then you can Dim it here" This is handy for include files.

Fof example my favourite multipurpose varaibles are Helpb As Byte or Helpw As Word so probably they are in my main code already but if you want to be sure that included part of the code will compile then you can add "If varexist("Helpw") ...#Else Dim Helpw As Word #Endif.

But this can also be used for some uC compatibility. You can check if uC have "Tifr" only or "Tifr2" for example because they are defined in the DAT files Very Happy
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1920

blank.gif
PostPosted: Tue Dec 31, 2019 12:23 pm    Post subject: Reply with quote

It originates from use within libs, where the user can define a variable, which can alter or extend code functionality, without having to alter the lib.
Code for a var called 'ABC' for example may only be implemented by conditional compiler directive if this variable actually exists by user-declaration, that's the varexist()'s purpose.

Else, it may be little known, that despite its name varexist() this function can be used also with constants.
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