Re: little endian read

2016-11-23 Thread Lance Dillon
Weird, I don't know what page I was getting then..  hmmm Sent from Yahoo Mail on Android On Wed, Nov 23, 2016 at 8:30 AM, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum<10...@lyskom.lysator.liu.se> wrote: The index works for me.  If you were unable to find Gnol and

Re: little endian read

2016-11-23 Thread Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
The index works for me. If you were unable to find Gnol and Drow in the list of methods that's probably because they are classes and not methods. :-) Click "MODULE REFERENCE" -> "ADT" -> "Struct" and both "Drow" and "Gnol" appear in the class list to the left.

Re: little endian read

2016-11-23 Thread Lance Dillon
Yeah, I found the ADT.Struct type with Gnol and Drow.  However, the documentation on the website gave me trouble.  I couldn't find an index to the left, just the modules themselves, so when I clicked on ADT, I couldn't see all the methods and click on them individually, I had to click on links a

Re: little endian read

2016-11-22 Thread Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
>Using %2c to read little endian probably only works on CPUs that are >little endian to begin with. No, that would just be broken. %2c is well defined to be big endian, and %-2c is well defined to be little endian. Why would what CPU you have matter?

little endian read

2016-11-22 Thread Martin Nilsson (Coppermist) @ Pike (-) developers forum
If someone could just come up with a good name, we should add little endian integers to Stdio.Buffer. read_int16_le()?

little endian read

2016-11-22 Thread Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
For starters, there is no need to call reverse. Just use "%-2c" in the sscanf format string for backwards endianness. Secondly, while you can't use "%*c",2 you _can_ use "%"+2+"c", if that is what you need. (Most headers have a fixed format where you know the sizes beforehand though, meaning you

Re: little endian read

2016-11-17 Thread Stephen R. van den Berg
Tobias S. Josefowitz wrote: >On Thu, Nov 17, 2016 at 11:37 AM, Stephen R. van den Berg wrote: >> Lance Dillon wrote: >>>Stdio.File fp;fp=Stdio.File(filename,"r");string str=fp->read(2);int >>>res=array_sscanf(reverse(str),"%2c")[0]; >> Using %2c to read little endian probably only works on CPUs

Re: little endian read

2016-11-17 Thread Stephen R. van den Berg
Lance Dillon wrote: >But, I found something even easier.?? It's been a while since I've used it, >but I remembered ADT.Struct, and it has Drow() and Gnol() types, which are >Intel (little-endian) versions of Word() and Long() types.?? Those do exactly >what I need, so even easier. Indeed. Forg

Re: little endian read

2016-11-17 Thread Lance Dillon
But, I found something even easier.  It's been a while since I've used it, but I remembered ADT.Struct, and it has Drow() and Gnol() types, which are Intel (little-endian) versions of Word() and Long() types.  Those do exactly what I need, so even easier. Basically I'm writing a program to conve

Re: little endian read

2016-11-17 Thread Lance Dillon
Ah, there we go.  I tried to find sscanf, but it isn't on the Pike Reference Manual - namespace predef | | | Pike Reference Manual - namespace predef | | | Module Tree Reference.  I had to go to the main doc page and search for sscanf.  printf also isn't listed.  Is it missin

Re: little endian read

2016-11-17 Thread Tobias S. Josefowitz
On Thu, Nov 17, 2016 at 11:37 AM, Stephen R. van den Berg wrote: > Lance Dillon wrote: >>Stdio.File fp;fp=Stdio.File(filename,"r");string str=fp->read(2);int >>res=array_sscanf(reverse(str),"%2c")[0]; > > Using %2c to read little endian probably only works on CPUs that are > little endian to begi

Re: little endian read

2016-11-17 Thread Stephen R. van den Berg
Lance Dillon wrote: >Stdio.File fp;fp=Stdio.File(filename,"r");string str=fp->read(2);int >res=array_sscanf(reverse(str),"%2c")[0]; Using %2c to read little endian probably only works on CPUs that are little endian to begin with. >Trying to find an easy way to make it variable, like 2 or 4 byte

little endian read

2016-11-16 Thread Lance Dillon
Is there an easy way to read a string from a file and read it in little endian format to convert to int? I have some old file formats that I want to convert, and header information is stored in little endian format.  So far I have something like this for a WORD (2-bytes): Stdio.File fp;fp=Stdio.