define field

hi,
in a form I have three fields: A (number); its value = 2006
B (number); its value= 5
C (number) its value must be the value of the field A and value of the field B, then = 20065; I do not succeed to set up the calculation.
I have tried with C = A && B but it is mistaken. How it must be?

can you help me?
thanks and regards

Giovanni

giota:
hi,
in a form I have three fields: A (number); its value = 2006
B (number); its value= 5
C (number) its value must be the value of the field A and value of the field B, then = 20065; I do not succeed to set up the calculation.
I have tried with C = A && B but it is mistaken. How it must be?

can you help me?
thanks and regards

Giovanni

Giovanni, my suggestion is you take a good look at the documentation (you can find all the pdf on the Servoy Website, starting from this link:
http://www.servoy.com/generic.jsp?mt=39 … omy_id=596
); especially, if you come from filemaker, the excellent Guide written by Bob Cusick (http://www.servoy.com/docs/ServoyAdvProgGuideFMP.pdf).

Anyway, since Servoy’s scripting language is Javascript, the concat operator is not “&&” but “+”
(“&&” stands for “AND”)

Ciao

Riccardino , thanks for the kind answer. I had already tried the +. In effects it works, but it gives back the sum of the fields A and B. My attempt was to obtain, in field C, the contents the A and B (es: A=32, B=5, in the calculated C would have to appear 325. However, I’m in possession of the optimal handbook that you me councils, but I have not found that it could help me. Can you give me the page of handbook, where is the solution of my question? I’m accustomed to search before asking help and councils. I am 58 years old and I try to amuse myself, learning new things, but if in the forum of Servoy the helps and the councils are not given to the new peoples (not for job), ask excuse to you and I will limit myself to read only. Thanks for your interest still.
Giovanni

Hi Giota –

You are trying to treat these three fields as text characters. And any time you wish to concatenate values (rather than perform mathematic operations on them) you would do best to define those columns as text type rather than number type. The only reason you would define these columns as numbers would be if they are used predominantly in mathematical operations, but in the example you give you are treating the field values as text (two “strings” that you wish to “string together”).

You have two ways to go with what you are attempting here:

  1. Define the two fields and the calculation as text, not numbers. Then write the calc formula as:

return fieldA + fieldB;

  1. If you really need these fields to be treated as numbers, leave the definitions as number type, and write the calc formula like this to coerce the numeric data type into strings:

return fieldA.toString() + fieldB.toString();

hth,

kazar

Thanks for your answer, kazar; it is all clear now.
Regards
Giovanni

giota:
Riccardino , thanks for the kind answer. I had already tried the +. In effects it works, but it gives back the sum of the fields A and B. My attempt was to obtain, in field C, the contents the A and B (es: A=32, B=5, in the calculated C would have to appear 325.

Since Ilyse already indicated you the right approach much better than I can do, I’ll only add a few suggestion to help you having even more fun with Servoy.

giota:
However, I’m in possession of the optimal handbook that you me councils, but I have not found that it could help me. Can you give me the page of handbook, where is the solution of my question?

When I moved to Servoy, I found very helpful the JAVASCRIPT PRIMER section. In your case, you can find some example on page 85.
The other good news are that, since Servoy uses Javascript as programming language, you can find a lot of books and free articles on the subject that will help you to understand the basis. If you’re interested, I’ll be glad to give you some titles and links.

giota:
I’m accustomed to search before asking help and councils. I am 58 years old and I try to amuse myself, learning new things, but if in the forum of Servoy the helps and the councils are not given to the new peoples (not for job), ask excuse to you and I will limit myself to read only.

Giovanni: did you have the feeling that new people are ignored on this forum?
I only suggested you read the manual because you didn’t mention the fact that you already tried the “+” operator and you was having a string related problem. Reading your first question, I understood you were having difficulties with the base concepts of Javascript: that’s why I suggested to read the documentation, where the use of operators is clearly explained.

People of this forum are always trying to help new users to enjoy Servoy: the problem is that sometimes is difficult to understand where the real problem is…

Have fun with Servoy

PS: In case you don’t know, there’s also an italian forum. If you want to join it, you can subscribe at this link
http://forum.servoy.it/