pass pointer of Preferences structure to gadget

Discuss OrbForms Designer and PocketC Architect

Postby kac on Tue Jan 07, 2003 6:21 pm

I am having trouble passing a pointer of my preferences structure to a gadget. Run into trouble with the type in the parameter list.

Can anyone give an example of the correct syntax?
Posts: 18
Joined: Thu Oct 17, 2002 12:12 pm

Postby design4use on Wed Jan 08, 2003 12:47 am

One possible cause for problems is that global (app scope) variable are not seen by the template code that defines the gadget. However an code related to an instance of that gadget on a form can 'see' the variable. But in order to help you you really need to be more specific in describing your case.
Posts: 128
Joined: Fri May 10, 2002 3:31 pm

Postby kac on Wed Jan 08, 2003 11:45 am

Thanks for your response design4use,

I'll try to be brief but provide more info....

I define my preferences and create an instance appPrefs. I define a pointer to this instance pappPrefs using AppPrefs* pappPrefs=&appPrefs.

When I try to define a function parameter to pass this pointer it requires a type definition. It will not accept struct* as the type, typeof(&appPrefs) doesn't work. I'm not sure what type to use for the pointer variable I want to pass.
Posts: 18
Joined: Thu Oct 17, 2002 12:12 pm

Postby jims on Thu Jan 09, 2003 5:16 am

Won't this work?

void funcName ( AppPrefs* funcAppPrefs );
Posts: 34
Joined: Wed May 22, 2002 4:01 pm
Location: USA

Postby kac on Thu Jan 09, 2003 11:35 am


The code looks like this:
void myGadget.ondraw(AppPrefs* pappPrefs)

The error I get when trying to build is:
MyGadget.oc(24 ): type name expected

I think the problem is the function is inside a Gadget vs. in a normal source file. Perhaps even that the Gadget source comes before the regular source files (I'm not sure).

I can pass references to structures within normal source of a program, the Gadget cannot see global variables.

The help in Orbforms defines the different pointer types and lists struct* as one of them, however the build gives an error when you define struct* as a parameter of a function. This is where I am confused.

I noticed in the PocketC forum this subject discussed and the moderator stating that PocketC does not support structure pointers. I would assume the same for Orbworks except in the help text for Pointers it specifically mentions struct* as a type. This is an exert from the help on pointers --- <i><b>"A pointer can be used with only one value type (int, string, struct, etc.)"</b></i>
Posts: 18
Joined: Thu Oct 17, 2002 12:12 pm

Postby cao on Thu Jan 09, 2003 9:15 pm

* Gadget files are compiled before the rest of files.
* If you defined an object let us call apppref in an .oc file, and
declared a method in your gadget file that takes this appref.
The compiler will complain since it processes the gadget file first, and it doesnot know the type of apppref yet.

You can try to move apppref code into gadget file, and see if that solved problem.

Usually I would recommend to keep gadget method generic and it will help you move this gadget around in different apps. If the gadget takes special objects as inputs, it would make it difficult to reuse it later.
Posts: 60
Joined: Tue Dec 05, 2000 4:11 am
Location: USA

Postby kac on Fri Jan 10, 2003 11:32 am


Thanks for the response. I can pass a pointer to the individual field (I think) and solve it this way.

Posts: 18
Joined: Thu Oct 17, 2002 12:12 pm

Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 2 guests