Recalling X-MEM files information - RAMPAGE
|
06-24-2021, 05:50 PM
(This post was last modified: 06-24-2021 07:06 PM by Artur - Brasil.)
Post: #1
|
|||
|
|||
Recalling X-MEM files information - RAMPAGE
Well, me again with my ideas....
I wrote some routines for saving data in X-Memory files, as numbered registers or as named variables. Also, I wrote on program for presenting a menu of equations and solving for any choosen variable of such equations. Now, I would like to put both programs to work togheter, but I stopped with the following problem: - changing from one x-file (data file), used in one program, to another in a subroutine, and back again. I was planning to write a programm to save the actual X-file - name (thanks RAMPAGE) and its record pointer - make the new one as current file and returning to caller program: Main program will it use X-DATA? if so, CREATE xfile1 ... XEQ SUBPROGRAM1 (I don't care and don't know if this sub will use x-file too) continues... CLOSE (clean the stack of xfile control) END Subprogram1 will it use its own -XDATA? if so, XEQ CREATE xfile2 uses xfile2 ... ... CLOSE (here, the current xfile will be xfil1 again) END sub CREATE file save current file[name/pointer] CRFLD xfile1 END sub CLOSE step back SAVED FILES get saved pointer (maybe -1) SEEKPT END I'm using the WORKFL function on RAMPAGE to get the current xfile name; FLHD for getting the address of its header; And studying the PEEKR function to get the pointer information. Please, could someone help if am I walking in correct diretion? How to use PEEKR in this situation, as the x-file header has more information than pointer number? BYTE: 13 12 11 10 09 08 07 06 05 04 03 02 01 00 CONT: T A D R - - - - R E G S Z E Best wishes Artur - Brasil ARTUR MARIO JUNIOR BRAZIL |
|||
06-25-2021, 03:15 PM
Post: #2
|
|||
|
|||
RE: Recalling X-MEM files information - RAMPAGE
If I understand your description, why not saving the current pointer using RCLPTA, so you can restore it later with SEEKPTA?
There's a brief description of the file headers in the ToolBox/RamPage manual, look at the appendix section. ÁM "To live or die by your own sword one must first learn to wield it aptly." |
|||
06-28-2021, 12:00 AM
Post: #3
|
|||
|
|||
RE: Recalling X-MEM files information - RAMPAGE
(06-25-2021 03:15 PM)Ángel Martin Wrote: If I understand your description, why not saving the current pointer using RCLPTA, so you can restore it later with SEEKPTA? Yes, Angel. I discovered this too re-reading the X files use in HP-41CX manual. Actually, there's no need to save the pointer of each x-file opened, as each one has his own header which is preserved even if the file is not the current. So, just save the name of actual before selecting the desired one in a structure of a stack: last in, last out - include always on first record. Just was wondering about recursiviness or the rotine A call B that calls A again, but this is very crazy. In the case of recursive programs, there would be necessity of saving the pointer, but what would be the effectiviness if variables have been changed? I'll not allow duplicated files name in stack, so, no recursiveness. Best regards! Artur ARTUR MARIO JUNIOR BRAZIL |
|||
06-29-2021, 10:28 PM
Post: #4
|
|||
|
|||
RE: Recalling X-MEM files information - RAMPAGE
Done! At least the initial work...
The first program saves the name of current X-File in use to another data X-File (already created with only one register), the XFLSTK (x-Filo stack): I assume you have the RAMPAGE module installed (my in NovRam - thanks, Diego!) 1 LBL "BKXFL" 2 CLA 3 WORKFL here the important function from RAMPAGE that gets the current X-file's name 4 ALENGH 5 X=0? if no X-file in use, nothing to do. 6 RTN 7 ASTO L 8 "XFLSTK" 9 FLSIZE 10 ISG X 11 + 12 RESZFL 13 DSE X 14 SEEKPTA 15 X<> L 16 SAVEX 17 CLA 18 CLX 19 END The second program restores the last saved file as current one: 1 LBL "RCXFL" 2 "XFLSTK" 3 FLSIZE 4 DSE X 5 SEEKPTA 6 X=0? 7 1/X 8 GETX 9 RDN 10 CHS 11 RESZFL 12 CLA 13 ARCL T 14 RCLPTA 15 SEEKPTA 16 END How to use: 1 - Create the control X-file: ALPHA XFLSTK ALPHA 1 XEQ CRFLD (this is a one time execution); 2 - will you write a programm that uses X-files? If so, the first instruction after the label's name of program is to save current X-file in use. Don't worry, if there is no X-file in use, the routine will not do anything: XEQ "BKXFL" 3 - write your programm, create your X-file - if more than one in your program, call BKXFL before create/access each X-file; 4 - each subroutine (other program or not) that creates/uses its own x-file, call BKXFL before trying to access its own X-file; 5 - at the end of each program/subroutine, call RCXFL (recall x-file) before doing RTN to the caller program. If you call RCXFL more than there is saved file names, an erro occurs. I believe these are simple but important routines for those who make intensive use of X-files. I'll rewrite my own programs of menus and others that are a simplified version of units conversion to use registers in X-Memory instead of main memory. Any improvement someone sees is very wellcome! Best regards Artur ARTUR MARIO JUNIOR BRAZIL |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)