Subject:
|
Re: mindscript - subroutines
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Fri, 23 Dec 2005 15:47:02 GMT
|
Viewed:
|
1580 times
|
| |
| |
In lugnet.robotics, Ron Karabowicz wrote:
> Hi,
> I'm new to this mindscript stuff and lugnet, so hopefully someone can shed some
> insight for me.
>
> I was lead to believe that Mindscript had the capability of defining
> subroutines. In either Bricx or Scripted I keep coming up with an error when I
> use the word "sub".
>
> Here is some simple code that doesn't give me an error:
>
> program mytest {
> macro mysound {
> sound 3
> }
> main {
> repeat 5 {mysound}
> }
> }
>
> Here is code that gives me an error:
>
> program mytest {
> sub mysound {
> sound 3
> }
> main {
> repeat 5 {mysound}
> }
> }
>
> I need to use mindscript and define it as a subroutine. The indication is
> "error" and no further information in either scripted or bricx.
>
> I have downloaded the mindscript sdk 2.5 and have installed it.
> Scripted comes up with coyright lego 2000-2002, is 152k in size and is dated
> 9/27/02.
> Bricx comes up as 3.3.7.10. How does bricx know to use the mindscript compiler?
>
>
> Since I am using an RCX, is there any way of creating and saving the LASM code
> from either one of these interfaces?
>
> Thanks for the help.
>
> Ron
Ron,
I am fairly new to the mindscript language as well, but I have done substantial
research into this problem as I was encountering the exact same problem. From
what I have found, you cannot do user subroutines in mindscript FOR THE RCX.
User soubroutines are allowed for the Spybot but not the RCX. Open up the help
from Scripted and check out the script help for "sub". What I have done to get
around this is to create tasks, and events to tell me when the task is done.
Here is an example:
program {
var SoundDone = 0 // variable to use to check if task is done
event SoundTaskDone when SoundDone = 1 // event to watch for end of task
main {
// Do stuff here
start MySound // start task
wait until SoundTaskDone
stop MySound // not really needed in this case
}
task MySound{
// Do some more stuff
SoundDone = 1 // when done set event variable to 1
}
}
It isn't the best solution, but it does work. Hope this helps.
John
|
|
Message is in Reply To:
| | mindscript - subroutines
|
| Hi, I'm new to this mindscript stuff and lugnet, so hopefully someone can shed some insight for me. I was lead to believe that Mindscript had the capability of defining subroutines. In either Bricx or Scripted I keep coming up with an error when I (...) (19 years ago, 22-Dec-05, to lugnet.robotics)
|
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|