Basics in Lotus Notes

i just started learning notes last wk, so you sould imagine how little i know.... here's my problem, how do i convert numbers entered in a textbox to words (which should also be shown in a textbox). only formulas should be use, no lotus scripts. Ex. in field1-> 1,100,123.52 the result in field2 should be --> one million, one hundred thousand, one hundred twenty three and 52/100..

tnx in advance!
macjacintoAsked:
Who is Participating?
 
Jean Marie GeeraertsConnect With a Mentor Application EngineerCommented:
8-D
Weekends still exist, do they ? Hope you enjoyed your weekend, I did. Allthough, it's been raing all weekend here in Belgium, I didn't really mind, because I could watch the US Open on TV. (I'm a big tennis fan)
0
 
GunsenCommented:
I dont think i would have used formula lanuage to compute this text. Nope.
Why do u say - no lotus script ??
Is it ment for notes clients or Web ?
0
 
Jean Marie GeeraertsApplication EngineerCommented:
Good question, Gunsen.
If it's for web, I would suggest using JavaScript to translate the numbers into the written text.
If it's for the client, I suggest using LotusScript.
This is just too complicated to do with formula language.
Let us know what you want to do and we can surely help you write the necessary code.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
macjacintoAuthor Commented:
it will be used for notes clients only. we must use formula. i think it would be better if each digit is assigned to each field and process it seperately. ex. 1,234, there should be 4 fields, one for ones, tens, hundreds etc. the processing is done differently. at the end, all the content of the said fields will be concutanated to one field. and also, the maximum allowed is up to billions, so in effect, only 13 characters should be accepted. (this includes the decimal point and the two decimal digit, no comma should be allowed)
0
 
macjacintoAuthor Commented:
it will be used for notes clients only. we must use formula. i think it would be better if each digit is assigned to each field and process it seperately. ex. 1,234, there should be 4 fields, one for ones, tens, hundreds etc. the processing is done differently. at the end, all the content of the said fields will be concutanated to one field. and also, the maximum allowed is up to billions, so in effect, only 13 characters should be accepted. (this includes the decimal point and the two decimal digit, no comma should be allowed)
0
 
macjacintoAuthor Commented:
it will be used for notes clients only. we must use formula. i think it would be better if each digit is assigned to each field and process it seperately. ex. 1,234, there should be 4 fields, one for ones, tens, hundreds etc. the processing is done differently. at the end, all the content of the said fields will be concutanated to one field. and also, the maximum allowed is up to billions, so in effect, only 13 characters should be accepted. (this includes the decimal point and the two decimal digit, no comma should be allowed)
0
 
macjacintoAuthor Commented:
it will be used for notes clients only. we must use formula. i think it would be better if each digit is assigned to each field and process it seperately. ex. 1,234, there should be 4 fields, one for ones, tens, hundreds etc. the processing is done differently. at the end, all the content of the said fields will be concutanated to one field. and also, the maximum allowed is up to billions, so in effect, only 13 characters should be accepted. (this includes the decimal point and the two decimal digit, no comma should be allowed)
0
 
macjacintoAuthor Commented:
it will be used for notes clients only. we must use formula. i think it would be better if each digit is assigned to each field and process it seperately. ex. 1,234, there should be 4 fields, one for ones, tens, hundreds etc. the processing is done differently. at the end, all the content of the said fields will be concutanated to one field. and also, the maximum allowed is up to billions, so in effect, only 13 characters should be accepted. (this includes the decimal point and the two decimal digit, no comma should be allowed)
0
 
Jean Marie GeeraertsApplication EngineerCommented:
What notes version are you using ?
And why do you have to use formula language ?
0
 
macjacintoAuthor Commented:
it will be used for notes clients only. we must use formula. i think it would be better if each digit is assigned to each field and process it seperately. ex. 1,234, there should be 4 fields, one for ones, tens, hundreds etc. the processing is done differently. at the end, all the content of the said fields will be concutanated to one field. and also, the maximum allowed is up to billions, so in effect, only 13 characters should be accepted. (this includes the decimal point and the two decimal digit, no comma should be allowed)
0
 
macjacintoAuthor Commented:
R5....because thats the lesson weve discussed so far
0
 
macjacintoAuthor Commented:
R5....because thats the lesson weve discussed so far
0
 
Jean Marie GeeraertsApplication EngineerCommented:
Ah, so this is a "school exercise".
Let me look into it and get back to you. (This might take a bit of working out)
0
 
GunsenCommented:
I will not do the homework for you, but give u a clue on how to....this is a sample up to 1mill excluding decimals :

ex: num:= 123456;
or num := @TextToNumber( textNum );

numbers := "" : "one" : "two" : "three" : "four" : "five" : "six" : "seven" : "eight" : "nine";
decades := "" : "ten" : "twenty" : "thirty" : "fourty" : "fifty" : "sixty" : "seventy" : "eighty" : "ninty";

digit1 := @Modulo( @Integer( num / @Power(10;0)); 10 );
digit2 := @Modulo( @Integer( num / @Power(10;1)); 10 );
digit3 := @Modulo( @Integer( num / @Power(10;2)); 10 );
digit4 := @Modulo( @Integer( num / @Power(10;3)); 10 );
digit5 := @Modulo( @Integer( num / @Power(10;4)); 10 );
digit6 := @Modulo( @Integer( num / @Power(10;5)); 10 );

t1 := @Subset( @Subset( numbers; digit1+1 ); -1);
t2 := @Subset( @Subset( decades; digit2+1 ); -1);
t3 := @Subset( @Subset( numbers; digit3+1 ); -1) + @If(digit3=0;"";" houndred and");
t4 := @Subset( @Subset( numbers; digit4+1 ); -1);
t5 := @Subset( @Subset( decades; digit5+1 ); -1);
t6 := @Subset( @Subset( numbers; digit6+1 ); -1) + @If(digit6=0;"";" houndred and");

displayString := @If( digit6 + digit5 + digit4 = 0; ""; t6 + " " + t5 + " " + t4 + " thousand ") + t3 + " " + t2 + " " +t1;
0
 
Jean Marie GeeraertsApplication EngineerCommented:
Yep, that's along the line I was think too. I guess you can work it out from there.
0
 
HemanthaKumarCommented:
Here is the whole formula for it , http://www.keysolutions.com/NotesFAQ/howconvert.html

~Hemanth
0
 
macjacintoAuthor Commented:
initially the error "No main or selection expression in formula:" " is displayed, then i added displaystring at the end of the code, and the error was gone. but when i previewed it, it converts the number to words but it doesnt appear in the display field, it appears in the message box (the heading of the said message box is "field contains incorrect value")  so it cant be saved. the data type of the display field is text.

i already added the code for converting up to billions, but the problem is the numbers from 11-19, when i enter 11, what appears in the message box is "ten one"
0
 
Jean Marie GeeraertsApplication EngineerCommented:
InputNumber is the name of the text-field I used to enter a string of numbers to be converted to words.
Check out this part of the formula to translate for numbers below 100 :

Digits1:="zero":"one":"two":"three":"four":"five":"six":"seven":"eight":"nine";
BelowTwenty:="ten" : "eleven" : "twelve" : "thirteen" : "fourteen" : "fifteen" : "sixteen" : "seventeen" : "eightteen" : "nineteen";
Digits2:=" ":"ten":"twenty":"thirty":"fourty":"fifty":"sixty":"seventy":"eighty":"ninety";

@If(InputNumber="";
   "empty field";
   @If(@TextToNumber(InputNumber)<20;
      @If(@TextToNumber(InputNumber)<10;
         @Subset(@Subset(Digits1;@TextToNumber(InputNumber)+1);-1);
         @Subset(@Subset(BelowTwenty;@TextToNumber(@Right(InputNumber;1))+1);-1));
      @Subset(@Subset(Digits2;@TextToNumber(@Middle(InputNumber;@Length(InputNumber)-2;1))+1);-1) + " " + @Subset(@Subset(Digits1;@TextToNumber(@Right(InputNumber;1))+1);-1)))

(I hope this code will look a bit readable, I've tried to indent so you can see the logic of the nested if-statements)

Just add your code to add the extra text to this and you should get it to work fine. Mind you that you will have to reuse this every three digits (you can have for example "thirteen million one hundred and eleven thousand and five hundred and twenty two").
0
 
macjacintoAuthor Commented:
i already edited the code of gunsen, how will i incorporate the 11-19 problem with the said code? i understood it more clearly than the code in the link that hemanth provided.
0
 
Jean Marie GeeraertsApplication EngineerCommented:
Okay, so here's the complete code using the code from gunsen.

num := @texttonumber(InputNumber);

numbers := "" : "one" : "two" : "three" : "four" : "five" : "six" : "seven" : "eight" : "nine";
belowTwenty := numbers : "ten":"eleven":"twelve":"thirteen":"fourteen":"fifteen":"sixteen":"seventeen":"eightteen":"nineteen";
decades := "" : "ten" : "twenty" : "thirty" : "fourty" : "fifty" : "sixty" : "seventy" : "eighty" :
"ninty";

digit1 := @Modulo( @Integer( num / @Power(10;0)); 10 );
digit2 := @Modulo( @Integer( num / @Power(10;1)); 10 );
digit12 := digit1 + (10 * digit2);
digit3 := @Modulo( @Integer( num / @Power(10;2)); 10 );
digit4 := @Modulo( @Integer( num / @Power(10;3)); 10 );
digit5 := @Modulo( @Integer( num / @Power(10;4)); 10 );
digit45 := digit4 + (10 * digit5);
digit6 := @Modulo( @Integer( num / @Power(10;5)); 10 );

t1 := @if(digit12<20;@Subset( @Subset( belowTwenty; digit12+1 ); -1);@Subset( @Subset( numbers; digit12+1 ); -1));
t2 := @if(digit12<20;"";@Subset( @Subset( decades; digit2+1 ); -1));
t3 := @Subset( @Subset( numbers; digit3+1 ); -1) + @If(digit3=0;"";" houndred and");
t4 := @if(digit45<20;@Subset( @Subset( belowTwenty; digit45+1 ); -1);@Subset( @Subset( numbers; digit45+1 ); -1));
t5 := @if(digit45<20;"";@Subset( @Subset( decades; digit5+1 ); -1));
t6 := @Subset( @Subset( numbers; digit6+1 ); -1) + @If(digit6=0;"";" houndred and");

displayString := @If( digit6 + digit5 + digit4 = 0; ""; t6 + " " + t5 + " " + t4 + " thousand ") + t3
+ " " + t2 + " " +t1;

Using this formula "514213" will be translated to "five hundred and fourteen thousand two hundred and thirteen".
0
 
macjacintoAuthor Commented:
here's the code that i used. i added digit6 to digit9 for numbers with more than 6 characters..... i patterned it to the code that you gave. when i entered 514213 the write words is diplayed in the message box(which is another problem bec. instead of appearing in the next field, it appears in the message box), but when numbers without the 11-19 problem is entered (ex.524123), the ones(3) and thousand(4) place is wrong.... and also, how will i add the million for the display? please reply ASAP. tnx!

num:=@TextToNumber(textnum);
numbers:="": "one" : "two" : "three" : "four" : "five" : "six" : "seven"
: "eight": "nine" ;
teens := numbers : "ten": "eleven" : "twelve" : "thirteen" : "fourteen" : "fifteen" : "sixteen" : "seventeen" : "eightteen" :"nineteen";
decades := "" : "ten" : "twenty" : "thirty" : "forty" : "fifty" :  "sixty" : "seventy" : "eighty" : "ninety";

digit1 := @Modulo( @Integer( num / @Power(10;0)); 10 );
digit2 := @Modulo( @Integer( num / @Power(10;1)); 10 );
digit12 := digit1 + (10 * digit2);
digit3 := @Modulo( @Integer( num / @Power(10;2)); 10 );
digit4 := @Modulo( @Integer( num / @Power(10;3)); 10 );
digit5 := @Modulo( @Integer( num / @Power(10;4)); 10 );
digit45 := digit4 + (10 * digit5);
digit6 := @Modulo( @Integer( num / @Power(10;5)); 10 );
digit7 := @Modulo( @Integer( num / @Power(10;6)); 10 );
digit8 := @Modulo( @Integer( num / @Power(10;7)); 10 );
digit78 := digit7 + (10 * digit8);
digit9 := @Modulo( @Integer( num / @Power(10;8)); 10 );
digit10 := @Modulo( @Integer( num / @Power(10;9)); 10 );

t1 := @if(digit12<20;@Subset( @Subset( teens; digit12+1 ); -1);@Subset( @Subset( numbers; digit12+1 ); -1));
t2 := @if(digit12<20;"";@Subset( @Subset( decades; digit2+1 ); -1));
t3 := @Subset( @Subset( numbers; digit3+1 ); -1) + @If(digit3=0;"";" hundred and");
t4 := @if(digit45<20;@Subset( @Subset( teens; digit45+1 ); -1);@Subset( @Subset( numbers; digit45+1 ); -1));
t5 := @if(digit45<20;"";@Subset( @Subset( decades; digit5+1 ); -1));
t6 := @Subset( @Subset( numbers; digit6+1 ); -1) + @If(digit6=0;"";" hundred and");
t7 := @if(digit78<20;@Subset( @Subset( teens; digit78+1 ); -1);@Subset( @Subset( numbers; digit78+1 ); -1));
t8 := @if(digit78<20;"";@Subset( @Subset( decades; digit8+1 ); -1));
t9 := @Subset( @Subset( numbers; digit9+1 ); -1) + @If(digit9=0;"";" hundred and");

displayString := @If( digit9 + digit8 + digit7 = 0; ""; t9 + " " + t8 + " " + t7 + " million ")+@If( digit6 + digit5 + digit4 = 0; ""; t6 + " " + t5 + " " + t4 + " thousand ") + t3 + " " + t2 + " " +t1;

displaystring
0
 
Jean Marie GeeraertsApplication EngineerCommented:
Here's the copy/paste solution until 123456789 :

num := @TextToNumber(InputNumber);

numbers := "" : "one" : "two" : "three" : "four" : "five" : "six" : "seven" : "eight" : "nine";
belowTwenty := numbers : "ten" : "eleven" : "twelve" : "thirteen" : "fourteen" : "fifteen" : "sixteen" : "seventeen" : "eightteen" : "nineteen";
decades := "" : "ten" : "twenty" : "thirty" : "fourty" : "fifty" : "sixty" : "seventy" : "eighty" : "ninety";

digit1 := @Modulo( @Integer( num / @Power(10;0)); 10 );
digit2 := @Modulo( @Integer( num / @Power(10;1)); 10 );
digit12 := digit1 + (10 * digit2);
digit3 := @Modulo( @Integer( num / @Power(10;2)); 10 );
digit4 := @Modulo( @Integer( num / @Power(10;3)); 10 );
digit5 := @Modulo( @Integer( num / @Power(10;4)); 10 );
digit45 := digit4 + (10 * digit5);
digit6 := @Modulo( @Integer( num / @Power(10;5)); 10 );
digit7 := @Modulo( @Integer( num / @Power(10;6)); 10 );
digit8 := @Modulo( @Integer( num / @Power(10;7)); 10 );
digit78 := digit7 + (10 * digit8);
digit9 := @Modulo( @Integer( num / @Power(10;8)); 10 );

t1 := @If(digit12<20;@Subset( @Subset( belowTwenty; digit12+1 ); -1);@Subset( @Subset( numbers; digit1+1 ); -1));
t2 := @If(digit12<20;"";@Subset( @Subset( decades; digit2+1 ); -1));
t3 := @Subset( @Subset( numbers; digit3+1 ); -1) + @If(digit3=0;"";" hundred and");
t4 := @If(digit45<20;@Subset( @Subset( belowTwenty; digit45+1 ); -1);@Subset( @Subset( numbers; digit4+1 ); -1));
t5 := @If(digit45<20;"";@Subset( @Subset( decades; digit5+1 ); -1));
t6 := @Subset( @Subset( numbers; digit6+1 ); -1) + @If(digit6=0;"";" hundred and");
t7 := @If(digit78<20;@Subset( @Subset( belowTwenty; digit78+1 ); -1);@Subset( @Subset( numbers; digit7+1 ); -1));
t8 := @If(digit78<20;"";@Subset( @Subset( decades; digit8+1 ); -1));
t9 := @Subset( @Subset( numbers; digit9+1 ); -1) + @If(digit9=0;"";" hundred and");

displayString := @If( digit9 + digit8 + digit7 = 0; ""; t9 + " " + t8 + " " + t7 + " million ")+@If( digit6 + digit5 + digit4 = 0; ""; t6 + " " + t5 + " " + t4 + " thousand ") + t3
+ " " + t2 + " " +t1;

@If(@IsError(displayString);"";displayString)

I made an error in the parts calculating the first digit when the value is 20 or higher. I should use the digit1 value instead of digit12 value to get the correct word from the string for example. Anyway, I adjusted the code and tested it. It should work fine now.
0
 
Jean Marie GeeraertsApplication EngineerCommented:
The last line is to return the value to the field in case you want to use the formula as the value for a computed field for example. If you don't put this in, you will get an "No main or selection expression in formula" error.
0
 
macjacintoAuthor Commented:
==> Is displayString the name of the computed field?

@If(InputNumber <> 0;@Failure("Amount should not be equal to zero."); @Success);

==> I tried to add this code in the beginning of the program to check if the user entered 0, but when previewed, and i typed 0, the suppossed error message  does not appear.


==> I added this code [cent : = @Left(InputNumber; ".");]  after [num := @TextToNumber(InputNumber);] but this error appears: "Inappropriate (unary) usage of an operator: ';' "
0
 
Jean Marie GeeraertsApplication EngineerCommented:
No displayString is just a variable, the @if-statement at the end will return the value to the computed field. You just put the whole formula in the "Value" event of the computed field.
@Failure and @Success are used in input validation of the field, so they won't do anything when you put them at the start of the formula's.
I have changed the @if at the end to set the result to "zero" if the user entered nothing or "0".

If you want to split the entered value into a part before and after the decimal point, here's the correct syntax :
num:=@TextToNumber(@left(InputNumber; ".");
decimals:=@TextToNumber(@RightBack(InputNumber; ".");

The @IsError function checks if the returned value is an error. If it returns true, I set the field to "Please enter a valid number", but you can put any error message here. If false, the computed result is returned to the field.

I have on my test form a text field, called InputNumber to enter the number to be translated. This field has the following input validation formula :

digits:=@if(@contains(InputNumber;"."); @length(@left(InputNumber;".")); @length(InputNumber));
decimals := @length(@RightBack(InputNumber;"."));
@If(digits>10 | decimals>2;@Failure("Number out of range");@Success);

This way an error will be returned when a number above billions or with more then two decimals is entered.

Here's the complete formula's to be entered to process the entered number in InputNumber, including decimals.
Put these formula's in the "Value" of the computed field you want to use to display the value.

num := @if(@contains(InputNumber; "."); @TextToNumber(@Left(InputNumber; ".")); @TextToNumber(InputNumber));
decimals:=@if(@contains(InputNumber; "."); @TextToNumber(@left(@RightBack(InputNumber; ".");2)); 0);

numbers := "" : "one" : "two" : "three" : "four" : "five" : "six" : "seven" : "eight" : "nine";
belowTwenty := numbers : "ten" : "eleven" : "twelve" : "thirteen" : "fourteen" : "fifteen" : "sixteen" : "seventeen" : "eightteen" : "nineteen";
decades := "" : "ten" : "twenty" : "thirty" : "fourty" : "fifty" : "sixty" : "seventy" : "eighty" : "ninety";

digit1 := @Modulo( @Integer( num / @Power(10;0)); 10 );
digit2 := @Modulo( @Integer( num / @Power(10;1)); 10 );
digit12 := digit1 + (10 * digit2);
digit3 := @Modulo( @Integer( num / @Power(10;2)); 10 );
digit4 := @Modulo( @Integer( num / @Power(10;3)); 10 );
digit5 := @Modulo( @Integer( num / @Power(10;4)); 10 );
digit45 := digit4 + (10 * digit5);
digit6 := @Modulo( @Integer( num / @Power(10;5)); 10 );
digit7 := @Modulo( @Integer( num / @Power(10;6)); 10 );
digit8 := @Modulo( @Integer( num / @Power(10;7)); 10 );
digit78 := digit7 + (10 * digit8);
digit9 := @Modulo( @Integer( num / @Power(10;8)); 10 );
digit10:=@Modulo( @Integer( num / @Power(10;9)); 10 );

decimal1 := @Modulo( @Integer( decimals / @Power(10;0)); 10 );
decimal2 := @Modulo( @Integer( decimals / @Power(10;1)); 10 );
decimal12 := decimal1 + (10 * decimal2);

t1 := @If(digit12<20;@Subset( @Subset( belowTwenty; digit12+1 ); -1);@Subset( @Subset( numbers; digit1+1 ); -1));
t2 := @If(digit12<20;"";@Subset( @Subset( decades; digit2+1 ); -1));
t3 := @Subset( @Subset( numbers; digit3+1 ); -1) + @If(digit3=0;"";" hundred and");
t4 := @If(digit45<20;@Subset( @Subset( belowTwenty; digit45+1 ); -1);@Subset( @Subset( numbers; digit4+1 ); -1));
t5 := @If(digit45<20;"";@Subset( @Subset( decades; digit5+1 ); -1));
t6 := @Subset( @Subset( numbers; digit6+1 ); -1) + @If(digit6=0;"";" hundred and");
t7 := @If(digit78<20;@Subset( @Subset( belowTwenty; digit78+1 ); -1);@Subset( @Subset( numbers; digit7+1 ); -1));
t8 := @If(digit78<20;"";@Subset( @Subset( decades; digit8+1 ); -1));
t9 := @Subset( @Subset( numbers; digit9+1 ); -1) + @If(digit9=0;"";" hundred and");
t10 := @Subset( @Subset( numbers; digit10+1 ); -1) + @If(digit10=0;"";" billion and ");

d1 := @If(decimal12<20;@Subset( @Subset( belowTwenty; decimal12+1 ); -1);@Subset( @Subset( numbers; decimal1+1 ); -1));
d2 := @if(decimals=0;""; " point " ) + @If(decimal12<20;"";@Subset( @Subset( decades; decimal2+1 ); -1));

displayString := t10 + @If( digit9 + digit8 + digit7 = 0; ""; t9 + " " + t8 + " " + t7 + " million ")+@If( digit6 + digit5 + digit4 = 0; ""; t6 + " " + t5 + " " + t4 + " thousand ") + t3 + " " + t2 + " " +t1 + d2 + d1;

@If(@IsError(displayString); "Please enter a valid number"; @if(@TextToNumber(InputNumber)=0;"zero";displayString))


This should give you a copy/paste solution for your problem. If you need any more help, just let us know.
0
 
HemanthaKumarCommented:
Anyone there who tried out the link that I provided, and is it really that bad !
0
 
Jean Marie GeeraertsApplication EngineerCommented:
Just checked it out and it looks clear enough to me, but I think I'll still want the points for all the work I put into it ;-)
I'd even be upset if I don't get an A for this (Big smile)
0
 
macjacintoAuthor Commented:
actually, i havent tried the code yet jerrith bec its weekends here, and i dont have lotus notes installed at home. so maybe it will be two days from now before i try it and award the points to you =)

if there's only a way that i could increase the points (and give u an A+) to show how much i appreciated your help, tnx again for the prompt reply, but i wont be awarding the points now bec. as ive said i havent tried it yet =)
0
 
GunsenCommented:
bugger
0
 
macjacintoAuthor Commented:
Thanks a lot!
0
 
Jean Marie GeeraertsApplication EngineerCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.