Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Passing parameters to a task

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
pjc30943



Joined: 02 Dec 2005
Posts: 220

Posted: 28 September 2006, 5:08 AM    Post subject: Passing parameters to a task Reply with quote

Why are task parameters prohibited by the compiler? It's nice to use the same task for several events, with its variations caused by parameters. A global would work of course, but...
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 28 September 2006, 5:22 AM    Post subject: Reply with quote

ZBasic was originally designed to be compatible with BasicX and in the latter, task main routines must be defined with no parameters.

We are currently testing a new version of the compiler that allows an arbitrary number of parameters. The VM also had to be updated to support this.
Back to top
mikep



Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX

Posted: 28 September 2006, 5:53 AM    Post subject: Reply with quote

dkinzer wrote:
We are currently testing a new version of the compiler that allows an arbitrary number of parameters. The VM also had to be updated to support this.

That is good.

I haven't tried this myself but it would good to be able to also pass in dynamically allocated memory for the task stack. Then I can create as many tasks as I like without going through the overhead of allocating static arrays at compile time.
Back to top
stevech



Joined: 23 Feb 2006
Posts: 657

Posted: 28 September 2006, 6:09 AM    Post subject: Reply with quote

I suspect that dynamically allocated task stacks will also be forthcoming.

I have a ZBasic program that does quasi-dynamic task stack allocation until ZBasic has this as intrinsic. The scheme I use is for a state machine, where each state is a particular ZBasic task/sub(). I could elaborate if there's interest.

I also have a working example of a task to handle the AVR's INT0 and INT1 with the same code. I just callTask() twice to the same code with different stacks. Parameter for each instance of the task is passed in a gobal for now. The task instances copy it to a local variable, freeing up the global.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group