1. Structures and eraier Windows graphics

I am in the process of writing 2 .e files: struct.e and gwin.e. Struct.e is
supposed to work with C structures, so you don't have do do all that
poke(address + offset...) and gwin.e is supposed to help with Windows
graphics and windows.

My problem is that in struct.e, I need to know how to poke shorys, ints,
and longs, and chars into memory. I need to know the format. If anyone has
any ideas, please tell me and I'll post my files on the Offical Euphoria
Programming Page.

JJProg at cyberbury.net

new topic     » topic index » view message » categorize

2. Re: Structures and eraier Windows graphics

Jeff Fielding wrote:

> My problem is that in struct.e, I need to know how to poke shorys,
> ints,
> and longs, and chars into memory. I need to know the format. If anyone
> has
> any ideas, please tell me and I'll post my files on the Offical
> Euphoria
> Programming Page.

Ints have to be converted to 4 bytes/atom values between 0 en 255
Longs have to be converted to 8 bytes/atom values between 0 en 255
Chars have to be converted to 1 byte. (so just poke it in)

To convert an atom to 4-bytes:
    poke(addres, {a, a/2^8, a/2^16, a/2^24})

2^8 means 2 to the power of 8.
See the logic ??
BTW for poking an atom as an 4-byte machine integer, you can use some
inbuilt routine called poke4 or something.
It is a new routine for Euphoria 2. It is a lot faster (i suppose)

BTW 2 you needed to convert anything to poke a char, it is automatically
done...
    poke (addres, char)
works, just as
    poke (addres, "ralf")
works fine..

Euphoria converts stuff being poked to memory to an byte/char as
default.

Ralf N.
nieuwen at xs4all.nl

new topic     » goto parent     » topic index » view message » categorize

3. Re: Structures and eraier Windows graphics

>Jeff Fielding wrote:

>> My problem is that in struct.e, I need to know how to poke
>shorys, > ints, > and longs, and chars into memory. I need to
>know the format. If anyone > has > any ideas, please tell me and
>I'll post my files on the Offical > Euphoria > Programming
>Page.

>Ints have to be converted to 4 bytes/atom values between 0 en
>255 Longs have to be converted to 8 bytes/atom values between 0
>en 255 Chars have to be converted to 1 byte. (so just poke it
>in)

>To convert an atom to 4-bytes:     poke(addres, {a, a/2^8,
>a/2^16, a/2^24})

>2^8 means 2 to the power of 8. See the logic ?? BTW for poking
>an atom as an 4-byte machine integer, you can use some inbuilt
>routine called poke4 or something. It is a new routine for
>Euphoria 2. It is a lot faster (i suppose)

>BTW 2 you needed to convert anything to poke a char, it is
>automatically done...     poke (addres, char) works, just as    =

>poke (addres, "ralf") works fine..

>Euphoria converts stuff being poked to memory to an byte/char as
>default.

>Ralf N. nieuwen at xs4all.nl

Additional information:

For converting to 8 bytes you can use:
Command: atom_to_float64
  =

Syntax: =

  include machine.e
  s =3D atom_to_float64(a1)
  =

Description: =

  Convert a Euphoria atom to a sequence of 8 single-byte values.
  These 8 bytes contain the representation of an IEEE floating-
  point number in 64-bit format.
  =

Comments: =

  All Euphoria atoms have values which can be represented as =

  64-bit IEEE floating-point numbers, so you can convert any atom
  to 64-bit format without losing any precision. =

  =

  Integer values will also be converted to 64-bit floating-point =

  format.
  =

Example: =

     fn =3D open("numbers.dat", "wb")
      puts(fn, atom_to_float32(157.82)) -- write 8 bytes to a file
      =

See Also: =

  atom_to_float32, float64_to_atom

Ad_Rienks at compuserve.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu