Sharing Code Between Programs
|
01-16-2022, 08:44 PM
(This post was last modified: 01-16-2022 08:53 PM by IHarwell.)
Post: #1
|
|||
|
|||
Sharing Code Between Programs
I can't be the only person annoyed that the documentation for the Prime describes "calling programs from other programs" basically amounts to "there's a call stack, but you can't call functions from other files."
With that said, I found a rather straightforward way to call code contained in other files. I haven't tested the feature too extensively, but here's what I've found so far: Let's say you want to make a function library for your programs to share. In my case, I wanted to have a way to draw the "shift" symbol in the correct place for any of my programs. This is the "library" file I created. Code: #cas This file creates the functions and makes them available through the CAS system. To call them, there are two options that currently occur to me. The first is more direct, and looks like: Code: CAS("DrawShiftMark()"); The second basically uses a verbose import statement by wrapping the CAS command in a function. Code: LOCAL DrawShiftMark() While it's a workable solution as-is, this approach is vulnerable to name collisions. I'll look into using the "folders" system that I ran across and posted about in an earlier thread to see if I can get something like namespaces working. Until then, I thought it was a pretty neat technique that enables more compact programs than could be done otherwise. If anyone has related ideas or has any ways to extend this, I'd be very interested to take a look. P.S. The current holdup for implementing namespaces is due to the EVAL function doing weird things with the "END" keyword. There may be a workaround, but I'll have to test it out a bit. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Sharing Code Between Programs - IHarwell - 01-16-2022 08:44 PM
RE: Sharing Code Between Programs - Didier Lachieze - 01-16-2022, 10:15 PM
RE: Sharing Code Between Programs - IHarwell - 01-16-2022, 10:44 PM
RE: Sharing Code Between Programs - BruceH - 01-19-2022, 12:29 AM
|
User(s) browsing this thread: 1 Guest(s)