The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
41-MCODE: Copying X-Mem Files
03-13-2014, 04:49 PM (This post was last modified: 03-13-2014 04:56 PM by Ángel Martin.)
Post: #1
41-MCODE: Copying X-Mem Files
A few weeks ago Geir started a thread about copying ASCII files, which is not possible using the standard function set in the CX. Some workarounds involved using the Mass storage functions SAVEAS/GETAS, as well as a FOCAL program from Raymond.

I tried that program but failed to make it work as supposed to, probably my bad. That made me start thinking of a MCODE implementation that would copy a source file into a destination one; and not only ASCII but of any type; like-to-like.

The code below shows the initial implementation - feel free to improve on it as you see fit ;-) Both files need to exist in X-Mem, but they don't have to be of the same size - which pretty much rules it out for program files, of course. Just make sure you know what you're doing...

Enjoy it!
'AM

PS. here's the original post: http://www.hpmuseum.org/forum/thread-260.html


Code:

AF4A    08C    "L"    
AF4B    006    "F"    
AF4C    00D    "M"    Copy X-Mem File
AF4D    019    "Y"    " Source,Destination"  in ALPHA
AF4E    010    "P"    Both Files must exist
AF4F    003    "C"    
AF50    03E    B=0 MS    wildcard type!
AF51    0A5    ?NC XQ    Does [GTFLNA] and [RFLSCH]
AF52    0E8    ->3A29    [FLSHAC]
AF53    046    C=0 S&X    
AF54    270    RAMSLCT    select chip0
AF55    0B0    C=N  ALL    Source File Header
AF56    268    WRIT 9(Q)    saved in rg.9(Q)
AF57    3E9    ?NC XQ    Get Text after comma (!)
AF58    0D0    ->34FA    [ALNAM2]
AF59    008    SETF 3    
AF5A    281    ?NC XQ    General File Search
AF5B    0F0    ->3CA0    [EFLSCH]
AF5C    38C    ?FSET 0    not found?
AF5D    0B5    ?NC GO    nope, say so!
AF5E    0F6    ->3D2D    [FLNOFN]
AF5F    046    C=0 S&X    
AF60    270    RAMSLCT    select chip0
AF61    0B0    C=N ALL    Dest File Header
AF62    128    WRIT 4(L)    save it in 4(L)
AF63    0AE    A<>C ALL    
AF64    278    READ 9(Q)    
AF65    37E    ?A#C MS    
AF66    089    ?C XQ    File Type Error
AF67    0F5    ->3D22    [FTPER]
AF68    244    CLRF 9    equal sizes
AF69    366    ?A#C S&X    different?
AF6A    033    JNC +06    no, skip adjustments
AF6B    248    SETF 9    remember this for later
AF6C    306    ?A<C S&X    is C smaller?
AF6D    013    JNC +02    yes, skip
AF6E    0A6    A<>C S&X    no, get the smaller size
AF6F    106    A=C S&X    into both counters
AF70    158    M=C ALL    Source Header
AF71    0AE    A<>C ALL    
AF72    070    N=C ALL    DestInation header
AF73    198    C=M ALL    source file counters
AF74    0FC    RCR 10    rotate file addr to C[S&X]
AF75    10E    A=C ALL    prepare it as input
AF76    00D    ?NC XQ    Get next register adr
AF77    0D0    ->3403    [NXREG]
AF78    0A6    A<>C S&X    reg to C[S&X]
AF79    270    RAMSLCT    select it
AF7A    0A6    A<>C S&X    rebuild A
AF7B    038    READATA    get reg value
AF7C    0EE    B<>C ALL    save in B
AF7D    0AE    A<>C ALL    
AF7E    07C    RCR 4    
AF7F    158    M=C ALL    Update source counter
AF80    0B0    C=N ALL    Dest file register
AF81    0FC    RCR 10    rotate file addr to C[S&X]
AF82    10E    A=C ALL    prepare it as input
AF83    00D    ?NC XQ    Get next register adr
AF84    0D0    ->3403    [NXREG]
AF85    0A6    A<>C S&X    reg to C[S&X]
AF86    270    RAMSLCT    select it
AF87    0A6    A<>C S&X    rebuild A
AF88    0EE    B<>C ALL    reg value!
AF89    2F0    WRITDATA    copy to destination
AF8A    0AE    A<>C ALL    
AF8B    07C    RCR 4    
AF8C    266    C=C-1 S&X    decrease size count
AF8D    070    N=C ALL    update destination counter
AF8E    266    C=C-1 S&X    last one?
AF8F    323    JNC -28d    no, do next
AF90    24C    ?FSET 9    yes, non-equal sized?
AF91    1F9    ?C GO    yes, Show 'END of FILE" 
AF92    0FB    ->3E7E    [SAVRER]
AF93    3E0    RTN

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
41-MCODE: Copying X-Mem Files - Ángel Martin - 03-13-2014 04:49 PM



User(s) browsing this thread: 1 Guest(s)