obsolete: Update: forget it, it doesn’t work. Culprit is HGETP, which copies the program file to main memory and executes it - which doesn’t make sense at all.
The HEPAX manual warns you for it: when you make changes to a program file and save it again (with HSAVEP), it will be moved to the end of the file chain (or to the first available free space if you have more than 1 page? I don't know), and your XROM numbers may be messed up.
If the number and order of programs in your files don't change, the following routine will 'replace' a program in the HEPAX file chain, by saving the program you want and all programs between its old and new position, so that they are again in the same order and XROM numbering is kept.
Caveats:
- it works only if all your files bear program names, not file names,
- only for program names not exceeding 6 characters, and not ending in a blank.
- only with Angel's HEPAX Plus that has PCOPY
- can not be used as a subroutine
There will probably be file chain scenarios for which this doesn't work, but for the time being, it serves my purpose
In: A: program name to save
Code: Select all
01>LBL "HUPDP"
-- 102 Bytes including END
-- 1. find out the file's HEPDIR index number n. ie it is the nth file in the chain.
-- result of HEPDIRX is padded with trailing blanks, though..
-- L X Y Z T A
02 CLX
03 ABS
04 ASTO T
05 +" "
06 ASTO X
07>LBL 02 n "P " - - "P"
08 R^
09 LASTX
10 1
11 +
12 HEPDIRX n TYPE "P" "P "
13 0
14 X=Y?
15 GTO 00
16 ASTO X
17 R^ n "P " "Fn" TYPE "P"
18 X#Y?
19 GTO 02
20 RDN
21 CLX
22 LASTX n "PR" "P" "P "
23 LBL 00 n 0 0 "P" "P "
24 CLA
25 ARCL Z
--
-- 2. Save the file, putting it LAST in the chain, or at least, further up
--
26 HSAVEP
27 X=0?
28 RTN
-- 3. do
-- HEPDIRX n
-- is it a PR?
-- then
-- is that our replaced file? then exit;
-- HGETP, HSAVEP and PCLPS
-- end;
-- else n := n+1;
-- loop;
--
-- L X Y Z T A
-- n "PR" - "P "
29 LBL 03
30 HEPDIRX n TYPE "PR" - "P " "Fn "
31 X#Y?
32 GTO 00
33 ASTO X
34 R^ n "P " "Fn " "PR"
35 X=Y?
36 RTN
37 RCL Z
38 32
39 ENTER
-- remove trailing blanks
-- n - 32 "PR" "P " "Fn "
40 LBL 04
41 CLX
42 -1
43 AROT
44 CLX
45 ATOX
46 X=Y?
47 GTO 04
48 XTOA
49 X<> T
50 PCOPY destroys T
51 HSAVEP
52 PCLPS
53 RDN
54 GTO 01
55>LBL 00
56 ISG L
57 LBL 01 n - "PR" - "P "
58 CLX
59 LASTX
60 GTO 03
61 END
Werner