BBC BASIC for Windows
Programming >> Communication and Input/Output >> Copy/paste output from BBC BASIC
http://bb4w.conforums.com/index.cgi?board=communication&action=display&num=1518810555

Copy/paste output from BBC BASIC
Post by simong42 on Feb 16th, 2018, 6:49pm

Any way in which the output from a PRINT statement can be copied into the paste buffer for use elsewhere?

Use case : decrypt and output the contents of a password file, for use in online logins.
Re: Copy/paste output from BBC BASIC
Post by michael on Feb 17th, 2018, 01:26am

I was experimenting with this code I found in help docs.

1) execute the program
2) after it ends, right click an empty spot in your editor and select paste

AND BEHOLD!

Code:
      text$ = "The five boxing wizards jump quickly"+CHR$13+CHR$10
      SYS "GlobalAlloc", &2000, LEN(text$)+1 TO hdata%
      SYS "GlobalLock", hdata% TO tmp%
      $$tmp% = text$
      SYS "GlobalUnlock", hdata%
      SYS "OpenClipboard", @hwnd%
      SYS "EmptyClipboard"
      SYS "SetClipboardData", 1, hdata%
      SYS "CloseClipboard"
      QUIT

      REM SYS "IsClipboardFormatAvailable", 1 TO res%

      REM  SYS "OpenClipboard", @hwnd%
      REM SYS "GetClipboardData", 1 TO hdata%
      REM IF hdata% THEN
      REM SYS "GlobalLock", hdata% TO tmp%
      REM text$ = $$tmp%
      REM SYS "GlobalUnlock", hdata%
      REM PRINT text$
      REM ENDIF
      REM SYS "CloseClipboard"