Getting my feet wet

Discuss OrbForms Designer and PocketC Architect

Postby Bolan on Wed May 01, 2002 2:13 am

I am very impressed at first glance with OrbForms. But I have a few questions.

Do I understand correctly that variable/objects defined in any function are essentially global to all other functions?

Where is the best place to define high level objects that are going to be used through the program by various event handlers. For instance, is the onopen handler for mainform the best place to declare arrays and initalize them?

What are the limitations of the demo version?

I am trying to write an event handler that changes the contents of one list based on the selection of a second list. To do this my code:

handler ListTwo.onselect()
{

string values[12];

switch (ListTwo.selitem)
{
case 0 : {
Values[1] = "valueA";
Values[2] = "valueB";
Values[3] = "valueC";
Values[4] = "valueD";
ListOne.setitems(12,Values);
ListOne.redraw();
break;
}

Am I on the right track here?
Bolan
 
Posts: 7
Joined: Wed May 01, 2002 2:07 am

Postby dewey on Wed May 01, 2002 3:39 am

Variables defined within a function are local only to that function. However, global variables, functions and object/struct declarations are global to all files following the one in which they are defined.

Using the demo, you cannot run your app on an actual device, and you cannot build standalone apps. Other than that, the demo and full version are the same.

Your code looks about right. However, if you are only setting 4 values, you should pass "4" as the parameter to setitems, rather than "12".
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby Bolan on Wed May 01, 2002 10:47 am

Thanks - I knew about the number of elements being wrong, however I had dummied up the code so you wouldn't have to see my silly application.


I am still unclear on where globals are defined? Maybe that was the real question the whole time.

When you say files that "follow" are you saying that before I can call a function, all predecessor functions have to be defined? How is this "order" determined?

Sorry for the elemental questions, I'm just getting started with this stuff.
Bolan
 
Posts: 7
Joined: Wed May 01, 2002 2:07 am

Postby Ringmaster on Thu May 02, 2002 11:23 am

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I am still unclear on where globals are defined? Maybe that was the real question the whole time.

When you say files that "follow" are you saying that before I can call a function, all predecessor functions have to be defined? How is this "order" determined?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Within a single source file, you must declare a variable or function before you can reference it. So this is good:

int i;

void stuff() {
i++;
}

handler form1.onpenup() {
stuff();
}

But this is not:

handler form1.onpenup() {
stuff();
}

void stuff() {
i++
}

int i;

As far as global variables are concerned, when you open a project in OrbForms, be sure that you can access the Workspace Source pane. Varaibles declared at global scope in files at the top of the pane will be accessible by files below it, but not above it. This is why (even if it's only metaphorical) all gadgets are displayed at the top of the project source list.

You can move modules around in the list (make them build earlier) by right-clicking them in the Workspace Source pane and choosing Move Up/Down.
Ringmaster
 
Posts: 11
Joined: Tue Mar 19, 2002 2:49 am

Postby Bolan on Thu May 02, 2002 12:15 pm

Thanks, thats exactly what I needed.
Bolan
 
Posts: 7
Joined: Wed May 01, 2002 2:07 am


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 4 guests

cron