Text_SetSize and Text_GetSize: Not the same value is read  [SOLVED]

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

Text_SetSize and Text_GetSize: Not the same value is read

Postby arjfca » 29 Dec 2015

Hello

An indicator is use to put a Text on the screen
It installed the text, The border and the size

Another indicator is in use to read back the Text on the screen using Text_GetSize

Strange is the Size read back is not the same as the size installed

Code: Select all

Text_SetBorder(TextVal, True);
text_SetColor(textVal,Black);
text_setsize(TextVal,14);

Code: Select all


Print("Border: ", text_getBorder(Text_ID), " size: ", text_GetSize(Text_ID):0:0, " color: ", Text_Getcolor(Text_ID):0:0);
Value returned:
Border: TRUE size: 13 color: 0
Border: TRUE size: 13 color: 0
Border: TRUE size: 13 color: 0

The problem is that I planned to use the size, border and color to discriminate Text on the screen that I want to saved the coordinate. I will look to change my conditions because

Martin

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby TJ » 29 Dec 2015

Text_SetBorder(TextVal, True);

Print("Border: ", text_getBorder(Text_ID), " size: ",

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby arjfca » 29 Dec 2015

Text_SetBorder(TextVal, True);

Print("Border: ", text_getBorder(Text_ID), " size: ",
Hello TJ

My variables definition are OK because they are in use in two different indicators. But to removed any confusion, I did rename the first indicator to "Text_ID"

There is really a difference font size that is read back.

I changed my conditions to include a defined FontName. First indicator to define Font Name to "verdana" The second one is reading back the good font name.

Martin

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby TJ » 29 Dec 2015

You might have discovered a bug.

Try this:

Code: Select all


VAR: textval(-1);

if LastBarOnChart_s then
begin

textval = text_new(d,time_s, c, "Is there a bug?");

for value1 = 1 to 20
begin
text_setsize( TextVal, value1 );

value2 = text_GetSize( textval );

Print(
"valu1=", text( value1:0:0 ),
" text_getsize=", text( value2:0:0 ),
" diff= ", ( value1-value2 ):0:0
);
end;
end;

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby arjfca » 29 Dec 2015

You might have discovered a bug.

Try this:

Code: Select all


VAR: textval(-1);

if LastBarOnChart_s then
begin

textval = text_new(d,time_s, c, "Is there a bug?");

for value1 = 1 to 20
begin
text_setsize( TextVal, value1 );

value2 = text_GetSize( textval );

Print(
"valu1=", text( value1:0:0 ),
" text_getsize=", text( value2:0:0 ),
" diff= ", ( value1-value2 ):0:0
);
end;
end;
here is the result

valu1=1 text_size=1 diff= 0
valu1=2 text_size=1 diff= 1
valu1=3 text_size=3 diff= 0
valu1=4 text_size=4 diff= 0
valu1=5 text_size=4 diff= 1
valu1=6 text_size=6 diff= 0
valu1=7 text_size=7 diff= 0
valu1=8 text_size=7 diff= 1
valu1=9 text_size=9 diff= 0
valu1=10 text_size=10 diff= 0
valu1=11 text_size=10 diff= 1
valu1=12 text_size=12 diff= 0
valu1=13 text_size=13 diff= 0
valu1=14 text_size=13 diff= 1
valu1=15 text_size=15 diff= 0
valu1=16 text_size=16 diff= 0
valu1=17 text_size=16 diff= 1
valu1=18 text_size=18 diff= 0
valu1=19 text_size=19 diff= 0
valu1=20 text_size=19 diff= 1

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby TJ » 29 Dec 2015

this is what I have:
valu1=1 text_getsize=1 diff= 0
valu1=2 text_getsize=2 diff= 0
valu1=3 text_getsize=3 diff= 0
valu1=4 text_getsize=3 diff= 1
valu1=5 text_getsize=5 diff= 0
valu1=6 text_getsize=6 diff= 0
valu1=7 text_getsize=6 diff= 1
valu1=8 text_getsize=8 diff= 0
valu1=9 text_getsize=9 diff= 0
valu1=10 text_getsize=9 diff= 1
valu1=11 text_getsize=11 diff= 0
valu1=12 text_getsize=12 diff= 0
valu1=13 text_getsize=12 diff= 1
valu1=14 text_getsize=14 diff= 0
valu1=15 text_getsize=15 diff= 0
valu1=16 text_getsize=15 diff= 1
valu1=17 text_getsize=17 diff= 0
valu1=18 text_getsize=18 diff= 0
valu1=19 text_getsize=18 diff= 1
valu1=20 text_getsize=20 diff= 0
Strange. I have different results than yours.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby JoshM » 30 Dec 2015

I thought there might be a difference of 1px when the for-loop updates faster than the text box is changed, but without a for loop this issue also occurs:

Code: Select all

Variables:
IntraBarPersist counter(1),
textID(0);

if (LastBarOnChart_s = true) then begin

textID = text_new_s(Date, Time_s, Close, "Text");

Text_SetSize(textID, counter);

Print(FormatTime("HH:mm:ss", ComputerDateTime),
" - Text set to: ",
NumToStr(counter, 0),
" - Text size: ",
NumToStr(Text_GetSize(textID), 0));

counter = counter + 1;

if (counter > 20) then
counter = 1;

end;
Generates as output:

Code: Select all

08:31:18 - Text set to: 1 - Text size: 1
08:31:18 - Text set to: 2 - Text size: 2
08:31:22 - Text set to: 3 - Text size: 3
08:31:27 - Text set to: 4 - Text size: 3
08:31:31 - Text set to: 5 - Text size: 5
08:31:40 - Text set to: 6 - Text size: 6
08:31:50 - Text set to: 7 - Text size: 6
08:32:03 - Text set to: 8 - Text size: 8
08:32:17 - Text set to: 9 - Text size: 9
08:32:21 - Text set to: 10 - Text size: 9
08:32:26 - Text set to: 11 - Text size: 11
08:32:35 - Text set to: 12 - Text size: 12
08:32:40 - Text set to: 13 - Text size: 12
08:32:44 - Text set to: 14 - Text size: 14
08:32:49 - Text set to: 15 - Text size: 15
08:32:53 - Text set to: 16 - Text size: 15
08:33:07 - Text set to: 17 - Text size: 17
08:33:21 - Text set to: 18 - Text size: 18
08:33:25 - Text set to: 19 - Text size: 18
08:33:30 - Text set to: 20 - Text size: 20
08:33:34 - Text set to: 1 - Text size: 1
08:33:48 - Text set to: 2 - Text size: 2
08:33:52 - Text set to: 3 - Text size: 3
08:33:57 - Text set to: 4 - Text size: 3
08:34:15 - Text set to: 5 - Text size: 5
08:34:20 - Text set to: 6 - Text size: 6
08:34:24 - Text set to: 7 - Text size: 6
08:34:38 - Text set to: 8 - Text size: 8
08:34:43 - Text set to: 9 - Text size: 9
08:34:44 - Text set to: 10 - Text size: 9
08:34:47 - Text set to: 11 - Text size: 11
08:34:56 - Text set to: 12 - Text size: 12
08:35:05 - Text set to: 13 - Text size: 12
08:35:05 - Text set to: 14 - Text size: 14
08:35:10 - Text set to: 15 - Text size: 15
08:35:19 - Text set to: 16 - Text size: 15
08:35:24 - Text set to: 17 - Text size: 17
08:35:28 - Text set to: 18 - Text size: 18
08:35:33 - Text set to: 19 - Text size: 18
08:35:42 - Text set to: 20 - Text size: 20
So it's not due to that changing a text box is 'lagging' behind a for loop. It's also not due to rounding differences; the font sizes returned are integers so the differences of 1 isn't due to that. Would be interesting to hear what causes this.

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

Re: Text_SetSize and Text_GetSize: Not the same value is rea

Postby Henry MultiСharts » 04 Jan 2016

Dear users,

This issue has been confirmed and forwarded to the development team.

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

Re: Text_SetSize and Text_GetSize: Not the same value is rea  [SOLVED]

Postby Henry MultiСharts » 10 Feb 2016

The fix for this issue will become available in MultiCharts 9.1 Release 3.


Return to “MultiCharts”