Link to home
Start Free TrialLog in
Avatar of RanjeetRain
RanjeetRain

asked on

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!!!!
SOLUTION
Avatar of madheeswar
madheeswar
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sjef Bosman
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.
Avatar of RanjeetRain
RanjeetRain

ASKER

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...  :-#
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 :-/
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Mady, I thought you changed job again. Is that true?

Ok, I have an offer for you. Come join my team. Interested?
Anyone need my CV?
Hmmm... thats interesting... lemme take a look at that :-B
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 :>
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?
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)


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...
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.
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.
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!!!




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 :-#
We have no immediate plans of opening a center in Europe. C'mon you guys don't want Indian software professionals there, do you ;-)
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?
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 ;)
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.
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 :)

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.
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.