Wow, what are you doing?
Several things go wrong here:
1. You're not using global data.
Char *GlobalRCASel;
is present within a function, which means it is just a local variable.
Move it to
outside the function block, at the start of the .c file.
(Note that using global vars is not a good coding practice, and should be
avoided if possible)
2. You're trying to copy data to somewhere in the memory, but you don't know
were.
Your variable isn't a string, but a pointer, which points to something,
but you
don't know were to. If you run this on a real Palm, you might corrupt
memory of
other programs and possibly be forced to hard-reset your Palm.
Solutions to the second problem: use an array of characters, or allocate the
memory to
the pointer.
The stuff below might be better discussed in some ...lang.c newsgroup.
Ronnie
"R�gis Daniel de Oliveira" <[EMAIL PROTECTED]> schreef in bericht
news:109620@palm-dev-forum...
>
> Hy!
>
> I tried the code bellow, but it's no working
>
> Can anybody tell me why?
>
> This is the code of where I'm trying to call the variable:
> //////////////////////////////////////////////////////
> FILE global.h
> #ifndef GLOBAL_H_INCLUDED
> #define GLOBAL_H_INCLUDED
>
> //VAriavel Global - Nome do RCA Selecionado
> extern Char *GlobalRCASel;
>
> #endif
>
>
> //////////////////////////////////////////////////////
>
> THE FISRST FORM - WILL SET THE VARIABLE VALUE:
>
> #include <PalmOS.h>
> #include "SIR_Palm.h"
> #include "SIR_Palm_res.h"
> #include "list_manip.h"
> #include "frmRCAS.h"
> #include "global.h" //INCLUDE GLOBAL.H
>
>
////////////////////////////////////////////////////////////////////////////
> /
> //Define variaveis de acesso ao banco de dados p/ uso no carregamento de
> RCAS
> //#define DB_NAME "SIRRca"
> #define DB_CARDNO 0
> #define DB_CREATOR 'SIRP'
> #define DB_TYPE 'DATA'
>
> DmOpenRef dbPtr;
>
>
////////////////////////////////////////////////////////////////////////////
> /
> //Define opcoes sobre a lista...
>
////////////////////////////////////////////////////////////////////////////
> /
> #define MAX_LIST_ENTRIES 200
> Char* listEntries[MAX_LIST_ENTRIES];
> UInt16 nextListEntry = 0;
>
>
////////////////////////////////////////////////////////////////////////////
> static Boolean frmRCAS_cmdAvancar_OnSelect(EventPtr event)
> {
>
> // Insert code for cmdAvancar
> FormType *form;
> ListPtr lptr;
>
> //Ponteiro p/ a variave Global
> Char *GlobalRCASel;
>
> form = FrmGetActiveForm();
> lptr = (ListPtr)FrmGetObjectPtr(form, FrmGetObjectIndex(form, lstRCAS));
>
> //Copia o nome do RCA para a variavel Global
> //SET THE VALUE OF THE VARIABLE - PALM GENERATES A ERROR...
> StrCopy(GlobalRCASel,LstGetSelectionText(lptr,LstGetSelection(lptr)));
>
> //Chama o form;
> FrmGotoForm(frmRCAInfo);
> return true;
>
> }
>
>
>
>
>
> "Matthew Bevan" <[EMAIL PROTECTED]> escreveu na mensagem
> news:109602@palm-dev-forum...
>
> Done and done... this is a three-file example:
>
> --FILE 1: Globals.h--
> extern Char *bob;
>
> --FILE 2: Form1.c-- (variable defined here)
> #include "Globals.h"
>
> Char *bob = "This is a global variable.";
>
> // access bob as you would any normal variable - anywhere
>
> --FILE 3: Form2.c-- (variable used here)
> #include "Globals.h"
>
> // access bob as you would any normal variable - anywhere
>
> --END--
>
> Hope that helps. It's usually a good idea to keep the global variable
> definitions grouped in some reasonable manner (i.e. keep all the VFS vars
> together, all of the current state ones together, etc.)
>
> --
> Matthew (Darkstorm) Bevan [EMAIL PROTECTED]
> Margin Software, NECTI. http://www.marginsoftware.com
> Re-inventing the wheel, every time.
>
> - Afternoon, n.:
> That part of the day we spend worrying about how we wasted the
> morning.
>
>
>
>
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/