--- Benjamin Brazil wrote:
> A simple question really, but I can't seem to find how to do it.
> How do you declare a global string which is created in one from and
> can be accessed in another form.

This question would be easy to answer if we knew what language and
compiler you are using.  Kind of hard to say otherwise.

In general, a global variable is declared outside of and prior to any
function that uses it.  If you are using C and all of your functions
are in one file, for example, then here is how to do it:

// near the top of your file
static Char aString[30];

static Boolean OneFormHandleEvent( EventPtr eventP )
{
  Boolean handled = false;
  FormPtr frmP = FrmGetFormPtr( OneForm );

  switch( eventP->eType ) 
  {
    case frmOpenEvent:
      MainFormInit( frmP );
      FrmDrawForm( frmP );
      StrCopy(aString, "some string");  // save something in aString
      handled = true;
      break;
    // other cases, etc.
    default:
      break;
  }
  return handled;
}

static Boolean TwoFormHandleEvent( EventPtr eventP )
{
  Boolean handled = false;
  FormPtr frmP = FrmGetFormPtr( TwoForm );

  switch( eventP->eType ) 
  {
    case frmOpenEvent:
      MainFormInit( frmP );
      FrmDrawForm( frmP );
      WinDrawChars(aString, StrLen(aString), 10, 20);  // use aString
      handled = true;
      break;
    // other cases, etc.
    default:
      break;
  }
  return handled;
}


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

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

Reply via email to