Re: [Newbies] Reading and writing C structs

2008-07-01 Thread David Finlayson
I need to read very large files so a single ByteArray holding all the data wouldn't work (not until I get a 64-bit version of Squeak). However, I could read in one or more structure at-a-time as a ByteArray and then parse out the data I need, then read the next sequence. This is kind-of like a buff

Re: [Newbies] Reading and writing C structs

2008-07-01 Thread Ramiro Diaz Trepat
Yes, if you can load the contents on a ByteArray you can use the method: array floatAt: position It works just fine to read contents written from a C program, and I think it is a bit simpler. Cheers. r. On Wed, Jul 2, 2008 at 12:36 AM, David Finlayson <[EMAIL PROTECTED]> wrote: > Thanks. T

Re: [Newbies] Reading and writing C structs

2008-07-01 Thread David Finlayson
Thanks. The following methods work, can they be improved/simplified? double " returns a double " | n a b | a := self uint32. b := self uint32. n := Float new: 2. n at: 1 put: b. n at: 2 put: a. ^n float " returns a float "

Re: [Newbies] Reading and writing C structs

2008-07-01 Thread Bert Freudenberg
Am 01.07.2008 um 07:27 schrieb David Finlayson: OK, I've got an object that can read int and uint for 8, 16, 24 and 32 bit numbers from a binary file stream. But I cant figure out how to read a float or double. What I want is something like this (these don't work): double | n |

Re: [Newbies] Reading and writing C structs

2008-06-30 Thread David Finlayson
OK, I've got an object that can read int and uint for 8, 16, 24 and 32 bit numbers from a binary file stream. But I cant figure out how to read a float or double. What I want is something like this (these don't work): double | n | n := Float from: (aFileStream next: 32). ^n

Re: [Newbies] Reading and writing C structs

2008-05-24 Thread Randal L. Schwartz
> "David" == David T Lewis <[EMAIL PROTECTED]> writes: David> In addition to the Simon Lewis book that you mentioned, I have found David> "Smalltalk Best Practice Patterns" by Kent Beck to be something you David> will want to read sooner rather than later. It's really worthwhile David> and adm

Re: [Newbies] Reading and writing C structs

2008-05-24 Thread David T. Lewis
On Fri, May 23, 2008 at 10:33:32PM -0700, David Finlayson wrote: > > I am a scientist not a proffesional programmer, > but I've been coding all my life and coding is part of my job. That's > why I am looking into Smalltalk. Can't get much higher level than > this. Besides, I've always wanted to lea

Re: [Newbies] Reading and writing C structs

2008-05-23 Thread David Finlayson
On Fri, May 23, 2008 at 6:17 PM, David T. Lewis <[EMAIL PROTECTED]> wrote: > > Look at the Number class hierarchy (browse hierarchy) and look at the > "instance creation" category on the class side of each of these classes. > That will give you some good tips. If you are dealing with simple data >

Re: [Newbies] Reading and writing C structs

2008-05-23 Thread David T. Lewis
On Fri, May 23, 2008 at 02:10:58PM -0700, David Finlayson wrote: > An instrument I am working with creates a complicated binary file > (memory dumps of C structs). I would like to try reading the file into > Squeak for a cool new project. What's the best way to set up and read > C-based structs and

[Newbies] Reading and writing C structs

2008-05-23 Thread David Finlayson
An instrument I am working with creates a complicated binary file (memory dumps of C structs). I would like to try reading the file into Squeak for a cool new project. What's the best way to set up and read C-based structs and then, once I'm done, to write them back out again (including endianness,