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
[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 - Field Focus

Field Focus

Discuss OrbForms Designer and PocketC Architect

Postby trajecto on Sat Feb 01, 2003 1:57 am

I am working on a loan calculator with a built-in numeric keypad.

I'm not going to just have top-down calculations I want the user to be able to choose which field to leave blank (Price, Downpayment, Principal, Interest, years, Payment) and the code will calculate the empty field.

So my issue is how can my program know which field to append values to as the user uses the keyboard? Normally (with eVB) for just one field for example when the user presses "1" the code would read:

fldDownpayment.text = fldDownpayment.text & "1"

So what I want to do is basically:

CurrentFieldWithFocus.text = CurrentFiledWithFocus.text & "1"


Any ideas? Maybe I should just scrap the numeric-keypad - it would be great though!!!

Thanks in advance!
Chris
trajecto
 
Posts: 51
Joined: Wed Aug 21, 2002 1:53 am
Location: USA

Postby trajecto on Sat Feb 01, 2003 2:52 am

I am also getting an error with this code:

fldGenericThree.text = fldGenericOne.text - fldGenericTwo.text;

"Operator supports numeric types only"

How can I fix this?

Thanks!
Chris
trajecto
 
Posts: 51
Joined: Wed Aug 21, 2002 1:53 am
Location: USA

Postby dewey on Sat Feb 01, 2003 4:08 am

UIForm.activefield() returns a pointer to the currently selected field (or null, if a field does not have focus).

UIField.text is a string, and as such you cannot do math operations directly on them. To do math operation you will need to cast them BOTH to ints first:

res.text = (int)a.text - (int)b.text;

or

int ia,ib;
ia = a.text;
ib = b.text;
res.text = ia - ib;
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby trajecto on Sat Feb 01, 2003 4:54 pm

Thanks Jeremy!

Do you have an example of how to use UIForm.activefield()in a case statemnt?

I want to do something like this when someone hits the calculate button:


switch (activefield) {
case price:
do price calculation;
break;
case downpayment:
do downpayment calculation;
break;
case principal;
do principal calculation;
break;
case interest:
do interest calculation;
break;
case NumPayment:
do NumPayments calculation;
break;
case payment:
do payment calculation;
break;
}
trajecto
 
Posts: 51
Joined: Wed Aug 21, 2002 1:53 am
Location: USA

Postby dewey on Sat Feb 01, 2003 6:12 pm

You can only use constants in your case statements - the fields on a form are objects. You will need to do this using if/else statements.

Code: Select all
handler buttonAdd.onselect() {
  UIField* af = mainForm.activefield();
  if (af == &fieldLeft) {
    fieldLeft.insert("5");
  } else if (af == &fieldRight) {
    fieldRight.insert("5");
  } else {
    alert("no field selected");
  }
}
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby FrankG on Sat Feb 01, 2003 11:13 pm

Though this won't help the calculate question, another way to handle the append the keystroke to the text field is to use pointer notation, as in

UIField* af = mainForm.activefield();<br />
af->insert("5");

Pointer notation was very helpful in one of my applications -- and might be to you in another way -- in simulating an array of controls, in my case buttons. Like for the calculator numeric buttons '0' through '9', supposed each was named something like ButN0 through ButN9.

Create an array UIButton *ButN[10] and in startup code do 10 fast assignments of:

ButN[0] = &ButN0;<br />ButN[1] = &ButN1;<br />ButN[2] = &ButN2;<br />etc.

Each onselect routine is simply

ButN0.onselect() {DoKeyPress(0);}<br />ButN1.onselect() {DoKeyPress(1);}<br />etc.

DoKeyPress is

void DoKeyPress(int k) {<br /> ButN[k]->insert(i); //Wish there was asc() and chr()!<br /> accumulator = accumulator*10+k; // or whatever<br />}

Might not suit your needs at all or maybe it's more complicated than it needs to be but I was impressed with how OrbForms handled pointers and OO-ish stuff.

Just rambling & good luck with the project,
Frank
FrankG
 
Posts: 210
Joined: Thu Jan 23, 2003 7:58 pm

Postby trajecto on Sun Feb 02, 2003 5:25 am

Thanks a ton guys!!! Your input really helped. I figured out something really neat here. Look at this little routine for the button "7" Whichever field has the focus it puts a 7 in and concetenates it nicely also.

I first experimented with:
fldPayment.text = (int)mainForm.activefield();
To find the field identities.

Then came up with this:


handler btn7.onselect() {

int x;
x = (int)mainForm.activefield();

switch(x) {
case 4:
fldPrice.insert("7");
break;

case 5:
fldDownPayment.insert("7");
break;

case 6:
fldPrincipal.insert("7");
break;

case 7:
fldInterest.insert("7");
break;

case 8:
fldYears.insert("7");
break;

case 9:
fldPayment.insert("7");
break;
}

}





It works like a charm. A Late night programming breakthrough thanks to you guys!!!
trajecto
 
Posts: 51
Joined: Wed Aug 21, 2002 1:53 am
Location: USA


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 1 guest

cron