Translations: Memotext to ZX Pro/File

Authors

Publication

Pub Details

Date

Pages

See all articles from SyncWare News v2 n1

If you have a Memotext word-processor module and 64K RAM, you undoubtedly have already made use of its powerful “text” files mode. Memotext also supports “data” files, organized in six fields per file, up to 31 characters per field. Entering data files is just as easy and fast as text, thanks to the re-defined keyboard, visually logical upper/lower case screen, and cursor editing. Unfortunately, manipulation of data files is very limited; M/text is simply not meant as a data-base program. Wouldn’t it be nice if you could enter your data files using Memotext, and then transfer them into your favorite filing program for sorting, searching, etc.?

I ran into the need for this when sending our subscriber list (on Memotext data files) to Tom Woods, who did not have a Memotext. So what more logical a program to try this out on than his ZX Pro/File? Fortunately, this is quite possible, and not as difficult as it might seem at first. The biggest problem is loading M/text files into your computer without M/text on-line. It may be possible to patch the Memotext load routine into RAM to do this directly, but meanwhile it’s “the universal solvent”, HotZ, to the rescue. We can use HotZ to load the Memotext data file into high memory. On quitting HotZ, load ZX Pro/File, and then translate and transfer the files into its data string (D$.)

Before we get on to the actual mechanics, let’s look at how the two programs differ in their file structure. Memotext uses CHR$ 255 (FFh) to mark the beginning and end of the files, and CHR$ 254 (FE) as end- of- field markers. There are no end- of-file markers after each file, since each file is fixed at six fields; every sixth FE marker is interpreted as the start of a new file. Empty fields result in the FE marker (only), much in the style of the ZX display file when “collapsed” and containing empty screen lines. ZX Pro/File, on the other hand, is capable of handling any number of fields per file, so an “end-of-file” marker is necessary (CHR$ 23) for each file. As a result, there is no need for end-of-field markers for empty fields. Also, ZX Pro/File uses CHR$ 140 for end-of-field instead of CHR$ 254. So to translate to ZX Pro/ File, we have to:

  1. Change end-of-field markers from CHR$ 254 to CHR$ 140
  2. Change every sixth end-of-field CHR$ 140 to an end-of-file CHR$ 23.
  3. Change the marker at the end of the entire set of files from CHR$ 255 to CHR$ 134.
  4. Since Memotext reverses the cases (normal = capitals, inverse = lower case) compared to the printer interface, our translation routine also has to change inverse to normal and vice versa.
  5. Any apostrophes (inverse comma or CHR$ 154) have to be changed to inverse colon (CHR$ 142) due to a quirk in the CIF/Memotext system. (Otherwise, when printed, the apostrophes are reversed.)

If your existing M/text files contain inverse pound signs (prints as “%”) or asterisks (*) then you’ll have to additionally change them to something else, or they will be falsely interpreted by ZX Pro/File as end markers. For the sake of simplicity, and since it is rare that these would be used for typical filing jobs like mailing lists, etc. this feature is not included in the program presented here.

So with no further ado, here’s how you go about getting data files into ZX Pro/ File via Memotext.

  1. Power up your 64K computer, then POKE 16389, 107 then NEW. This sets RAMTOP lower and insures that your file length will not exceed the 11000 character maximum dictated by the 16K ZX Pro/File. Type in your data files, then save to tape using “SDF.” Rewind the tape.
  2. Turn off Memotext, and reset the computer with your reset switch if you have one, or by powering down and up again. This time, leave RAMTOP at its default value of 16K (do not POKE 16388 or 16389 first). Turn on your 8-16 K region, this will be where the translation and transfer routines will be stored.
  3. Load the 16K version of Hot Z or Hot Z II (I used HZ II) and use it to enter the machine code translation routines as listed. I wrote it to take the area from 2000h (8192) to 2086. You may wish to locate it elsewhere in the 2000-3FFF region. You will have to change the CALLs and variables references. When entered, use HotZ to save this code to tape for future use. (If you’re entering the program as listed, put END at 2087, cursor at 2000, and SAVE.)
  4. Use Function 0 to clear the area from 8000-BFFFh. Now put your M/text tape back into the recorder, set cursor to 8020h and END to 8021, then LOAD. When the first brief load pattern (Memotext header) has loaded, the screen will reappear; stop the tape in time so it is still positioned before the main body of the data. Locations 8020 and 8021 now contain the length of the data file, in low-high order. Set END to 8020 + this value; e.g. if 8020 contains 3B and 8021 contains 29, set END to (8020+293B) = A95B. With cursor at 8020, give the LOAD command and restart the tape.
  5. When the tape has loaded, the screen will reappear and you can look through the data file. The first byte (at 8020) identifies the type of file (data or text) and should contain a 29h (“D”). The next two contain length- of- files minus 2. The next 60 bytes are for the field labels. After that is an FFh to mark the start of file. Take a look at the location just before END to verify that it contains the required FFh to mark end of files.
  6. You may now quit HotZ. If you have 64K memory, you can then RAND USR 8192 to store HotZ (or any 16 K program, for that matter) in the 48-64K area (C000FFFFh) complete with system variables, display file, etc. Later, you can instantly recall HotZ or other software using RAND USR 8204 (with HotZ, first POKE 16388,128 and POKE 16389,127 then NEW before calling USR 8204, since it sets RAMTOP 128 bytes lower to protect its variables. Also call USR 8204 from the same mode, FAST or SLOW, as you used when you called USR 8192).
  7. LOAD the 16K version of ZX Pro/File. When loaded, STOP operation, and enter LET P=USR 8233. This routine will translate the files in less than a second in FAST mode, and will return the correct length-of-file into BASIC variable P (ZX Pro/File’s length variable = actual file length plus 21.)
  8. At this point, the files have been translated, but not yet transferred to D$. RAND USR 8216 to do the actual transfer. Now you may GOTO 17 to restart ZX Pro/File, and you can use any of the program’s options to process the files any way you want. Use the SAVE option to record the program and data on a separate tape.

