pld files

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
dangerous
Posts: 748
Joined: 08 Mar 2005 16:06
Location: Nottinghamshire, UK

pld files

#1 Post by dangerous » 09 Nov 2021 16:49

Hi, I have been puzzling over how to format a pld file.

From other posts I have read it appears that comments are not supported although that is not documented in the help files.

If I write it as a module then add to the project in project manager it seems to work but if I comment an entry it is still sometimes remains active but not always.

I tried to write it as a txt file using notepad++ and that seems OK as well but adding comments still upset the operation.

Is it necessary to remove any things that need to represent #undefine in a normal module/program or can they be commented out, and if so is it the usual single quote mark or "rem" as in old basic, or maybe // as in C?

Is it possible for someone to post a correctly formatted file please, so I have a known working starting point.

This is what works if ctest is not preceded by a '.

Code: Select all

module HP

'''//'Must include this.pld file in project or it is ignored



setup


hidef



' ctest


implements

end.
Ctest is followed as though #defined and an address is modified. With the comment in place it still acts as though it were #defined. It is only not activated if the line is deleted.

Is there a way to have the option to undefine or define in the pld file?

Any help would be appreciated.

dangerous
Posts: 748
Joined: 08 Mar 2005 16:06
Location: Nottinghamshire, UK

Re: pld files

#2 Post by dangerous » 10 Nov 2021 10:43

Seems like I have answered my own question here. The question came about as I have several modules that had "#'ifdefine hidef" pre-processor statements and all have to have a common " #define hidef" in the modules. It is also easy to control declaration of variables and constants this way dependent on the state of the " #define hidef" as well, so this method seems to make more sense.

I have been playing with a simple file to control global defines for the project as a pld file

Several points seem relevant.

A new module file is started and all text in it removed including the title. It is then saved as a pld file, say My_test.pld. Alternatively it can be written with notepad or similar, so long as it is saved with the .pld suffix.

Any comments must be preceded by a delimiter. The Mikrobasic ' works but so does c type //, ! or any character. This sort of makes sense as the comment will not be looked for in the modules.

White space before the thing to be #defined is OK, and if you want to #undefine it add a single quote before the statement.

Any comments must be on a separate line and preceded by a single (or more) quote or other delimiter.

Any defines must also be on a new line.

VERY importantly after any changes to the file, use Rebuild all (alt + f9) or the changes will not be used. Some help is given here: https://www.mikroe.com/blog/project-level-defines

It is not fault tolerant so if you make a mistake it can get very difficult to debug so beware.

Code: Select all

//HP_pld  = project level defines for global pre-processor instructions
//Must include this.pld file in project  and re-build ALL sources or it is ignored
//If token is defined below, #ifdef token in any module will see and act on it as will #ifndef token etc



  setup
        //allows text from Uart2 to send setup parameters as ASCII text


 hidef
    //defines 10 bit A-D mode if uncommented, 8 bit if commented


 ctest
    //defines test address as 2 if uncommented or default 1  if not commented
If anyone has a better or more reliable way to do it please let us know.

Post Reply

Return to “mikroBasic PRO for PIC General”