Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

Funny but true

TestObject.CreateLogEntry("Hello World!")
TestObject.CreateLogEntryWithContext "Hello", " World!"

I wouldn't expect the first line to work, but it does. When I write the second line the same way it doesn't. Can anybody enlighten me as to why this might happen?

TestObject.CreateLogEntry("Hello World!")
TestObject.CreateLogEntryWithContext("Hello", " World!")

2nd line doesn't work. Says iliegal use of parenthesis. The first works.

And most funny -

TestObject.CreateLogEntryWithContext"Hello", " World!"

works too!!!!
0
RanjeetRain
Asked:
RanjeetRain
3 Solutions
 
madheeswarCommented:
I am not sure about it.

Send your CV to may email Ranjeet.
Have a nice weekend
0
 
HappyFunBallCommented:
I've seen this problem ever since I first started programming in Lotusscript.  If you use the 'Call' statement, that 2nd line will work:

Call TestObject.CreateLogEntry("Hello World!")
Call TestObject.CreateLogEntryWithContext("Hello", " World!")

Wish I could explain why this happens, but I just chalk it up with all the other idiosyncrasies in Domino.
0
 
Sjef BosmanGroupware ConsultantCommented:
Is not funny, Notes sucks!

Explanation:
either use
    Call name(param1, param2)
or
    name param1, param2

If you omit Call, then Notes assumes the second method. If it encounters a (, then it expects a parameter that is a valid expression. Now, (param1, param2) is NOT a valid expression in LS!

Be happy you found out like this, I have been staring at the following problem:

    Sub Sort(a As Variant) ' some Array
    ... 'results written back in a
    End Sub

I called the sub with
    Sort(array)
and the results were the original array. It took me HOURS to find out why.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
RanjeetRainAuthor Commented:
LOL.... Funnunnyyyy Notesss

I know what you guys mean. But that's funny. I of course know the usage of the call statement and how it differs. But I was wondering how it could be acceptable. It didn't puzzle me if the 2nd line didn't work. I knew it was wrong usage, but first line working!!!!!!!! That sent me into tizzy :o)

I just came across this accidentally when I was doing some testing on parsing. Jeff, do you remember I was talking about LS parsing tool in one of my threads earlier? Oh, well! I am sorry! But, if this is how Notes behaves then I would rather invest my time on something else...  :-#
0
 
RanjeetRainAuthor Commented:
HFB.. you didn't get the funny side of it. See the line below:

TestObject.CreateLogEntry("Hello World!")

That should NOT work, should it? But it does :-/
0
 
Sjef BosmanGroupware ConsultantCommented:
The difference between
    Dim a As Integer

    a= 4
   
    Sub1 a
    Sub2 (a)
    Call Sub3(a)
    Call Sub4((a))

is that the call to Sub2 is equivalent to the call to Sub4! The value a is passed by value, because of the parentheses!
0
 
RanjeetRainAuthor Commented:
Mady, I thought you changed job again. Is that true?

Ok, I have an offer for you. Come join my team. Interested?
0
 
Sjef BosmanGroupware ConsultantCommented:
Anyone need my CV?
0
 
RanjeetRainAuthor Commented:
Hmmm... thats interesting... lemme take a look at that :-B
0
 
RanjeetRainAuthor Commented:
LOL... want a salary in Rupees? You are welcome ;-) They say - heaven is when you have an American salary.... blah blah blah.... and an Indian wife.... hell is when you have an American wife... blah blah blah.... and an Indian salary.... LOL

But not that bad either... software guys make loads of money in India too :>
0
 
Sjef BosmanGroupware ConsultantCommented:
About your saying: that explains Partha's seventh heaven probably :D

> ... loads of money...

Is that literally? Truckloads of Rupee paper? What's the going rate against the US-Dollar? Or the Euro? And what's your offer I cannot refuse?
0
 
RanjeetRainAuthor Commented:
Partha's heaven... oh yeah ;)

Don't go for the going rate. It is long time before you can compare Rupee with Dollar or Euro :|

