Peter.M..Perchansky@f101.n273.z1.fidonet.org (Peter M. Perchansky) (06/28/90)
Hello: Subject: TSR Program to import an ASCII file into a text editor/word processor. Problem: Our present email system has no import feature; all editing must be done within the email systems editor. Solution: Write a TSR program to perform the following: 1) Activate upon key sequence (alt I). 2) Get file name of ASCII file from user. 3) If valid file perform the following from start of the file to the end of the file: a) Get string of text from file. b) Stuff each character from the input string into the keyboard buffer. Programming Dilema: TSR program fills keyboard buffer (16 characters), and overloads the keyboard buffer. Only the first 16 characters from the file are actually imported. The buffer is not read (cleared) until the TSR becomes inactive, and the calling program takes over once again. Best Guess: Temporarily transfer control to calling program in order for the calling program to read (clear) the keyboard buffer --- then return to the TSR. The sequence should be as follows: 1) Stuff 16 characters or less into the keyboard buffer. 2) Transfer control to calling program until keyboard buffer is read (cleared). 3) Repeat 1 and 2 until no more characters from the text file can be processed. Question: How to implement the "best guess" in Modula-2 or another high level language? -- uucp: uunet!m2xenix!puddle!273!101!Peter.M..Perchansky Internet: Peter.M..Perchansky@f101.n273.z1.fidonet.org
Dominique.Willems@p4610.f46.n295.z2.fidonet.org (Dominique Willems) (07/02/90)
Hello Peter, > 1) Stuff 16 characters or less into the > keyboard buffer. > 2) Transfer control to calling program until > keyboard buffer is read (cleared). > 3) Repeat 1 and 2 until no more characters > from the text file can be processed. I don't know if this is of any use to you, but I once had a similar problem when I wanted to make one-key or key-combination macroes that allowed me to start up a program and simulate all the key-entries to put the programme in the wanted state from the DOS command line. The programme works perfectly and has saved me from a lot of useless (repetitive) keystrokes since. It is implemented in Assembly Language, although I think you shouldn't have many problems implementing it in Modula-2, although I don't really recommend it, since it's very unlikely that even JPI's M2 can produce more compact code for this very simple TSR. What I did was : 1) Intercept interrupt 16H 2) Check for the Macro keystroke (in your case this is already done) 3) Set a counter equal to the number of simulated ("emulated" is more correct) keystrokes, although this is unnecessary if the string has a termination character (in your case probably the End-Of-File marker) 4) Signal via the return registers that there is a character available from the keyboard and put the character in AL 5) IRET - programme execution - 6) Interception of INT 16H (the programme wants to read the next character) 7) Check the counter or any other flag you choose to use to check whether the transfer is complete 8) If the counter#0, or flag is still set, then fetch the next character and go to step 4 else jump to the usual INT 16H routine (of which you have saved the address at TSR installation, of course) As you see this is a very simple solution and doesn't use the buffer at all, so theoretically unlimited size character streams can be transferred. (the only really important thing is step 4) As I said, I don't know if this helps you any further, but it did the trick wonderfully for me. If you want more details about the code, please let me know. Greetings from Brussels, where the weather has gone bizarre again, Dominique -- uucp: uunet!m2xenix!puddle!2!295!46.4610!Dominique.Willems Internet: Dominique.Willems@p4610.f46.n295.z2.fidonet.org
Peter.M..Perchansky@f101.n273.z1.fidonet.org (Peter M. Perchansky) (07/06/90)
Hello Dominique: Thank you for your help. I will try to implement the above next week (new Novell installations are keeping me busy this week). I will let you know how it goes. -- uucp: uunet!m2xenix!puddle!273!101!Peter.M..Perchansky Internet: Peter.M..Perchansky@f101.n273.z1.fidonet.org