Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Improving PBASIC: Request for Comments (http://www.chiefdelphi.com/forums/showthread.php?t=1021)

Joe Johnson 01-02-2002 10:24

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.

Greg Ross 01-02-2002 11:36

Label Example
 
Quote:

Originally posted by GreenDice
Greg,

Could you give some examples on how to use labels?

Thanks.

Sure. Sorry for the oversight.

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}


Greg Ross 01-02-2002 11:50

Re: How about a slot directive?
 
Quote:

Originally posted by Joe Johnson
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}

I think I like it. Let me stew on it a bit.



Quote:

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.

If I'm understanding what you need, then you can already do this with multiple include files. You're not restricted to a single $Include directive per file. Simply $Include the global data file in all your project files, and $Include the special code files only where you need them.


Quote:

I know I am asking a lot, but you asked for feedback.

Joe J.

Yes, I did, and I appreciate it all.:)

Greg Ross 12-02-2002 14:53

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}


GhettoTech 16-02-2002 22:14

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]


All times are GMT -5. The time now is 11:08.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi