You're right about the global variables.  I cut and pasted data from the
vicinity of the global variables instead.

As I've used structures in the past, I declare the structure, then
instantiate an instance of it, which associates that instance with a
variable name.

I then can reference the member variables of the structure by associated
them with the instance of the structure.

I've tried:

TransStruct* aStructure;
aStructure->Ground[0]='u';

This compiles but creates the error message regarding accessing global
variables when I actually call the function under the emulator.

If I comment out the second of the two lines, the code run's fine,
apparently accepting the other data inputs associated with the structure's
variables.

----- Original Message ----- 
From: "Logan Shaw" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[email protected]>
Sent: Friday, November 04, 2005 3:16 PM
Subject: Re: I hate to ask


> Del Ventruella wrote:
> > GLOBAL VARIABLES
> >
> > typedef struct {
> >  char Name[10];
> >  char IDorY[2];
> >  UInt16 ANUM;
> >  } TransStruct;
> > typedef TransStruct   TransStructType;
> > typedef TransStruct*  TransStructPtr;
>
> None of these are global variables.  They're all type declarations.
>
> > DmOpenRef gTdata;
>
> Now that's a global variable.
>
> > SUBROUTINE TO GET DATA FROM FIELDS ON FORM
> > AND ENTER INTO A STRUCTURE TO LATER BE STORED
> > IN A RECORD
> >
> > Err TrFormGet(TransStruct* aRecord)
> > {
> > FormType* frmP = FrmGetActiveForm();
> > Err err=0;
> > Char* Text;
> > TransStruct* aStructure;
> > Char* IntegerT = (Char*) MemPtrNew(maxStrIToALen);
> > UInt16 test;
> >
> > //Get pointer to field into which data is to be placed
> > FieldType * field = (FieldType*)GetObjectPtr(TName);
> > //get data from record structure passed to function
> > aRecord->IDorY[0]='u';
>
> You haven't given any information about the value of the
> aRecord pointer, which was ultimately the question.  If
> this pointer doesn't point to a valid instance of a
> TransStruct, then you will probably get a crash.
>
> Incidentally, your typedefs above are a bit redundant.  It
> would be simpler to do this:
>
> typedef struct TransStruct {
>     char Name[10];
>     char IDorY[2];
>     UInt16 ANUM;
> } TransStructType;
> typedef TransStructType* TransStructPtr;
>
> However, what you have right now won't cause a crash of course.
>
>    - Logan
>
> -- 
> For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/
>

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to