Strang square at end of Text read from file

A forum dedicated to George scripting questions
Post Reply
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Strang square at end of Text read from file

Post by Mads Juul »

I want to create text brushes from text files with George
I have a text file called "test.txt" in my TEMP directory on my Windows Computer
I Have one line in the text file with the text "mads"
If I run this script

Code: Select all

tv_getPath Temp
	temp =  result
	
	myFile =  tempDir"test.txt"
	
	tv_readtextfile  0 myFile
	read = result
	PARSE read line string
	tv_textBrush string
I get a custom brush with a strange square at the end
brush.png
brush.png (2.64 KiB) Viewed 1255 times
I guess TVpaint is reading the new line wrong. So I guess this is a bug?
How can I avoid this?
-Mads
User avatar
Paul Fierlinger
Posts: 8100
Joined: 03 May 2008, 12:05
Location: Pennsylvania USA
Contact:

Re: Strang square at end of Text read from file

Post by Paul Fierlinger »

I don't know if there is a connection, but on the Vegas forum there has been some discussions of this happening to some users and the explanation can be found here:
http://www.infoworld.com/t/microsoft-wi ... tch-209684" onclick="window.open(this.href);return false;
Paul
http://www.slocumfilm.com
Desktop PC Win10-Pro -64 bit OS; 32.0 GB RAM
Processor: i7-2600 CPU@3.40GHz
AMD FirePro V7900; Intuos4 Wacom tablet
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Strang square at end of Text read from file

Post by Mads Juul »

I dont think there is a connection. The square is a symbol for that TVPaint is misinterprenting "the new line"
IF I rrun this code

Code: Select all

PARAM none

tv_getPath Temp
temp =  result

myFile =  temp"test.txt"

tv_readtextfile  0 myFile
read = result
PARSE read line string

tv_reqstring [MULTILINE] "Get text|"string
tv_textBrush result
I get this brush result
new.png
new.png (3.74 KiB) Viewed 1248 times
So the tv_regstring read a new line correctly as "\n", which I can replace with nothing with the function Replace(string,'\n',' ')

So I would like the tv_readtextfile 0 myFile
to read new lines as "/n"
I consider it a bug that it is not reading new lines correct.
-Mads
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: Strang square at end of Text read from file

Post by Svengali »

Hi Mads,

I haven't tested your script code but I wonder if the square (unidentified character) is being introduced because you first assign the RESULT to the variable READ, then you are parsing the contents of the variable READ.

Try instead simply parsing the RESULT of the tv_readtextfile.

Code: Select all

tv_readtextfile  0 myFile
PARSE result line string
Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Strang square at end of Text read from file

Post by Mads Juul »

Svengali wrote:Hi Mads,

I haven't tested your script code but I wonder if the square (unidentified character) is being introduced because you first assign the RESULT to the variable READ, then you are parsing the contents of the variable READ.

Try instead simply parsing the RESULT of the tv_readtextfile.

Code: Select all

tv_readtextfile  0 myFile
PARSE result line string
Sven
No it gives the same result.
It must be the tv_readtextfile that interprets new line wrong
the test.txt file should of course have a new line. for instance my test.txt have this 2 lines
mads
juul
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: Strang square at end of Text read from file

Post by Svengali »

OK. One other work around might be to include a character (to act as a terminator for each word you are trying to convert in the list) something like an asterisk...

mads*
juul*


In your script you would then process the result of a textline read, to extract only up to the asterisk, giving you the word you want for each line... hopefully that would clip off the unrecognized character at the end of each line in the text file.

This should give you a functional result until a solution can be discovered in a future fixed version of TVPaint.

Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Strang square at end of Text read from file

Post by Mads Juul »

Assuming the last char is a unrecognised "new line" I could do this

Code: Select all

PARAM none
tv_getPath Temp
temp =  result

myFile =  temp"test.txt"

tv_readtextfile  0 myFile

PARSE result line string

length = LEN(string)
length=length-1
string = CUT(string,1,length)
tv_textBrush string

And if I wanted a new line I can do this

Code: Select all

string = string"\n"
tv_reqstring [MULTILINE] "Get text|"string
But it could be nice if this bug is fixed
Elodie
Posts: 13912
Joined: 06 Jan 2009, 09:53
Location: Metz

Re: Strang square at end of Text read from file

Post by Elodie »

Send your prayers to the God of the Development :mrgreen:
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Strang square at end of Text read from file

Post by Mads Juul »

Elodie wrote:Send your prayers to the God of the Development :mrgreen:
I will :D
Post Reply