Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!cornell!rochester!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: User Interface Message-ID: <1815.UUL1.3#5129@willett.pgh.pa.us> Date: 5 Oct 90 03:27:33 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 50 Date: 09-22-90 (08:04) Number: 3818 (Echo) To: ALL Refer#: NONE From: STEVE PALINCSAR Read: (N/A) Subj: Passing commands to DOS Status: PUBLIC MESSAGE The following code (which I translated into Forth - specifically HS/Forth - from QuickBasic code published in PC Magazine this Spring) can be used to chain execution from one program to another by placing a string into the PC's keyboard buffer. Limitation is that only 15 characters max can be put there. That means a complex lengthy command would have to be invoked with a batch file. \ Pass a command to the PC keyboard buffer. Can be used to pass \ execcution of an EXE, COM orr BAT file. Unlike using SHELL, this \ program will not stay in memory. Can be used for creating a front-end \ menu program. For HS/Forth, but can be used with any Forth that has \ C!L ( n segmentaddr offset -- ). DUPC@ is a coded-together DUP C@; \ 2* is a 2 * DECIMAL : ADD_RETURN ( $addr -- $addr ) \ Add an ASCII 13 to the end of a counted string DUPC@ 1++ OVER C! 13 OVER DDUPC@ + C! ; : PASS_COMMAND ( $addr -- ) \ Place a counted string into the PC's keyboard buffer ADD_RETURN 30 0 1050 C!L \ Update the ead & ttail DUPC@ 2* 30 + 0 1052 C!L \ keyboard buffer pointers DUPC@ 1+ 1 DO \ Loop thru the string DUP I + C@ \ and copy i:hinto the 0 1052 I 2* + C!L \ keyboard buffer LOOP DROP \ annd then discard the string ; : TEST IN$ ( Prompts for string, places it at PAD ) PASS_COMMAND ( Place the string in thhe keyboardd buffer ) BYE ( and return to DOS. ) ; ----- This message came from GEnie via willett through a semi-automated process. Report problems to: dwp@willett.pgh.pa.us or uunet!willett!dwp