Home » Developer & Programmer » Forms » simple calculator in oracle form builder
simple calculator in oracle form builder [message #643134] Wed, 30 September 2015 01:27 Go to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
em new user in oracle form builder so i need some help to make my own simple calculator with using of code in pl sql.
so i want to make a calculator as like in cell phone or laptops so please guide me as soon as possible...

i want to add two number %like 2+2=4 but when i enter the number 2 then add a add button(this is not show in the text item but that + sign) then 2 then equal button that isi want to add two number %like 2+2=4 but when i enter the number 2 then add a add button(this is not show in the text item but that + sign) then 2 then equal button that is also not show in text item but sum up and answer show in another text item 4. please reply me as soon as possible. also not show in text item but sum up and answer show in another text item 4. please reply me as soon as possible.
Re: simple calculator in oracle form builder [message #643146 is a reply to message #643134] Wed, 30 September 2015 08:34 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Try this: https://www.google.com/?gws_rd=ssl#q=oracle+forms+calculator&safe=active
Re: simple calculator in oracle form builder [message #643180 is a reply to message #643146] Thu, 01 October 2015 01:52 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
i'm student so i just wannt some help in code when i press the button of equal. then answer will be display
my block name is cal_block and my text_item is inputval
Re: simple calculator in oracle form builder [message #643192 is a reply to message #643180] Thu, 01 October 2015 03:04 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You'll need additional items to store the original number and mathematical function being used, they don't have to be on the screen.
Then I'd use execute immediate to do the maths - select [calculation] from dual.
Re: simple calculator in oracle form builder [message #643198 is a reply to message #643192] Thu, 01 October 2015 03:18 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
DECLARE
RESULT1 NUMBER;

BEGIN

:GLOBAL.VALUE1 := :result;

IF :GLOBAL.OP1 = '+' THEN
RESULT1 := :GLOBAL.VALUE1 + :GLOBAL.VALUE2;
:result := RESULT1;
:GLOBAL.VALUE1 := :result;
:GLOBAL.OP1 := '=';

ELSIF :GLOBAL.OP1 = '-' THEN
RESULT1 := :GLOBAL.VALUE2 - :GLOBAL.VALUE1;
:result := RESULT1;
:GLOBAL.VALUE1 := :result;
:GLOBAL.OP1 := '=';

END IF;


END;


what is problem in this code?
it display error in runtime when i press the equal button and the error is that varible globle.op1 does not exist
Re: simple calculator in oracle form builder [message #643199 is a reply to message #643198] Thu, 01 October 2015 03:22 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You haven't run any code that would create the global, so it gets to the IF statement and fails at that point.
I'd just use datablock items rather than globals.
Re: simple calculator in oracle form builder [message #643200 is a reply to message #643199] Thu, 01 October 2015 03:23 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Also that variable is a waste of time just assign the result to :result directly.
Re: simple calculator in oracle form builder [message #643214 is a reply to message #643200] Thu, 01 October 2015 05:38 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
i need +,_,equal button code...
Re: simple calculator in oracle form builder [message #643216 is a reply to message #643214] Thu, 01 October 2015 05:41 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
i want code of calculator which is like used in laptop...
Re: simple calculator in oracle form builder [message #643217 is a reply to message #643216] Thu, 01 October 2015 05:41 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
without any sql query
Re: simple calculator in oracle form builder [message #643219 is a reply to message #643217] Thu, 01 October 2015 05:47 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
naihaasif07@gmail.com wrote on Thu, 01 October 2015 11:38
i need +,_,equal button code...


For anyhting other than = you'd just store the mathematical symbol defined by the button in an item.

naihaasif07@gmail.com wrote on Thu, 01 October 2015 11:41
without any sql query

Why not? It allows you to skip having lots of IFs, otherwise you've already got a start of the code you need.
Re: simple calculator in oracle form builder [message #643316 is a reply to message #643219] Mon, 05 October 2015 00:18 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
i want to make a fraction calculator help me how i made?
Re: simple calculator in oracle form builder [message #643319 is a reply to message #643316] Mon, 05 October 2015 01:41 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
DECLARE
ans NUMBER;
a number;
b number;
BEGIN

a := :result;

IF operator = '+' THEN
ans := a + b;
:cal_block.result := ans;
a := :result;

end if;

END;

this code i used in add button but at the runtime this button does not work...what is mistake in this code guide me
cal_block is my block name and result is my display item.
Re: simple calculator in oracle form builder [message #643322 is a reply to message #643319] Mon, 05 October 2015 02:40 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?

What value do you think b has in that code?
Re: simple calculator in oracle form builder [message #643323 is a reply to message #643322] Mon, 05 October 2015 03:07 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
b is the second value to calculate
Re: simple calculator in oracle form builder [message #643324 is a reply to message #643323] Mon, 05 October 2015 03:07 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
And where do you assign that second value to b in the code?
Re: simple calculator in oracle form builder [message #643325 is a reply to message #643324] Mon, 05 October 2015 03:09 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
if i assign then b then i press + button they show add same value
Re: simple calculator in oracle form builder [message #643326 is a reply to message #643325] Mon, 05 October 2015 03:10 Go to previous messageGo to next message
110165077
Messages: 11
Registered: September 2015
Junior Member
means i press 2 and then add button it show me ans 4
Re: simple calculator in oracle form builder [message #643328 is a reply to message #643326] Mon, 05 October 2015 03:22 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
How does that answer my question?
Re: simple calculator in oracle form builder [message #643342 is a reply to message #643328] Mon, 05 October 2015 10:54 Go to previous message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Why don't you simply take one of the examples listed in the Google search URL I provided and look at how they developed their Calculator Form. This should show you how you can write yours...
Previous Topic: Communication form Serial / Parallel port via Oracle Forms
Next Topic: How i want to call form from tree menu ???
Goto Forum:
  


Current Time: Tue Apr 23 18:20:22 CDT 2024