TeXWorks Scripting Delphi Trials Zip
Ive been looking at some of the recent html and like issues from a different perspective.
And came to the somewhat obvious conclussion that with the work that has already gone into providing scripting in Tw and the availablilty of the system function, anything that could write to the console under its OS could provide capturable text for Tw to us, and this may hep in the current discussion.
What I was not sure about esp for MS Windows was that a windowed application (forms application) could readily do this in a thread safe manner and not hit name-space issues.
Attached is a proof of concept which may open up some exciting possibilities.
Unzip into your 'scripts' directory - allowing Use Folder Names, in Tw Reload Scripts, and look for a new menu item, Delphi Trials.
You'll have to have selected the Edit/Preferences/Scripts Allow System Commands option.
This has only been tried under Windows Xp so how Windows 7 or Vista would behave is an open question, but this is all pure Win32 code so it should work there very well. (Code for inspection is below my siganture.)
(This Page is ): http://PaulANorman.com/trials/
Paul
====
Delphi Programmers, note that we can not call the system command Write from a form, set a form wide variable and access it after the form has closed, Write has to be called in the console unit. The application object is provided automatically in the Forms unit.
See: http://www.delphi3000.com/articles/article_2925.asp
=====
program formApptoConsoleOutput; {$APPTYPE CONSOLE} uses SysUtils, Windows, Messages, Forms, main in 'main.pas' {Form1}; {$R *.res} procedure showInfo(text:string); begin writeln(text); end; begin Form1 := TForm1.Create(Application); Form1.ShowModal; showInfo(main.answer); end.
======
unit main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm1 = class(TForm) Memo1: TMemo; BitBtn1: TBitBtn; BitBtn2: TBitBtn; procedure BitBtn2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; answer : string; implementation {$R *.dfm} procedure TForm1.BitBtn2Click(Sender: TObject); begin writeln('% From Delphi Application'+#13#10); answer := memo1.text; end; end.
======
object Form1: TForm1 Left = 0 Top = 0 Width = 530 Height = 370 Caption = 'Trial Insert Back to Tw' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Memo1: TMemo Left = 24 Top = 32 Width = 417 Height = 217 Lines.Strings = ( 'Proof of Concept' 'Type anything here on ...' 'Multiline' 'Can definitely do a colour dialogue from here or other things.' 'Connect to database and collect text etc ...' 'Can probably be done for Mac, Linux and Win - this is Win specif' + 'ic at mo' 'Any prog environment that can run forms and also write to the '#39'c' + 'onsole'#39' can ' 'do this..') ScrollBars = ssVertical TabOrder = 0 end object BitBtn1: TBitBtn Left = 408 Top = 296 Width = 75 Height = 25 TabOrder = 1 Kind = bkClose end object BitBtn2: TBitBtn Left = 320 Top = 296 Width = 75 Height = 25 Caption = 'Use' ModalResult = 6 TabOrder = 2 OnClick = BitBtn2Click end end