$DEFINE over the hole programm

Post your requests and ideas on the future development of mikroPascal PRO for AVR.
Post Reply
Author
Message
Tefi
Posts: 3
Joined: 18 Oct 2009 22:20

$DEFINE over the hole programm

#1 Post by Tefi » 18 Oct 2009 22:29

I develope with Delphi and from here I have a wish, maybe easely to realise. I can define some FLAG for a hole programm.

I shout define a Flag in the main programm and check it in all linked units.
Is that possible to implement?

best regards

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: $DEFINE over the hole programm

#2 Post by corado » 30 Aug 2013 14:47

Yeah, thats an good Idea!! At this moment I try LunaAVR, that have this feature :-) and I like it,
but I want to USe Mikropascal too, because I hope it will be more better in the Future,so I want this feature too!

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: $DEFINE over the hole programm

#3 Post by filip » 02 Sep 2013 09:15

Hi,

You may do something similar with the Project Level Defines, please check this topic in the Help file.

Regards,
Filip.

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: $DEFINE over the hole programm

#4 Post by corado » 02 Sep 2013 18:09

oh, I'm not shure, If this is what I mean....
In C there is #define led1 as PortB.5;


led1:=1; //switch led on...

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: $DEFINE over the hole programm

#5 Post by filip » 06 Sep 2013 09:38

Hi,

You cannot do this in Pascal, you can just define a flag which you will test in the code :

Code: Select all

program Example;

{$DEFINE flag}

begin
  {$IFDEF flag}
    DDRC  := 0xFF
    PORTC := 0xAA
  {$ENDIF}
end;
Regards,
Filip.

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: $DEFINE over the hole programm

#6 Post by corado » 06 Sep 2013 10:53

oh, ok...that is not realy easier to read if I have long code an maybe 16LEDs..and 16 Idefs... :-(

stefkpl
Posts: 26
Joined: 21 Jan 2009 15:57

Re: $DEFINE over the hole programm

#7 Post by stefkpl » 08 Sep 2013 16:07

hi,

You can do this :

Code: Select all


{$DEFINE flag_1}

var
{$IFDEF flag_1}
    PortR_      : sbit at PORTB.0;
    PortV_      : sbit at PORTB.1;
    PortB_      : sbit at PORTB.2;
{$ENDIF}

{$IFDEF flag_2}
    PortR_      : sbit at PORTC.0;
    PortV_      : sbit at PORTC.1;
    PortB_      : sbit at PORTC.2;
{$ENDIF}

Begin
    PortR_  := 1;
    PortV_  := 0;
    PortB_  := 1;
end;
I think it's what you want to do.

Regards

Stéf

Post Reply

Return to “mikroPascal PRO for AVR Wish List”