' The following code will stuff a string of upto 15 chars into ' the keyboard buffer after clearing same. This stuffing may or may ' not effect the ability of INSTAT to correctly access the availabity ' of an awaiting key-press so.... be advised! ' d83@hol.gr CLS ' Gotta pull bytes in by count as Strg$ = "Hello World" ' INSTR has lost it's count in Chars% = fStr2Keyboard?( Strg$ ) ' PowerBASIC at least. FOR X% = 1 TO Chars% ' G$ = G$ + INKEY$ ' NEXT ' PRINT ">>"; Strg$; "<<" ' PRINT ">>"; G$; "<<" ' ' PURPOSE: to clear the keyboard buffer then stuff Strg$ into it ' PARAMS: Strg$ any string of from 1 to 15 bytes in length ' RETURNS: the actual number of characters stuffed into the buffer ' values <1 would indicate a failed attempt FUNCTION fStr2Keyboard? ( SEG Strg$ ) LOCAL PUBLIC LOCAL A%, B%, G$, L%, Offset%, P% DO : G$ = INKEY$ : LOOP UNTIL LEN(G$)=0 ' clear the buffer ' L% = MIN%( LEN( Strg$ ), 15 ) ' max 15 characters IF L% = 0 THEN EXIT FUNCTION ' nothing to do.... bye! ' DEF SEG = &h0040 ' set the segment Offset% = PEEKI( &h001C ) ' offset to buffer ' FOR P% = 1 TO L% ' A% = ASCII( MID$( Strg$, P% ) ) ' low byte only for now IF A% = 0 THEN ' process 2byte keys IF P% = L% THEN EXIT FOR ' no "next" byte P% = ( P% + 1 ) ' next char in Strg$ B% = ASCII( MID$( Strg$, P% ) ) ' get next byte A% = ( B% * 256 ) ' lowbyte = 0 END IF ' B% = ( Offset% + 2 ) ' bump buffer ptr IF B% => PEEK( &h0082 ) THEN ' check if ptr is correct B% = PEEK( &h0080 ) ' if not then load END IF ' IF B% = PEEK( &h001A ) THEN EXIT FOR ' oops! POKEI Offset%, A% ' poke 2bytes into buffer POKEI &h001C, B% ' poke character count Offset% = B% ' new offset NEXT ' DEF SEG ' reset segment ' RETURN FUNCTION = ( P% - 1 ) ' # of chars processed ' END FUNCTION