- Desktop
- Tools
- PASCAL Programming
- Reading A File Example
Reading A File Example
The following code is an example of how to read a file with the custom tool scripting.
//// Sample script showing how to read data from a file using TStringList//
// This section is where variable are defined that need to be used in both the Init and Process proceduresvar tb : TText;
// DefineTool is where the settings for the Tool are defined// This procedure is called once when the tool is loaded// Normally this procedure does not need to be changedprocedure DefineTool(Tool : TTool);begin Tool.Name := 'ReadFile'; Tool.MouseClicks := 1; Tool.Hint := 'Read File'; Tool.ToolType := ttDrawing;end;
// Init is called to initialise the tool// This procedure is called once when the tool is added to a chartprocedure Init(Tool : TTool);var sl : TStringlist;begin tb := Tool.AddText('File', Tool.MP[0].Date, Tool.MP[0].Price); sl := TStringlist.Create; sl.LoadFromFile('c:\data\Topix500.csv'); tb.Text := sl.Text; tb.FontColor := clRed; sl.free;end;
// Process is called to calculate and drawn the tool on screen// This procedure is called when new data is received or loaded and// when a selection point is moved by the userprocedure Process(Tool : TTool; ProcessStart : Integer; ProcessEnd : Integer; DataIn : TDataList);begin tb.Date := Tool.MP[0].Date; tb.Price := Tool.MP[0].Price;end;Forum Discussion
Your privacy choices
We use cookies and similar technologies to make the site work, see how it's used, and improve it. Analytics and advertising cookies only run with your consent — see our Privacy Policy for details.