Note that our routine leaves end-of-field markers even after blank lines; while this somewhat non-standard for ZX Pro/File, it doesn’t seem to mind if they’re there. So far, I haven’t run into any difficulties. The programming would have been more longer and more complicated if we had to get rid of them, and the only advantage would have been a slight space savings – not enough to justify the additional trouble.

Next time, I’ll try to have a similar procedure worked out to translate M/text data files into the popular Psion Vu-File program. In subsequent installments we’ll work out programs to go the other way, from Pro/File to Vu-File to Memotext, so you can write form letters, etc. around existing files and make the interaction between your WP and database as complete as possible. Meanwhile, happy “Memo/Filing!”

ADDR HEXCODE   NAME MNEMONIC
============================
2000 010040 UPLD LD BC,ERNR ;STORE PROGRAM AT 49152-65535
2003 1100C0 LD BE,C000
2006 210040 LD HL,ERNR
2009 EDB0 LDIR
200B C9 RET
200C 010040 DNLD LD BC,ERNR ;GET STORED PROGRAM INTO 16-32K AREA
200F 110040 LD DE,ERNR
2012 2100C0 LD HL,C000
2015 EDB0 LDIR
2017 C9 RET
2018 010000 XFER LD BC,0000 ;# BYTES TO MOVE IN BC
201B 2A1040 LD HL,(VARS) ;GET VARS START ADDRESS
201E 111B00 LD DE,001B ;AND ADD 27
2021 19 ADD HL,DE ;FOR START OF FILE
2022 EB EX DE,HL ;DESTINATION IN DE
2023 216380 LD HL,8063 ;SOURCE ADDRESS IN HL
2026 EDB0 LDIR ;TRANSFER
2028 C9 RET ;RETURN
2029 210080 XLAT LD HL,8000 ;INIT ADDRESS=32768
202C 7E LP01 LD A,(HL) ;GET CHAR AT ADDR INTO A
202D 23 INC HL ;NEXT ADDRESS
202E FEFF CP FF ;IT IT START OF FILE?
2030 2802 JR Z 2034 ;YES, GO ON
2032 18F8 JR LP01 ;NO, LOOP BACK
2034 222420 LD (2024),HL ;PUT SOURCE ADDR INTO TRANSFER
2037 E5 PUSH HL ;ROUTINE
2038 0E00 LD C,00 ;INIT FIELD COUNTER
203A 7E LP02 LD A,(HL) ;GET CHAR AT ADDR INTO A
203B FEFF CP FF ;END OF FILES?
203D 2807 JR Z FINI ;YES, GO TO END ROUTINE
203F CD5820 CALL EXAM ;NO, TRANSLATE CHARACTER
2042 77 LD (HL),A ;PUT TRANSLATION INTO ADDR
2043 23 INC HL ;NEXT ADDRESS
2044 18F4 JR LP02 ;LOOP BACK
2046 3E86 FINI LD A,86 ;PUT END-OF-FILES MARKER
2048 77 LD (HL),A ;INTO ADDRESS
2049 23 INC HL ;NEXT ADDRESS
204A D1 POP DE ;GET START ADDR INTO DE
204B AF XOR A ;RESET CARRY
204C ED52 SBC HL,DE ;CALCULATE # OF BYTES
204E 221920 LD (2019),HL ;AND LOAD INTO TRANSFER ROUTINE
2051 111300 LD DE,0013 ;ADD 19
2054 19 ADD HL,DE ;TO # OF BYTES
2055 E5 PUSH HL ;FOR PRO/FILE VARIABLE P
2056 C1 POP BC ;AND PUT INTO BC
2057 C9 RET ;AND RETURN
2058 00 EXAM NOP ;END-OF-FIELD?
2059 FEFE EFLD CP FE ;NO, GO ON
205B 200F JR NZ APOS ;YES MAKE IT 140
205D 3E8C LD A,8C ;
205F 0C INC C ;INCREMENT FIELD COUNTER
2060 57 LD D,A ;STORE CHARACTER
2061 79 LD A,C ;FIELD COUNTER IN A
2062 FE06 CP 06 ;IS IT 6?
2064 2004 JR NZ 206A ;NO, GO ON
2066 0E00 LD C,00 ;YES, RESET COUNTER
2068 1617 LD D,17 ;CHANGE CHARACTER TO 23
206A 79 LD A,D ;AND PUT IT BACK IN A
206B C9 RET ;RETURN
206C FE9A APOS CP 9A ;IS IT APOSTROPHE
206E 2003 JR NZ IVRS ;NO, GO ON
2070 3E8E LD A,8E ;YES, MAKE IT INV COLON
2072 C9 RET ;RETURN
2073 FEA6 IVRS CP A6 ;IS IT INV (UPPER) LETTER
2075 3807 JR C NRML ;NO, GO ON
2077 FEC0 CP C0
2079 3003 JR NC NRML ;NO, GO ON
207B C680 ADD A,80 ;MAKE IT "NORMAL"
207D C9 RET ;RETURN
207E FE26 NRML CP 26 ;IS IT LOWER LETTER
2080 D8 RET C ;NO, RETURN
2081 FE40 CP 40
2083 D0 RET NC ;NO, RETURN
2084 C680 ADD A,80 ;YES, MAKE IT INVERSE
2086 C9 RET ;RETURN

Products

 

Downloadable Media

 

Image Gallery

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top