PDA

View Full Version : getlines() not returning


Kirko
02-14-2016, 12:57 PM
The functions getlines() and getlinecount() are returning nothing but when I do something else like gettext() it returns correctly.
This is all in a for loop when displaying messages

echo(("Message_"@temp.i).getlines());
echo(("Message_"@temp.i).getlinecount());
echo(("Message_"@temp.i).gettext());//only one to work

Another thing I tried to do

this.trueSize = thiso.catchevent(this, "onReflow", "onTest");


function onTest(temp.obj, newwidth, newheight){
echo(temp.obj.getlinecount()); //does echo correctly
return temp.obj.getlinecount();
}

but then back in the for loop this just doesnt echo anything

echo((@"Message_"@temp.i).trueSize);

What I'm trying to do is get the amount of lines there are in the text control so I can adjust the y position for the next message.

ffcmike
02-14-2016, 02:04 PM
Might it be that the string isn't coercing in to an object?

You could try something on the lines of:


temp.obj = makevar("Message_" @ temp.i);
echo(temp.obj.getLines());

Kirko
02-14-2016, 02:25 PM
Still doesn't seem to work.

ffcmike
02-21-2016, 04:26 PM
It seems this is just the behaviour when echo'ing an array rather than a string.

For example it outputs the line count if I do:


echo(("Message_"@temp.i).getlines().size());
//13
//13
//13


You can coerce the array to a string by doing:


echo(@ ("Message_"@temp.i).getlines());
//ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,A SDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH
//ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,A SDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH
//ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,A SDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH

Kirko
02-21-2016, 07:22 PM
I tried doing what you did and got zeros like before. I seem to have bad luck with this, or I just screwed up somewhere in the script. :(

This is the part where it seems to be messing up, if anyone can see anything wrong.

for(temp.i = 0; temp.i < temp.messageSize; temp.i++){

new GuiMLTextCtrl("Message_" @ temp.i){
useownprofile = true;
profile.modal = false;
profile.fonttype = "Arial";
profile.fontsize = 20;
profile.fontcolor = temp.textFormat ? "black" : "white";

profile.textshadow = true;
profile.shadowcolor = "black";

allowedtags = (temp.fromstaff ? {"img", "b", "font", "center"} : {"b", "img"});

alpha = temp.textFormat ? 0.3 : 1.0;
visible = true;
resize(50, temp.y, 330, 20);

//addtext(temp.message, true);
text = temp.message;
//thiso.catchevent(this, "onReflow", "onTest");
}


temp.obj = makevar("Message_" @ temp.i);
temp.lines = (@("Message_" @ temp.i).getLines());
echo(temp.lines); //echos nothing


temp.chat_height = temp.lines <= 0 ? 25 : temp.lines * 25;
temp.y += temp.chat_height;

}


Only other way I can think of fixing is getting the width of text and then getting the amount of lines by dividing the text width by Gui width.

ffcmike
02-21-2016, 07:46 PM
The problem seems to be something else, lines are being echo'd fine for me when I do:


temp.messageSize = 3;
for(temp.i = 0; temp.i < temp.messageSize; temp.i++){

new GuiMLTextCtrl("Message_" @ temp.i){
useownprofile = true;
profile.modal = false;
profile.fonttype = "Arial";
profile.fontsize = 20;
profile.fontcolor = temp.textFormat ? "black" : "white";

profile.textshadow = true;
profile.shadowcolor = "black";

allowedtags = (temp.fromstaff ? {"img", "b", "font", "center"} : {"b", "img"});

alpha = temp.textFormat ? 0.3 : 1.0;
visible = true;
resize(50, temp.y, 100, 20);

text = "asdf asdf asdf asdf asdf asdf asdf asdf ";
}


echo(@("Message_" @ temp.i).getlines());


temp.chat_height = temp.lines <= 0 ? 25 : temp.lines * 25;
temp.y += temp.chat_height;

}


Renders 2 "asdf" per line, echo's:

"asdf asdf","asdf asdf","asdf asdf","asdf asdf"
"asdf asdf","asdf asdf","asdf asdf","asdf asdf"
"asdf asdf","asdf asdf","asdf asdf","asdf asdf"

xAndrewx
02-24-2016, 12:41 PM
Looks like code from the iOS PM system...? Correct me if I'm wrong


Replace

temp.obj = makevar("Message_" @ temp.i);
temp.lines = (@("Message_" @ temp.i).getLines());
echo(temp.lines); //echos nothing

with

temp.lines = (@("Message_" @ temp.i)).getLines();
echo(temp.lines);

MysticalDragon
02-24-2016, 04:02 PM
It is, he works on Delteria IOS and is working on the PM Threading System. I added a temporary fix, because I could not get the lines to work either, So i did.


temp.lines = wraptext2(200,12/24," -","@[email protected]@" @ temp.rawmessage);
temp.linecount = temp.lines.size();


But I will try your method as it would be more accurate.