RPL beginner
|
10-30-2021, 07:23 PM
Post: #1
|
|||
|
|||
RPL beginner
I am studying RPL, but it turned out that the program does not work after checking the conditions
tell me where is the error Code:
|
|||
11-01-2021, 02:11 PM
Post: #2
|
|||
|
|||
RE: RPL beginner
I don't know why the program doesn't work, but you could replace this:
Code: %0 %0 %0 %0 %0 %0 %0 %0 Code: ZERO ZERO 120 FIFTYTHREE ONE ONE %0 %0 |
|||
11-01-2021, 04:40 PM
Post: #3
|
|||
|
|||
RE: RPL beginner
thanks, this way works. It remains to figure out the condition
Code:
|
|||
11-02-2021, 10:51 AM
Post: #4
|
|||
|
|||
RE: RPL beginner
Welcome to the world of System RPL programming! There are usually meaningful rewards to be had over standard (User) RPL programs, but the "price to pay" for these rewards is in understanding the more type-specific nature of the commands and the structures provided.
Looking at your program, several things stood out that may need consideration. I'll mention a few here that may help you. 1) Start all System RPL programs with one of the "check" commands. It sets the stage for how the error-handling system in the calculator should attempt to repair the initial stack objects if/when an error occurs in your code. Not all System RPL errors are recoverable, but this is the minimum you should do and it's a good habit to always include this in every System RPL program. In your case, there are no arguments needed by the program. So you should start with CK0NOLASTWD. 2) The GROB you create at the beginning of the program is blank, and you are then displaying it in the blank text display (which was cleared with RECLAIMDISP). This doesn't create a problem, but it serves no particular purpose. I've left that code out of my example since it doesn't contribute to the outcome here. I've also not included the LAMs that aren't used in this example in an effort to reduce distractions. 3) As was pointed out by David Hayden, you may as well just initialize the LAMs you create with their default values. That saves you the trouble of having to assign the initial values later as a separate step. 4) You've set up your indefinite loop to use a keypress as an exit condition. This is a good way to experiment with something like this, and I would suggest extending it one step further: also check for the user pressing the ON (CANCEL) key. This is a natural and intuitive exit case, and requires very little extra code to support it. Also, you don't really need to do anything with the keys which are pressed, so you should probably just ignore them instead of bringing the values to the stack. My example shows one way to do this. 5) Finally, the "check condition" that you are asking about. I've shown one way of doing this in my example, but there's more to it than is obvious in the code. While I believe the code I've provided does what you are suggesting, BINTs are actually not signed values. The reason this works is more a consequence of what happens naturally if you add two unsigned values where the carry would extend through all of the initial (high-order) bits. MINUSONE is defined (in hex notation) as FFFFF. But as a BINT, that actually has a value of (decimal) 1048575 instead of -1. Try the following program to see what I mean: Code: :: I hope this will give you a good start for further experimentation. Code: :: |
|||
11-02-2021, 02:18 PM
Post: #5
|
|||
|
|||
RE: RPL beginner
Thanks for the help. The most difficult thing for me was the correctness of the commands. Now one more condition does not work
Code:
is it possible to combine validation with OR? |
|||
11-02-2021, 05:20 PM
Post: #6
|
|||
|
|||
RE: RPL beginner
right now, but the manual says that when drawing a line, you need to call ORDERXY#, then the line draws incorrectly
Code:
|
|||
11-04-2021, 01:07 AM
Post: #7
|
|||
|
|||
RE: RPL beginner
(11-02-2021 05:20 PM)dwesti Wrote: right now, but the manual says that when drawing a line, you need to call ORDERXY#, then the line draws incorrectly ORDERXY# does more than simply swapping the X/Y pairs if X1>X2. It also swaps Y1 and Y2 in certain situations, which you definitely don't want for this. Here's how it is defined: Code: :: Everything up to (and including) the 2SWAP command is what you need in this situation; the rest of it should not be performed. There's no way to remove the excess from the built-in command, so I'd recommend just including that initial code where needed or possibly creating a subroutine with those commands to call. There's also the possibility of using the DRAWLINE#3/TOGGLELINE#3 pair of commands instead of LINEON/LINEOFF. The former pair has a built-in check for X values to make sure it can draw the line appropriately, whereas the latter does not. That would obviously require you to change the code around so that it uses the graphics display (PICT) instead of the text display, but that's not too difficult. SysRPL programs should save the existing PICT data before making any changes, though, since that data is considered to be "owned" by the user and is expected to be left intact by most programs. |
|||
11-04-2021, 09:21 AM
Post: #8
|
|||
|
|||
RE: RPL beginner
Now no lines are drawn. added to entries.a
|
|||
11-04-2021, 09:49 AM
Post: #9
|
|||
|
|||
RE: RPL beginner | |||
11-04-2021, 04:04 PM
(This post was last modified: 11-04-2021 04:06 PM by dwesti.)
Post: #10
|
|||
|
|||
RE: RPL beginner
I used rplcomp and sasm
Code:
file attached |
|||
11-05-2021, 10:12 AM
Post: #11
|
|||
|
|||
RE: RPL beginner
There are two main "displays" for RPL calculators: the main stack display (alpha/text) and the graph display (graph/PICT). Built-in drawing commands that aren't designed for use with stack-based GROBs are usually specific to either the alpha display (ADISP) or the graph display (GDISP).
Your original code used LINEON and LINEOFF, which draw/clear lines only on the alpha display. DRAWLINE#3 and TOGGLELINE#3 draw/toggle lines only on the graph display. The calculator has to be manually switched to the graph display in order to see the results of DRAWLINE#3 and TOGGLELINE#3. As you might expect, there are different commands for clearing/saving/restoring the two displays. I've taken the program from your zip file and edited it slightly to accommodate using the graph instead of the alpha display. I also added a short pause between the line-drawing and toggling steps to make the animation cleaner on an emulated calculator. If that step (% 0.02 dowait) slows things down too much, just remove it. No other changes were made from your posted code: Code: :: Hope this helps! |
|||
11-06-2021, 06:41 PM
Post: #12
|
|||
|
|||
RE: RPL beginner
thanks for the help. But the program that I wrote in Apple 2 works differently.
|
|||
11-07-2021, 01:38 PM
Post: #13
|
|||
|
|||
RE: RPL beginner
OK, it's now more obvious where you are headed with this animation. Very well done!
Using TOGGLELINE#3 worked with the previous versions of your code, given that there was only one line being drawn at the time. In the previous scenario, TOGGLELINE#3 would just clear the line that was just drawn. I would suggest that TOGGLELINE#3 is no longer appropriate with this most recent update, though, as it leaves stray pixels active in locations where previously-drawn lines overlap with previously-cleared lines. The original use of LINEON/LINEOFF now appears to be the better approach. That being the case, you could keep the drawing on the alpha display instead of switching to the graph display. This would negate the need to save the user PICT area and switch to that display, as well as correctly turning off all of the appropriate pixels for each previous line. Using LINEON/LINEOFF requires the occasional reordering of input pairs, though, so that requirement needs to be accommodated in the code. This seems like a good time to introduce the use of a subroutine. Calling subroutines in the context of an RPL library is very straightforward, but that's out-of-scope for this situation. Here, I would suggest doing it in a very similar manner to what you might do with a UserRPL implementation: save the subroutine as a local variable, then recall/EVAL it as needed for execution. I've taken your most recent code and modified it as follows:
I believe this provides a more faithful rendering of the animation that you originally intended. Code: :: |
|||
11-08-2021, 05:40 PM
Post: #14
|
|||
|
|||
RE: RPL beginner
Looks good. Probably the size of the program can be reduced by using arrays
|
|||
11-11-2021, 02:33 AM
Post: #15
|
|||
|
|||
RE: RPL beginner
(11-08-2021 05:40 PM)dwesti Wrote: Probably the size of the program can be reduced by using arrays Suggestion: Instead of an array, consider using NULL-named LAMs. They are fast to access, can be of any type, and are flexible to use with built-in commands. They are much like an array but are in some ways more convenient. The following sample implementation introduces the following SysRPL concepts:
Code: DEFINE X1 1GETLAM |
|||
11-13-2021, 08:04 PM
Post: #16
|
|||
|
|||
RE: RPL beginner
Impressive work DavidM, I was following along all different versions. You explain well and know SysRPL very well. Do you have any programs published at hpcalc.org? Are you actively programming SysRPL?
2xHP48GX, HP 50g, two Retrotronik ram cards, DM42 /Daniel Lidström |
|||
11-14-2021, 02:06 AM
Post: #17
|
|||
|
|||
RE: RPL beginner
(11-13-2021 08:04 PM)dlidstrom Wrote: Impressive work DavidM, I was following along all different versions. You explain well and know SysRPL very well. Do you have any programs published at hpcalc.org? Are you actively programming SysRPL?This is his profile at hpcalc.org. https://www.hpcalc.org/authors/2279 S.Korean / HP-50G | fx-570EX | fx-570CW | HP-200LX |
|||
11-14-2021, 12:49 PM
Post: #18
|
|||
|
|||
RE: RPL beginner
(11-13-2021 08:04 PM)dlidstrom Wrote: Do you have any programs published at hpcalc.org? Are you actively programming SysRPL? Thanks for following along, dlidstrom. This app provided a nice platform for showing some specific SysRPL concepts. In addition to the performance and functional advantages, I actually find SysRPL to be easier to code than UserRPL sometimes. It has its quirks, to be sure, but that's just part of the fun of it. Most of the coding I do for a calculator is written in SysRPL and targeted for a 50g these days. I've got a couple of contributed projects at hpcalc.org (MultiStopwatch and the ListExt library), and a few other contributions that Eric was kind enough to include that came from postings here and at comp.sys.hp48. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)