| Author |
Message |
pronatalist
Joined: 04 Sep 2007 Posts: 5
|
Posted: September 5, 2007 10:16 AM Post subject: Passing result parameters back from Program calls? |
|
|
Okay, I know how to pass a few parameters to functions and program calls. And I know that a function can return a single result, which can be tricked into being multiple results by making the returned value to be a set or matrix.
But how do I pass results from a called program, back to the calling program? This is important for trying to grow beyond the 30K program editor limit, and writing several programs to behave or appear to the user as if they were one integrated program.
So far, the only way I have found, is to store any such communications in a global text variable that the system of programs uses. A global variable is one that wasn't declared as Local, so that it stays after the programs have Quit.
And so far, I have only dabbled with run-on global text string variables, to store my month and week comments for my perpetual Calendar program. I used inString(,) to search out whether there are any comments for the current month being displayed, which didn't require me to sort the database. To manage this "database" all I needed was a simple Insert, Delete, and Find operations. "Replace" simply = Delete + Insert. My Find operation relies on an invisible YearMonth header automatically appended to the beginning of every entered user Comment. But is this really the best way to do a "database" or should I be using a global 1-dimensional set of text strings instead? I also need to put in miscellaneous data such as user preference choices.
BTW, when will they fix the Reply and Quote buttons on the forum? Last I checked, they weren't working, so forgive me if I don't Reply on the same thread.
Also see my question in the General Support folder about how my TI89 trashed all my program files. If that problem isn't soon resolved, I might never write another program again? Or if I do, will it be a 160*100 pixel Macintosh widget, just to spite my calculator for losing my files?
Other nagging questions: How do I rename or hide the buttons at the bottom of Dialogs? How can I gray-out menu items in Toolbar, Custom, and Dropdown? How important is it really, to have an Assembly shell to add in simple Assembly functions that my Basic program can call? Is there possibly an available TI Assembler that runs within the calculator? That would really be nice. I would like to run it in the calculator, to make small changes and test immediately.
When I started getting into Assembly on my old Apple //e computer, I soon discovered a favorite trick for POKing in small machine code programs. The code was simply put into a text string, in a loop that copied it into the keyboard buffer page of RAM. Then I think it may have been CALL -172, which tells the Monitor (ROM tool for machine code hacking) that the user just typed that line, and to interpret it. Since it is a subroutine call, program flow returns to the calling Applesoft Basic program, and not to the Monitor, after the hexadecimal digits are put into RAM. |
|
| Back to top |
|
 |
mellamokb
Joined: 10 May 2007 Posts: 100
|
Posted: September 13, 2007 7:02 PM Post subject: |
|
|
Hi pronatalist,
I'm glad to see you are interested in making progress with TI-89 programming. Programming in my opinion is very exciting, especially for devices that aren't targeted by mainstream companies.
AFAIK, you will always be limited to using global variables to "emulate" a return value from a program. However, you can consider two things if it bothers you to use global variables:
1) Use a folder dedicated to your program so there's no chance of a naming conflict with other programs, other users, or the system.
2) Make the major part of your program consist of things that cannot be done with functions (input, screen output, pausing, etc.), and then accomplish everything else (processing variables, getting calendar information, etc.) in functions. Rather than having other "programs" be your subroutines, try to make subroutine code only be code that can run in a "function", and have one main "program" that calls all these functions and so is decently short. As an added benefit, the more you breakup your functions, the more likely it is you will be able to reuse a powerful function in future applications.
And note that a "program" can still accomplish something useful without returning a value; the function was created to allow values to be returned, as programs are processed differently by the OS than functions (namely that a function cannot "hold up" the calculator OS and so can't have IO or dialogs).
For your variable storage, I would think an array would be the most efficient, because indexing an array is probably a faster operation than doing text searching on a slow calculator. Also, you have more flexibility in a 1-D array of strings instead of using multiple variables if the number of comments is to be variable as well. However, note that very large variables (like 500 part string array) may bog down the calculator when processing, so in that respect, it would be good to use multiple variables.
Reply & Quote must not work properly with your browser, because I've never had a problem. By "they", I'm sure you mean the people in charge of this forum. I have been in contact with the people in charge of this forum, and nobody has responded to my questions in a few months, so I don't think there is much interest by the owner. If I had more time and money, I would consider buying the site and making these changes...
(cont'd...) |
|
| Back to top |
|
 |
mellamokb
Joined: 10 May 2007 Posts: 100
|
Posted: September 13, 2007 7:15 PM Post subject: |
|
|
When you talk about fancy functionality not built into the OS or BASIC, you are on your own. Working in Assembly takes a lot of dedication, and like you say, adding to the OS functionality using Assembly is the only way you can extend BASIC. Note that there are two tools available (do a Google search, I don't remember where) that can do TIASM and tigc directly on the calculator. I have used them, and they are pretty good, but its so easy to crash your calculator that I would recommend using a PCbased ASM or tigc tool and using a virtual calculator. VirtualTI and others are pretty good, and Im sure some of them have a memorypeeking option to see exactly whats going on underneath so you know what to change to accomplish these things you're interested in. Also note that the tigc library of functions was put together basically by disassembling most of the TI89 OS, so you could consult the tigc manual or the authors of the tool for better information. The best help youre going to get from me is BASIC only, because Assembly is out of my league.
I hope Ive helped you in some way. Please dont hesitate to ask more questions, but I may not be able to help you.
~ mellamokb
(tigc = TI-GCC) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
Saphic 1.5 // Theme created by Sopel
|
|