ReadString() "To the Infinity and beyond"

Feature requests for future versions can be voiced here

ReadString() "To the Infinity and beyond"

Postby lazi » Mon Apr 13, 2015 11:46 am

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. ;)
User avatar
lazi
 
Posts: 256
Joined: Fri Feb 25, 2011 12:08 am

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

Postby p-OS » Mon Apr 13, 2015 3:56 pm

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")
p-OS
 
Posts: 72
Joined: Tue Nov 02, 2010 12:56 am

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

Postby lazi » Mon Apr 13, 2015 8:17 pm

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:
User avatar
lazi
 
Posts: 256
Joined: Fri Feb 25, 2011 12:08 am


Return to Wishlist

Who is online

Users browsing this forum: No registered users and 2 guests

cron