Offer would be - take it or leave it - My salary + 100K Rupees (Bonus for Non-indians)


0
 
Sjef BosmanGroupware ConsultantCommented:
100K bonus monthly or yearly? And I can stay here (for I have no intention to move)? Real Internet business? On a per project basis? Hmmm...
0
 
RanjeetRainAuthor Commented:
Sorry, we do not outsource... if you are willing to come here then only... yes you may get a chance in other offices of ours if the comapny "likes" you.
0
 
Sjef BosmanGroupware ConsultantCommented:
Development centres in US/India/Australia? No France? Sorry, I'll have to look around for a while...

Thanks for the offer!

By the way, happy with the explanation I gave? I can tell you that it was absolutely NOT funny at the time. When I finally found what was wrong, I could have kicked my own behind for being so stupid.
0
 
RanjeetRainAuthor Commented:
Oh I cracked it. Designer help long live :o)

(  )      (parentheses)

      (1) Groups an expression, controlling the order of evaluation of items in the expression.
      (2) Encloses an argument in a sub or function call that should be passed by value.
      (3) Encloses the argument list in function and sub definitions, and in calls to functions and subs.
      (4) Encloses the array bounds in array declarations, and the subscripts in references to array elements.
      (5) Encloses the list tag in a reference to a list element.



As per the rule #2, my first statement -- TestObject.CreateLogEntry("Hello World!") -- is legal. Why then the second one -- TestObject.CreateLogEntryWithContext("Hello", " World!") -- is not? The answer is, in the second statement LS compiler applies the rule #3.

So, the solution? The solution is to - enclose all the parameters in parenthesis separately. Now, that's nice isn't it!

TestObject.CreateLogEntryWithContext("Hello"), (" World!")    ' -- Works!!!




0
 
RanjeetRainAuthor Commented:
behind??? you mean to say b-u-t-t? ha ha ha... see you are increasing the work for CRAK ;-)

Btw, what did you finally find out :-#
0
 
RanjeetRainAuthor Commented:
We have no immediate plans of opening a center in Europe. C'mon you guys don't want Indian software professionals there, do you ;-)
0
 
Sjef BosmanGroupware ConsultantCommented:
You didn't see my post about a=4? It implies your rules. And I was talking about finding out why my Sort didn't work. Did you figure that one out by now?
0
 
RanjeetRainAuthor Commented:
I did notice your a=4. Though that didn't help me much. I read it and shrugged. Reading the rules made all the difference. I could immediately sort out my problem applying these rules ;-)

Nontheless points still go to you ;)
0
 
Sjef BosmanGroupware ConsultantCommented:
You're a friend :)

About my Sub Sort: sorting worked nicely, I could see that with the debugger. At the end of the sub, everything was in perfect order... and right after the return the unsorted array was still there. Rather annoying.

The way I called it using
    Sort(array)
was in fact equivalent to
    Call Sort((array))
so the array was passed by value to the sub. Which makes it immediately clear that, since the value of the array is passed to the sub, the local value will not be altered.
0
 
RanjeetRainAuthor Commented:
Okay then return my points.. LOL :))

Actually these are those subtle things that go unnoticed! Infact, in case of passing a variable it does make a difference. With Notes variables can be passed both by reference and by value (as long as called function can accept arguments passed by reference).  ANd ( and ) operator enforces that. Difficult to notice, isn't it :)

0
 
Sjef BosmanGroupware ConsultantCommented:
Let's call it a 'feature'...

Notes has more of those seldom-used or hard-to-see features, like the multi-declarations, e.g.
    Dim x, y As NotesDocument ' x=Variant!

Do you ever use
    Dim x List As String
in your code? There must be more, e.g. class-stuff, and Private, just to name a few.
0
 
RanjeetRainAuthor Commented:
Yeah right! And Dim x, y as String is a classic. I have seen even old programmers make this simple mistake. We can say old habbits die hard :)

LS syntax is a little too flexible at times. Probably that's because of the backward/forward  compatibilty that it must maintain with its predecessor languages.
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.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now