Newbie on lotusscript: Help on my button to times value by 3%

What I want is whenever I click this button, it will taka value from yearFieldValue, times with 1.03, and input into fieldA (which is next year value), and FieldA will times with 1.03, and input into Field B(which is next 2 years data). This is to facilitate forecast of expenses, when inflation is usually around 3%. HOwever, I got errors with this script.

Sorry, I am new in Lotus Script, I am learning just via trial and error, I tried to read the help but still is very confuse on the concepts on lotus script. Thus, any help is appreciated.

Perhaps eventually I will learn about the script function.

Any help is welcome

Sub Click(Source As Button)

’ Function takes a double value and returns the value with an additional 3 percent’

Function

addThreePercent = yearFieldValue * 1.03 ' decimal equivalent of 3 percent

End



Dim tempDouble1, tempDouble2 As Double

tempDouble1 = addThreePercent(Cdbl(document.fieldA(0)))

tempDouble2 = addThreePercent(Cdbl(document.fieldb(0)))

End Sub

Subject: Newbie on lotusscript: Help on my button to times value by 3%

If you’re getting an error it helps to say what it is. Also, I would encourage you to take a LotusScript class. In a few days you could get answers to about 99% of the questions you have been asking.

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

Error message: line 4: unexpected end of line, expected identifier.

Really appreciates your help. No classes available at my area, so me have to try learn myself. still working on it though…

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

And what’s on Line 4? Turn on the LotusScript debugger and see where it stops.

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

Sub Click(Source As Button)

’ Function takes a double value and returns the value with an additional 3 percent’

Function

The word function in above is in red font, it is the 4th line. Really appreciates your help, hopefully, I’ll pick up fast after this.

Even books on Lotus script is difficult to get where I am staying.

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

You have to name a Function, this is covered in the Domino Designer Help.

IBM provides a lot of free resources on their RedBooks website: http://www.redbooks.ibm.com/portals/Lotus. There are online LotusScript courses available, too, such as these: TLCC Course Catalog for Notes and Domino technical courses.

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

thanks, will look into it. But don’t think I can afford it, as I am only learning script for my own know how currently. can you please just give example of function, just for this one? I will try to check help and understand the rest myself. Sorry to keep on trouble you Charles.

Cheerio.

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

No, I won’t. This forum is not a substitute for reading the help. Help yourself and others will be more willing to help you.

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

Perhaps a shade harsh IMHO

A function has to be named in the function definition and needs a return value of the function name. It also sits outside of the sub and needs a return type. Haven’t compiled the code below but it should be pretty close…

Sub Click(Source As Button)

Dim tempDouble1, tempDouble2 As Double

tempDouble1 = addThreePercent(Cdbl(document.fieldA(0)))

tempDouble2 = addThreePercent(Cdbl(document.fieldb(0)))

End Sub

Function addThreePercent(yearFieldValue as Double) As Double

addThreePercent= yearFieldValue * 1.03 ’ decimal equivalent of 3 percent

End Function

Now go back to the help and try to see how it works!

hth

Pete

Subject: I understand Charles’ frustration…

Pete,

I believe Charles is frustrated by what appear to be an influx of posts from developers who know nothing about LS, or programming theory in general and post questions to the forum that are indicative of the fact that the users have not bothered to check the help or search the forum. Most of these new programmers simply take things from the out of the box databases and attempted to modify the code to suit their needs (which in my estimation is a bad way to try and use the product.)

Charles is right…there really is no excuse for not consulting the help first–the Help page for Functions is quite robust. I could understand if Will had come and posted that he had read the help and was having issues…but the error he was reporting made it obvious that he had not read the help, since it was erroring because he was trying to pass a parameter to a function that didn’t accept a parameter (my own reading of the help indicated that you don’t HAVE to specify a return data type, but to not do so is bad programmatic form, I’d say.)

And also, claiming there are no classes is kind of lame as well. There are plenty of online options, as Charles was nice enough to point out.

just my 2 cents.

brandt

Subject: RE: I understand Charles’ frustration…

I agree with Charles (and also Brandt)

It can be frustrating to help someone who is posting questions in a drip-feed manner. Newbies posting… please never feel like you are giving too much information. Error codes, error lines, post your code, explain what you are trying to achieve.

In my experience, I find 99.9% of people on here polite, courteous, willing to give their free time to discuss problems/options/best practices. In some cases, in the face of extreme provocation/goading (!). I am always in-debted to people helping me out when my brain decides to go on holiday :slight_smile:

Will: there are many good on-line courses etc. Spending a day reading through the help files will benefit you more than posting question after question here. If only because different people will answer using slightly different terminology.

Being from the UK, this is my 0.0105139 pence worth!!

Mike

Subject: RE: I understand Charles’ frustration…

Agree with you Mike.

Lotus - an idea. How about a Newbies forum for new developers to ask what are in all honesty simple questions, then only those who are happy to help them will have to read their posts :slight_smile:

Subject: RE: I understand Charles’ frustration…

Brandt

I take all of your points on board and agree with you on most of them. I am self taught having been involved with Notes since V2.1. I completely agree that the best learning resource is the online help and with a bit of time and effort and maybe a couple of pointers from fellow developers most people should be able to find their way.

