Author Topic: Add, Subtract, Divide, Multiply x from y?  (Read 5911 times)

Jeff

  • Newbie
  • *
  • Posts: 33
Add, Subtract, Divide, Multiply x from y?
« on: January 30, 2011, 11:24:23 PM »
I have two questions to ask and it is about Adding, Subtracting, Dividing and Multiplying numbers:

Question 1:
How can I Add two(2) different fields(e.g. Add field1 from field2) and get the answer in the third field(field3) just by clicking a button?
All these fields and a button must be in the same card.

What is the code that I will place into this button?

Question 2:
How can I Add two(2) different fields(e.g. Add field1 from field2) and get the answer in the third field(field3) just by clicking a button?
field1 and field2 must be in the same card (card1).
Field3 and the button must be in card2

What is the code that I will place into this button?

I've tried and tried but can't figure it out.

Thanks.

JD
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 460
  • Here to help you
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #1 on: January 31, 2011, 07:14:24 AM »
Quote from: "Jeff"
I have two questions to ask and it is about Adding, Subtracting, Dividing and Multiplying numbers:

Question 1:
How can I Add two(2) different fields(e.g. Add field1 from field2) and get the answer in the third field(field3) just by clicking a button?
All these fields and a button must be in the same card.

What is the code that I will place into this button?

You have to place each field into variables before you can performs maths with them.

Code: [Select]
Local a,b

Put field 1 into a
Put field 2 into b

Add a to b
Put b into field 3



For fields on another card - example card 5

Code: [Select]
Local a,b

Put FieldCardFN(5,1) into a
Put FieldCardFN(5,2) into b

Add a to b
FieldCardSet(5,3,b)


Quote from: "Jeff"
Question 2:
How can I Add two(2) different fields(e.g. Add field1 from field2) and get the answer in the third field(field3) just by clicking a button?
field1 and field2 must be in the same card (card1).
Field3 and the button must be in card2

What is the code that I will place into this button?

Code: [Select]
Local a,b

Put field 1 into a
Put field 2 into b

Add a to b
FieldCardSet(2,3,b)
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

Jeff

  • Newbie
  • *
  • Posts: 33
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #2 on: February 01, 2011, 05:49:06 AM »
Sir,

I still can't get the codes right. Everything went right when I start running it, there was no error on the codes.

But when I start inserting the numbers in fields 1 & 2 and clicked the button nothing was showing in field 3.

So this is what I did and please correct me:

In Card1:
I placed 2 fields (fields 1 & 2) and a next button to get me to card 2.

These are the codes I put in fields 1 & 2...
@

Local a,b

Put field 1 into a
Put field 2 into b

Add a to b
Put b into field 3

This is the code button...
@ GotoCard 2

These are the codes I placed in field 3 in card 2....

@

Local a,b

Put FieldCardFN(2,1) into a
Put FieldCardFN(2,2) into b

Add a to b
FieldCardSet(2,3,b)

This is the button that when clicked displays the sum in field 3 in card 2...

@ Add Field 1 to Field 2

Please help, this is how I understand your reply

Thanks

JD
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 460
  • Here to help you
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #3 on: February 01, 2011, 09:40:32 AM »
I'm sorry - its field 1 in card 2 so the code in the button should be:-

Code: [Select]
Local a,b

Put field 1 into a
Put field 2 into b

Add a to b
FieldCardSet(2,1,b)
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

Jeff

  • Newbie
  • *
  • Posts: 33
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #4 on: February 01, 2011, 10:37:21 PM »
Sir,

Field 3 in card 2 showed a zero when I pressed the button

This is the code you gave me to be placed in the button in card 2:
@

Local a,b

Put field 1 into a
Put field 2 into b

Add a to b
FieldCardSet(2,1,b)

Please help, I am really confused now...

Thanks
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 460
  • Here to help you
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #5 on: February 02, 2011, 05:40:40 AM »
For my test example - they assume that button 1, fields 1 and 2 on are card 1, while field 1 is on card 2.

The syntax for the FieldCardSet(p1,p2,p3) is:-

p1 = card where the field is located
p2 = the target field on that card
p3 = the value to put into target field

Note, the numbering of controls on each card is independent from controls on other cards. So it is possible to have fields on different cards each numbered 1 - the field on card 2 does not have to be numbered 3.
By the way, if the target field does not exist then by default HyperNext does not report an error, the command just fails silently.
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

Jeff

  • Newbie
  • *
  • Posts: 33
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #6 on: February 02, 2011, 06:39:36 AM »
Sir,

Thank you very much for the codes. After your last post I'm starting to understand the logic behind this. I think HyperNext is the best to use for creating softwares faster.

By the way is it possible to place the value of field1 into field2 in the same card?

I'm trying it but can't figure this out.

Thanks

JD
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 460
  • Here to help you
Re: Add, Subtract, Divide, Multiply x from y?
« Reply #7 on: February 08, 2011, 10:21:42 AM »
Quote from: "Jeff"
By the way is it possible to place the value of field1 into field2 in the same card?

Yes, just use:-

Code: [Select]
Put field 1 into field 2
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.