Page 1 of 1

[Implemented] ReadCharacter(#File, [, Flags])

Posted: Thu Aug 14, 2014 4:02 pm
by Tenaja
Fred & Freak, can you please add the same file format flags to ReadCharacter() that are in ReadString()?

I am making my code Unicode friendly, but I need to be able to read ascii and utf-8 files as well, based on the file type.

thanks.

Re: ReadCharacter(#File, [, Flags])

Posted: Thu Aug 14, 2014 4:51 pm
by Fred
Good idea. In the meantime, you can use ReadString() with a length of 1.

Re: ReadCharacter(#File, [, Flags])

Posted: Thu Aug 14, 2014 4:56 pm
by STARGĂ…TE
@Fred
With this flag you can remove the functions: ReadUnicodeCharacter() and ReadAsciiCharacter()
Same for WriteCharacter()

And same for PokeC() and PeekC() ?

Re: ReadCharacter(#File, [, Flags])

Posted: Thu Aug 14, 2014 5:15 pm
by Tenaja
Fred wrote:Good idea. In the meantime, you can use ReadString() with a length of 1.
Thank you. (And if you saw my other post, you will see I am using ReadString, but it is slow compared to readcharacter, which is noticeable in very large files.

As Stargate suggested, perhaps you can implement it in other string and character related commands...where it makes sense, of course. This update will make the elimination of ascii strings significantly easier to deal with.

Re: ReadCharacter(#File, [, Flags])

Posted: Thu Aug 14, 2014 5:16 pm
by skywalk
Please don't remove PeekC/PokeC. That breaks macros and requires even more code changes.

Re: ReadCharacter(#File, [, Flags])

Posted: Thu Aug 14, 2014 7:49 pm
by Tenaja
skywalk wrote:Please don't remove PeekC/PokeC. That breaks macros and requires even more code changes.
Considering his pattern of previous edits, I think Fred is more likely to change the syntax from this:
PeekC(*MemoryBuffer)
To this:
PeekC(*MemoryBuffer [, Flags])
An edit which will not break existing code.

BTW, I have posted a workaround that does not create a string, by creating a ReadUTF8Character routine. It may or may not be faster; I guess I'd have to benchmark it to tell:
http://purebasic.fr/english/viewtopic.php?f=12&t=60273