ExportText.bbc  (C) Jon Ripley 2007 3 Export current program as formatted text file $ 0.10 01dec2007 Initial version  *ESC OFF P%=0:P%=!408: P%=0 X  P%>= P%<=P Name$="ExportText" 8Action$="save the current program as formatted text" ; 0: "SetWindowPos", @hwnd%, 0, 0, 0, 640, 320, 6: 26 / B% 255: "GetWindowText", @hwnd%, B%, 256 @file$=@dir$+$$B%:tmp$=file$: "CharLowerBuff", !^tmp$, tmp$ op$="CALL """+file$+"""" 4 "SetWindowText", @hwnd%, Name$+" Installation"  "ShowWindow", @hwnd%, 9  2: "Bind to which function key (1-15) ? "F%  F%>0 F%<16 (F$= 0+18+"EAECRI"+255+18+op$+13 <K$ = "Software\R T Russell\BBC BASIC for Windows\Macros" D "RegCreateKeyEx", &80000001, K$, 0, "", 0, &F003F, 0, ^K%, ^D% 3 "RegSetValueEx", K%, "F"+F%, 0, 3, F$, (F$)  "RegCloseKey", K% G'"Press "-(F%<10),"Shift+")"F";F%" from the editor to "Action$"." ('"Press any key to continue . . .";     @ "MessageBox", @hwnd%, $, $," in module")), 0, 48:  8 Clipboard_IsText= 100, "Cannot read clipboard"  > fs{lStructSize%, hwndOwner%, hInstance%, lpstrFilter%, \ @\ lpstrCustomFilter%, nMaxCustFilter%, nFilterIndex%, \ 4\ lpstrFile%, nMaxFile%, lpstrFileTitle%, \ ;\ nMaxFileTitle%, lpstrInitialDir%, lpstrTitle%, \ ?\ flags%, nFileOffset{l&,h&}, nFileExtension{l&,h&}, \ @\ lpstrDefExt%, lCustData%, lpfnHook%, lpTemplateName%} fp% 255 /ff$ = "Text files (*.txt)"+0+"*.txt"+0+0 fs.lStructSize% = (fs{}) fs.hwndOwner% = @hwnd% fs.lpstrFilter% = !^ff$ fs.lpstrFile% = fp% fs.nMaxFile% = 256 fs.flags% = 6  ' "GetWindowText", @hwnd%, fp%, 256  $$fp%,".") P%=$$fp%-1  fp%?P%<>".":P%-=1: $$(fp%+P%)=".txt"  $$fp%+=".txt"   ' "GetSaveFileName", fs{} result%  result%  "OpenClipboard", @hwnd% $ "GetClipboardData", 1 hdata% ! "GlobalLock", hdata% tmp% len%=0: len%?tmp%:len%+=1: file% = ($$fp%) 5 file%=0 100, "Cannot create file '"+$$fp%+"'" 8 "WriteFile", @hfile%(file%), tmp%, len%, ^temp%, 0 #file%  "GlobalUnlock", hdata%  "CloseClipboard"     Clipboard_IsText res% , "IsClipboardFormatAvailable", 1 res% =(res%=1)