> > William Chops" Westfield" wrote: > > > Please provide a pascal example that works with at least > two different > > vendors' pascal compilers. > > -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu] On Behalf Of Olin Lathrop > Sent: 02 July 2009 01:00 > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] using BREAK in 'C' > > No, you're missing the point again. We're talking about > computer science concepts, not particular implementations. > The point is that what you want to do is possible in a more > tightly typed language like Pascal. A single instance is > proof enough. I think you are missing Bills point. Can you take the code you have just written and be sure it will compile and work on any arbitrary Pascal compiler? Would you really want to have to have a diffierent implementaion of this code for each target you want to use it on? Most of the projects I work on keep the CPU pretty busy with a lot of completely separate tasks, but since we don't use an RTOS, each task is impleneted using a state machine. All variables that are only used by the task (e.g. the timer and state variable) are declared static within the task function, since they need to retain their values between calls. #define MY_TASK_PERIOD_MS 15 void MyTask( void ) { static int my_task_state = 0; static tickms_t mytask_time; switch( my_task_state ) { case 0: /* Initialise timer */ mytask_time = StartTimer( MY_TASK_PERIOD_MS ); my_task_state = 1; break; case 1: /* new state dpends on function return */ my_task_state = ( MyFunc() )? 2 : 3; break; case 2: /* some stuff */ break; case 3: /* some other stuff */ break; case 4: if( TimerExpired( mytask_time ) ) { mytask_time = StartTimer( MY_TASK_PERIOD_MS ); my_task_state = 1; } break; /* etc...etc... */ } } When I last used Pascal (a long time ago admittedly), I could find no way of defining static variables within a function, so end up using globals which is very ugly. Has this situation changed? Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist