Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Calculated Fields in follow on Forms
Page 1 of 1

PostPosted: Tue Apr 04, 2006 11:47 pm
by B0yBlue
I am new to OFB and am writing my first apps.

I am writing an application with a number of forms with calculations
fields that affect following forms.

Form 1 is an Intro/Menu Form.

Form 2 has data entry into some fields, it also calculates some fields from the data entry.

Form 3 contains further calculations based on the out puts of 2 fields from Form 2.

The problem I have is this:
How do I reference the data from Form 2 into Form 3so that the calculations can continue?

Using the unique field name does not work.

Is there a text pre-cursor to the unique field name that would identify the form (in the same way you would with a spreadsheet)?

Any help would be appreciated.



Regards

Steve

PostPosted: Wed Apr 05, 2006 1:01 am
by dewey
You cannot access the fields/controls of any form but the current form (since the controls don't exist when the form is open). You need to save the data into variables before closing the form.

PostPosted: Wed Apr 05, 2006 9:35 am
by B0yBlue
Dewey,

Thanks for the quick reply, but I am still struggling.

In Form 2 I have a calculated field called:
NumPC

Before closing Form 2 and moving to Form 3 I saved the data from field NumPC as a variable like this:

int VarNumPC = NumPC.text;

In Form 3 I have the following fields:
CallsPerPC
TotalCalls

CallsPerPC is user entered.
TotalCalls is a calculation of NumPC from Form2 and CallsPerPC from Form3.
When I do this:

int VarCallsperPC = CallsPerPC.text;
TotalCalls.text = VarCallsperPC*VarNumPC;

I get the error messgae undeclared identifier.

Can you tell me where I am going wrong here. Apologies if this all seems a bit basic, but I am a complete beginner to this.




Regards

Steve

PostPosted: Wed Apr 05, 2006 10:01 am
by FrankG
Your statement

int VarNumPC = NumPC.text;

declares VarNumPC within the routine in which you have that line. It is locally declared and therefore can be seen only by code within that routine. You need to declare it globally by moving the int VarNumPC; outside of any routines. Probably near the top of the code in your project.oc file.

HTH,
Frank

PostPosted: Wed Apr 05, 2006 10:34 am
by B0yBlue
Frank,
I did as you suggested and moved "int VarNumPC;" to the project.oc
file. I placed it into the struct AppPrefs thinking that as the application begins, this variable would be defined. The code is here:

// application code

// The saved state of your application is represented
// by the members of this structure
struct AppPrefs {
int data;
int VarNumPC;
};

AppPrefs appPrefs;

handler app.onstart() {





Preferences prefs;
// load the preferences
prefs.get(app.creator, false, &appPrefs, typeof(appPrefs), 1);


// load the main form
mainForm.load();
}

However, when I refer to VarNumPC on other forms I get the error message undeclared indentifier.
Is there a step I am missing on the follow on forms?


Regards

Steve

PostPosted: Wed Apr 05, 2006 11:07 am
by FrankG
Steve,

I'm not sure why you put the declare in the AppPrefs struct unless you're planning on saving / restoring the NumVarPC value via the program's preference record.

If so, then because it's a member of the structure, you have to refer to it as a fully qualified name like:
"the structure name" <dot> "the member data name", as in, appPrefs.NumVarPC.

You might think the structure *is* named AppPrefs. The struct <i>definition</i> has that name. The structure definition really doesn't exist other than as a concept of what the structure would look like in case you ever declare one. Turns out you did declare one called appPrefs. So the structure with the structure definition of AppPrefs is called appPrefs. Therefore accessing the data item you want is appPrefs.VarNumPC.

BUT -- if you don't want the variable in the prefs structure, simply move it below / outside the struct definition and refer to it by its birth name: VarNumPC.

You might want to find an intro C manual to help you get the hang of C variable definitions to really take advantage of structs, unions (C, not labor), local and global variables. It's good clean fun.

HTH,
Frank

PostPosted: Wed Apr 05, 2006 11:29 am
by B0yBlue
Frank,

Thanks for taking the time to read my questions and reply its appreciated.

Its a shame that even though the fields and variables have unique names, that they cannot be referenced globally across all forms without additional coding.

I will keep at it until I get it working.

Regards

Steve

PostPosted: Wed Apr 05, 2006 11:38 am
by FrankG
> Its a shame that even though the fields and variables have
> unique names, that they cannot be referenced globally

Well it's actually kind of useful to have variables globally visible or not -- regardless of whether they're unique.... just something to get used to, I guess.

Good luck with it all,
Frank

PostPosted: Wed Apr 05, 2006 6:06 pm
by B0yBlue
Frank,

I took your advice and read through a bunch of tutorials on C programming. Along the way I have solved my problem. Its not very elegent, but it does work.

First on form 2:

setclip(NumPC.text);

Then on Form 3:

#define NUMPC getclip();

Its taken me all day just to use the clipboard function! However, the good news is that it only required 2 lines of code to move a calculated field from one form to another.

The limitation of course is that this only allows 1 variable to be placed into a follow on form. I need to move more than 1.

Regards

Steve

PostPosted: Wed Apr 05, 2006 9:38 pm
by nmc
> The limitation of course is that this only
> allows 1 variable to be placed into a follow
> on form. I need to move more than 1.

Simply try this:

1. find this place in your code:
struct AppPrefs {
int data;
};

2. Add lines like this before or after the struct-definition:
int VarNumPC;
int AnotherVar;
int YetAnotherVar;

3. use those variables in all your forms

PostPosted: Thu Apr 06, 2006 8:59 pm
by B0yBlue
Hey NMC,

I tried it and it works great. Thanks for the help. This has helped out a lot and saved a lot of head scratching.

Regards

Steve

Regards

Steve