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 convert old dos grasp .gl files, which contain Pictor PC Paint .pic files, into individual images, possibly gif or png format.  I'm going to skip the actual automation or anything, just write out the individual files.



On Thursday, November 17, 2016 9:11 AM, Lance Dillon <riffraff169@yahoo.com> wrote:


Ah, there we go.  I tried to find sscanf, but it isn't on the 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 missing, or am I just missing it?  array_sscanf is present, and says it uses the same format specifiers as sscanf, but didn't have a link to sscanf.

That does exactly what I need, thanks.


On Thursday, November 17, 2016 6:20 AM, Tobias S. Josefowitz <t.josefowitz@gmail.com> wrote:


On Thu, Nov 17, 2016 at 11:37 AM, Stephen R. van den Berg <srb@cuci.nl> 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 begin with.

To quote from sscanf() documentation:


"%c"

Reads one character and returns it as an integer ("0101" makes 48, or
'0', leaving "101" for later directives). Using the field width and
endianness modifiers, you can decode integers of any size and
endianness. For example "%-2c" decodes "0101" into 12592, leaving "01"
fot later directives. The sign modifiers can be used to modify the
signature of the data, making "%+1c" decode "รค" into -28.

"-"
Supplying a minus sign toggles the decoding to read the data encoded
in little-endian byte order, rather than the default network
(big-endian) byte order.