'===========================================================================
' Subject: LOAD/MERGE FILE TSR                Date: 11-23-97 (16:59)       
'  Author: Bert van Dam                       Code: PB                     
'  Origin: bd1rsd@usa.net                   Packet: PB.ABC
'===========================================================================
'LOAD/MERGE FILE TSR IN POWERBASIC
'
'TSR utility to load/merge files into applications that don't have
'functionality to do this otherwise. This TSR can be called with ALT-A.
'No errorchecking or repeated loading checking has been inculded. This
'TSR has been written by Bert van Dam with lot's of help from Scott McNay.
'If lines are 'double loaded' increase the value behing POPUP TIMER to
'match the speed of your computer. This code has been tested on a
'846DX4/100.

x& = SETMEM(-700000)
POPUP KEY CHR$(8,30,247)
PRINT "Popping down now . . ."
DO
  SuitYouself:
  'Temporary file to pop down to to save memory
  POPUP SLEEP using ems , "c:\dos\tmp\pb3.tsr"
  Letter$ = " "
  'Configuration file to remember which parts have been loaded
  'already. Before using this program for the first time you must
  'make this file manually. It only contains a space and a 0 (on the
  'same line.)
  OPEN "c:\pb3\config.txt" FOR INPUT AS #1
  INPUT #1, Status
  CLOSE #1
  if Status=0 then
    input "Which file do you want to load ";FileName$
  end if
  if FileName$="" then goto SuitYouself
  OPEN FileName$ FOR BINARY AS #1
  IF Status + 200 > LOF(1) THEN
    Fase = LOF(1)
  ELSE
    Fase = Status + 200
  END IF
  FOR Teller = Status TO Fase
    GET #1, Teller, Letter$
    if asc(Letter$)=10 then
      'carriage returns are not handled well by some applications
      'so the are replaced by the HOME key, which seems to work
      'much better.
      POPUP STUFF chr$(0,0,71),0,0
    else
      POPUP STUFF Letter$,0,0
    end if
  NEXT Teller
  if Fase=lof(1) then
    'when the entire file has been loaded the timer action is disabled
    'and the tsr can now be called manually again with ALT-A
    popup timer off
    popup key on
    Fase=-1
  end if
  CLOSE #1
  OPEN "c:\pb3\config.txt" FOR OUTPUT AS #1
  PRINT #1, Fase+1
  CLOSE #1
  if status=0 then
    'when the first part of the file has been loaded into the stuff
    'buffer the tsr is reloaded based on the timer to complete loading
    'the entire file.
    popup key off
    popup timer 18
    popup timer on
  end if
LOOP
