|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||||
|
||||||
|
How about a slot directive?
It might be nice to have a slot directive that allows you to start the code for a different programming slot in the same file.
Typical directives: To start a new slot (slot number assigned by the preprossor -- we refernence them by name): {$SlotStart slotname} To end a slot (perhaps not required, either the file ends or a new slot begins: {$SlotEnd} To run another slot (preprocessor resolves the slotname to the required number) {Run slotname} Along with this I would say it would be nice to have "global" include directives and "local" include directives. This would let us have some code (say the declarations of variables, constants, etc.) included in all programming slots and then but then we could include special code in specific programming slots. I know I am asking a lot, but you asked for feedback. Joe J. |
|
#2
|
|||||
|
|||||
|
Label Example
Quote:
Code:
AppleTest: {$if X = Apple}
debug "X is an apple", cr
OrangeTest: {$elseif X = Orange}
debug "X is an orange", cr
MangoTest: {$elseif X = Mango}
debug "X is an mango", cr
NoneOfTheAbove: {$else}
debug "X must be a banana", cr
EndFruitTest: {$endif}
Last edited by Greg Ross : 01-02-2002 at 14:30. |
|
#3
|
|||||
|
|||||
|
Re: How about a slot directive?
Quote:
Quote:
Quote:
![]() Last edited by Greg Ross : 01-02-2002 at 14:32. |
|
#4
|
|||||
|
|||||
|
How about another preprocessor directive?
I'm thinking about adding another directive similar to the $Slot directive suggested by Dr. Joe.
$Slot demarks a section of a preprocessor source file to be output as a separate BASIC Stamp program which is loaded into one of the suplemental program slots. The new directive would identify a portion of a file which can be $Included in any of your $Slot output files. I'm proposing $IncludeSource for the directive name. The syntax would be {$IncludeSource symbolic_name}. The source file lines between the $IncludeSource and a subsequent $EndIncludeSource directive can then be $Included using symbolic_name. Example: Code:
{$Stamp bs2sx}
{$IncludeSource dataIncludes}
' Your data definitions go here
.
.
.
{$EndIncludeSource}
{$Include dataIncludes} ' Insert the data definitions from above
'Your program initialization goes here
.
.
.
'Now run the main control loop
{$Run MainLoop}
{$Slot MainLoop}
{$Include dataIncludes} ' Insert the data definitions from above
' Read inputs and process them
.
.
.
'When you run out of program space, split your program, and
'continue in the next program slot.
{$Run NextSlot}
{$Slot NextSlot}
{$Include dataIncludes} ' Insert the data definitions from above
'Do some more processing...
'Finally, output your data via the serout command, and go back to
'the beginning of the control loop.
serout ...
{$Run MainLoop}
|
|
#5
|
|||
|
|||
|
From my understanding of the original posted question, you want to avoid typing multiple "IF" statements.
http://parallaxinc.com/downloads/Doc...ual%20v2.0.pdf That's a link to the manual for the Basic Stamp, look up the "Branch" code. (Pages 85 & 86) ~Excerpt from Basic Stamp Manual~ [b]Explanation:[\B] The BRANCH instruction is useful when you want to write something like this: IF value = 0 THEN case_0 ' value =0: go to label "case_0" IF value = 1 THEN case_1 ' value =1: go to label "case_1" IF value = 2 THEN case_2 ' value =2: go to label "case_2" You can use BRANCH to organize this into a single statement: BRANCH value, [case_0, case_1, case_2] |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PBASIC ARCTAN function | Greg Ross | Programming | 14 | 11-05-2003 12:28 |
| Obscure PBASIC for RoboEmu | rbayer | Programming | 1 | 28-03-2003 23:57 |
| PBasic 2.5 vs. 2.0 | Anthony Kesich | Programming | 6 | 09-02-2003 22:06 |
| emulationFIRST (aka PBasic emulator) | Matt Leese | Programming | 5 | 30-06-2002 12:06 |
| PBASIC Loop Speed? | archiver | 2001 | 3 | 23-06-2002 23:46 |