Post Reply 
How do I create a Subroutine using System RPL?
09-30-2022, 02:24 PM
Post: #10
RE: How do I create a Subroutine using System RPL?
Hi David, thank you very much for spending the time teaching me this stuff. You already provides way more informaiton than I expected! Greatly appreciated!

A few more notes and questions on your comments.

(09-29-2022 04:38 PM)DavidM Wrote:  The code word CK2&Dispatch should only be used in a library command, and it should be the first item in the code (after the initial ::, of course). This example is, by definition, a stand-alone program instead of a library command. So instead of CK2&Dispatch, you would use two separate code words:

CK2NOLASTWD
CK&DISPATCH1

This is very interesting. I did note the error XLib 695 49 Error: Too Few Arguments and the XLib keword caught my attention. After your note I did a quick search on the Programming in System RPL Second Edition and its all there.

(09-29-2022 04:38 PM)DavidM Wrote:  Generally speaking, you start a program with the argument check/dispatch tools, then you proceed with setting up locals and validating argument applicability. I usually validate the arguments before setting up locals, unless the locals being defined would make it simpler to validate things. Forcing an early exit by raising an error will normally take care of an active temp environment, but it has to be marked appropriately for that to work. That marking is done with the CK<n>NOLASTWD command, which is but one reason that needs to be first in the code.

That is a great coding practice, thanks for calling that out, it makes total sense to me.

In addition, the same section of the document also describes this behavior and the "marking" that you refer to.

My understanding is that right after the CK&DISPATCH1 we add the types we want to check. If its real real it should be #00011 so this mean we can only test up to 5 arguments for their type?

What if we had a CKNNOLASTWD with N=10? Would I create a loop to check each parameter individually?

I tried using the directory macro as you suggested. Does that only work if in one single file? I tried creating 2 files and assignign a section like below, but it did not work.

File 1: Named.s
Code:
INCLUDE DirMacro.s

ASSEMBLE
    Dir <NAMEd>
    
RPL
File 2: Unnamed.s
Code:
INCLUDE DirMacro.s

ASSEMBLE
    Dir <UNNMD>
    
RPL

After moving both Assembles into one file it worked.

Thank you!
Walter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How do I create a Subroutine using System RPL? - wmundstock - 09-30-2022 02:24 PM



User(s) browsing this thread: 1 Guest(s)