Function vs Indicator, is there a difference in execution

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Function vs Indicator, is there a difference in execution

Postby arjfca » 30 Dec 2015

Hello

I wrote some code line to erase specific text on screen

The code was written in an indicator and in a Function

When the code is executed in Indicator, all the selected text on screen is erased
When the code is executed in Function, only one Text is erased at the time. i need to click somewhere else on the screen and then reclick on the button to erase the next Text

The code is the same in the function and in the Indicator but it look a lot slower when executed in the function

Martin

Code: Select all

Var:
ValToShow (-1),
Text_ID (-1);

ValToShow = GVSetNamedInt("Filename_B",0);
Text_ID = Text_Getfirst(3);


While Text_ID <> -2 begin;
//Print ("All ID: ", Text_ID:0:0);
// Print ("Text_ID: ", Text_ID:0:0, " TEX_ID_New: ", Text_ID_New:0:0);

//Print("Border: ", text_getBorder(Text_ID), " font name: ", text_Getfontname(Text_ID), " color: ", Text_Getcolor(Text_ID):0:0);

if A_Valid_Note_Number (text_ID)then begin
Print (Text_Id:0:0);
Text_delete(Text_ID);

end;

Text_ID = Text_GetNext(Text_ID,3);

end;
Text Valid function

Code: Select all

Input:
Text_ID (NumericSimple);


A_Valid_Note_Number = False;
//Print ("Border: ", text_getBorder(Text_ID), " Font Name: ", text_Getfontname(Text_ID), " Color: ", Text_Getcolor(Text_ID):0:0);
if text_getBorder(Text_ID) = True and text_Getfontname(Text_ID) = "Verdana" and Text_Getcolor(Text_ID) = darkbrown then begin
//Print ("Valid: ", Text_ID:0:0);
A_Valid_Note_Number = True;
end;

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Function vs Indicator, is there a difference in executio

Postby Henry MultiСharts » 13 Jan 2016

Hello Martin,

You need to call Text_GetNext before you call Text_delete.
Please try the following code:

Code: Select all

Var:
ValToShow (-1),
Text_ID (-1), Text_ID_Next(-1);


Text_ID = Text_Getfirst(3);

While Text_ID <> -2 begin

Text_ID_Next = Text_GetNext(Text_ID, 3);

if A_Valid_Note_Number(text_ID)then begin
Print (Text_Id:0:0);
Text_delete(Text_ID);
end;

Text_ID = Text_ID_Next;

end;


Return to “MultiCharts”