Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by Scott R Violet
Wed, 08 Apr 1992 02:35
Writing a Storage Object
Author: Scott R Violet
Date: Wed, 08 Apr 1992 02:35
Date: Wed, 08 Apr 1992 02:35
22 lines
1447 bytes
1447 bytes
Hi,
Lately I have been playing around with Storage objects and have
encountered a few problems. So, hopefully someone out there knows how
to use them and would be willing to help. First off if I had the following
structure
struct test {
int aTestInt;
int arrayTest[25][3];
};
Would the descriptor string be "{i[25[3i]]}"?
Writing the object to a NXTypedStream seems to go ok. But then when
I try to read it back in I get a bus error. When you want to read back
in the stream, how should you initialize the object? I have tried it
with just testStorage = [[Storage alloc] init]; but that doesn't seem
to work. And I have also tried initialiving it the same way that I did
with the first, with an initCount..., but that doesn't seem to work either.
In both cases I get a Bus error. I am hopping that it is something
simple, anyone have any suggestions?
Thanks in advance,
-Scott Violet (xepo@csd4.csd.uwm.edu)
Re: Writing a Storage Object
Author: Tony Zamora
Date: Wed, 08 Apr 1992 03:34
Date: Wed, 08 Apr 1992 03:34
46 lines
2448 bytes
2448 bytes
In article <1992Apr8.023553.17506@uwm.edu> xepo@csd4.csd.uwm.edu (Scott R
Violet) writes:
> Hi,
> Lately I have been playing around with Storage objects and have
> encountered a few problems. So, hopefully someone out there knows how
> to use them and would be willing to help. First off if I had the following
> structure
>
> struct test {
> int aTestInt;
> int arrayTest[25][3];
> };
>
> Would the descriptor string be "{i[25[3i]]}"?
It is a good idea to use the @encode directive and typeof operator to generate
descriptor strings. @encode(struct test) should give you the correct
descriptor for your structure. If you need the encoding of a variable, you can
use @encode(typeof(variable_name)). This way you never have to remember all
the rules for descriptors (and you don't get hosed if they change).
> Writing the object to a NXTypedStream seems to go ok. But then when
> I try to read it back in I get a bus error. When you want to read back
> in the stream, how should you initialize the object? I have tried it
> with just testStorage = [[Storage alloc] init]; but that doesn't seem
> to work. And I have also tried initialiving it the same way that I did
> with the first, with an initCount..., but that doesn't seem to work either.
> In both cases I get a Bus error. I am hopping that it is something
> simple, anyone have any suggestions?
> Thanks in advance,
> -Scott Violet (xepo@csd4.csd.uwm.edu)
I use code like
storage = NXReadObject(stream); // to read a storage object (Storage *storage)
NXWriteObject(stream, storage); // write a storage object
and that works for me. NXReadObject should allocate the memory for the object,
so you shouldn't have to do anything special.
Tony
--
Tony Zamora
Department of Computer Science, Indiana University
azamora@cs.indiana.edu
"They thought it was love, but it was only the caffeine."
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads