ReadString() "To the Infinity and beyond"

Feature requests for future versions of Hollywood can be voiced here
Post Reply
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

ReadString() "To the Infinity and beyond"

Post by lazi »

I wish I could use ReadString() without knowing the length.
Maybe a #NIL as length could mean that should read the bytes until it reach the end of file or the end of the universe. ;)
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Re: ReadString() "To the Infinity and beyond"

Post by p-OS »

A Hollywood string is not limited to characters, it can also contain binary data. As documentation explicitly states ReadString is also meant for reading parts of a binary file to memory. Thus it is important to give length. If you just want to read complete file in to memory, you could use either

Code: Select all

size =FileSize("myfilename")
fh=OpenFile(Nil,"myfilename")
mystring=ReadString(fh,size)
CloseFile(1)
or more easily:

Code: Select all

mystring=FileToString("myfilename")
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

Re: ReadString() "To the Infinity and beyond"

Post by lazi »

Thanks!

The first method is known by me, but overlooked the FileToString() function.

Hollywood is so huge that my 45 years old head hardly can fight with it :lol:
Post Reply