I understand that some developers may find it frustrating giving answers to what to us veterans are simple questions. I’ve got an answer to that - don’t answer them if you don’t want to give advice! :slight_smile:

All IMHO of course

Pete

Subject: RE: I understand Charles’ frustration…

Not having a clue what you’re doing is one thing, but this is something else entirely. In every post Will has made he says he doesn’t have the time to read the help or it would be easier if people could just give him examples. Ever heard the parable of teaching a man to fish?

Subject: RE: I understand Charles’ frustration…

There’s an interesting read on something called ‘tacit knowledge’ over at Infowold http://www.infoworld.com/article/05/06/15/25OPstrategic_1.html This fits in pretty well with this thread.

I’m struggling with ‘how not to appear stupid’ now over in the DB2 forum. I know a bit about dbs, a bit about linux, a bit about a lot of stuff, but am floundering trying to get DB2 Express-C set up on my home Mandriva 2007 box. I’ve searched the forum, the wiki, googled, you name it and it’s just not adding up. So do I post a noob question and risk having my rear handed to me because I missed the ‘simple’ answer that requires tacit knowledge or do I just whang it out there and hope for the best? (*)

On the other hand, if I just started in posting ‘how do I install Linux’, ‘how do I download DB2’, ‘how do I toast my bread’ kinds of questions, I think I deserve to be flamed into submission (and that handles the toasted bread problem).

Given that every person has a different learning style, I’m not sure there is a ‘right’ way to handle the Wills of the world. I think, for me, I assume no tacit knowledge and then give 'em a fishing pole (link to a search or good resource) and hope that they’re able to develop the underpinnings of explicit knowledge. When I’m tempted to respond aggressively, I try and either just skip the post or put up a link and leave. The few times I just let it fly it wasn’t good for me, the poster, or the forum.

Side bar issue on this particular user: Will claims not to have funds to acquire the necessary resources (books, classes, etc). Unless I missed something, the Notes developer client is pretty darned expensive for somebody just playing around (reason I don’t have a personal copy at home). If I’d just plunked down the entry price for the developer and client licenses, I think I’d be able to spend another $50 at Amazon or Borders for some books. Will, you DID actually buy the designer client, right??? You do understand that the penaties for software piracy are really high ($50,000 fine per copy last time I checked)?? If your company provided you with the software, ask them to provide training otherwise they’ve wasted their investment.

FWIW, this problem isn’t unique to this forum. I believe this forum handles Wills with much more kindness than I see in other places.

Will, if you really want to learn, realize that programming is a skill that requires you spend time working on - it cannot be passed along ‘by example’. Pick a simple problem, start writing code, debug the code, then write some more, then rethink what you’re doing, then ask for some help.

Doug

(*) The DB2 Express forum has been ever so kind to my postings so I’m either asking in the right way or they are WAY patient.

Subject: RE: I understand Charles’ frustration…

Charles,

Screw the fish…if I am doing your work for you, I want part of your paycheck! haha.

brandt

Subject: RE: I understand Charles’ frustration…

I do understand what you are saying Charles. I remember whan I was starting out there was no such thing as notes.net and we had to rely completely on the online help - still the best LotusScript resource available as far as I’m concerned. Guess I was lucky in that I was working for an organisation which already had some LotusScript enabled apps so I was able to see through some examples of how a function should be structured, etc. I’ve got no prob passing on the odd hints to a beginner no matter what their reason for asking. If I get sick of the same person continually asking trivial questions, I simply won’t answer them any more! :slight_smile:

Subject: RE: I understand Charles’ frustration…

Pete,

I think the problem Charles is having is that the attitude is more “do my work for me” and less “show me a direction.” I think all of us agree that we are willing to help someone who has shown that they have tried to use the resources available BEFORE asking a question. In this instance, that was obviously not the case.

and notice that did not stop me from helping him either.

brandt

Subject: RE: I understand Charles’ frustration…

Brandt

I did indeed noticed that and for what it’s worth, I also noticed that your answer was a lot clearer and better explained than mine :slight_smile:

Pete

Subject: RE: Newbie on lotusscript: Help on my button to times value by 3%

Tq Pete,

I noticed most posting come with the following paragraph, and I always get error message, I tried to put commas or delete it and left with the word function, but still there is problem

Function addThreePercent(yearFieldValue as Double) As Double

Just to share with you:

Following is the exact script in my button:

Sub Click(Source As Button)

Dim tempDouble1, tempDouble2 As Double

tempDouble1 = addThreePercent(Cdbl(document.fieldA(0)))

tempDouble2 = addThreePercent(Cdbl(document.fieldb(0)))

End Sub

Function addThreePercent(yearFieldValue As Double) As Double

addThreePercent= yearFieldValue * 1.03 ' decimal equivalent of 3 percent End Function

End Function

This is the error message

addThreePercent (5) illegal duplicate End Statement

I am still reseaching to understand what does this error message means, hopefully it will not take me too many days to comprehend what is the issue and how to overcome it.

btw, what does IMHO means? don’t understand when you said shade harsh IMHO

ps: is there a way to be able to copy the error message from designer?