logo

More Notes Annoyances

screengrab Here's another LotusScript headache from my past week of coding. It's not like I was doing any power-coding or anything. So why do I seem to have so many issues? Am I just a bad coder maybe? Imagine the simple code below:

Dim doc1, doc2 As NotesDocument
Call doc2.MakeResponse(doc1)

Obviously there are some lines missing to set the variables. Still, nothing special. So, why did I get the following error when it ran:

68: Type Mismatch on DOC1

Because I needed to declare the document variables on separate lines, like so:

Dim doc1 As NotesDocument
Dim doc2 As NotesDocument
Call doc2.MakeResponse(doc1)

Needless to say it took me ages to work that one out. It's one thing being able to spot logic errors in code. It's another being able to guess the illogical errors in LotusScript

screengrabHere's another error Notes threw my way recently when trying to open a certain design element:

No prizes for guessing what kind of element I was trying to open. Words can't describe how annoying this was. I had to delete it and start again!

Anyway, I promised myself I'd stop being so down about Notes. Sometimes I just can't help. This blog is my couch and you're my shrink. I feel better now. Same time next week?

Comments

    • avatar
    • Alexandre
    • Thu 24 Mar 2005 08:21

    The type declaration annoyance is not specific to LotusScript. You would have the same problem if you'd be using the VBA language.

    {Link}

  1. You can still use one line with:

    Dim doc1 As NotesDocument, doc2 As NotesDocument

    Cannot say it ever annoyed me though. I like to type my variables.

    • avatar
    • veer
    • Thu 24 Mar 2005 08:28

    err....i tried the same code but am not getting an error. i didnot call the save method after the makeresponse line as i was doing quick and dirty testing.

    i know i have done similar stuff before without problems. i normally go with

    Dim doc1 As NotesDocument, doc2 As notesDocument

    but Dim doc1, doc2 as notesdocument should work....

    i get a type mismatch when i do

    Dim doc1, doc2

    Call doc1.MakeResponse(doc2)

    which i can understand, as makeresponse is expecting a document object and doc2 is a vaariant countainer, though it holds a document.

    • avatar
    • yuval
    • Thu 24 Mar 2005 08:30

    Dim doc2, doc2 As NotesDocument ???

    Call doc1.MakeResponse(doc2)

    I gues you meant :

    Dim doc1, doc2 As NotesDocument

    ...

    Call doc1.MakeResponse(doc2)

    and this (at list in R7 Beta 3) will work.

    Dim s As New notessession

    Dim db As NotesDatabase

    Dim doc1, doc2 As NotesDocument

    Set db=s.CurrentDatabase

    Set doc2=New NotesDocument(db)

    doc2.form="DeleteMe"

    doc2.Save False,False

    Set doc1=New NotesDocument(db)

    Call doc1.MakeResponse(doc2)

    Msgbox doc1.getitemvalue("$REF")(0)

  2. I've run into this in the past. When you declare

    dim doc1, doc2 as NotesDocument

    for some reason Notes only picks up the doc2 as NotesDocument. It automatically assigns doc1 as a variable and not a document. It works this way on all assignments, views...documents...rtf's whatever.

    • avatar
    • Blop
    • Thu 24 Mar 2005 08:54

    Corey,

    Read Alexandre's comment above. This isn't specific to Notes (or more accurately LotusScript).

    More a case of RTFLM.

    P.S. LM = Language Manual

    • avatar
    • Jake Howlett
    • Thu 24 Mar 2005 09:17

    I thought that you could declare variables this way? e.g:

    Dim s1, s2, s3 as String

    Would that not result in three string variables? Do they all have to be "typed" explicitly or not?

    If it's documented that it doesn't work then why does it work for Yuval and Veer?

  3. No -- only variables followed immediately by "As Type" will be anything other than a Variant. That's the same behaviour one gets in Visual Basic up to VB6.

    veer's syntax was:

    Dim doc1 As NotesDocument, doc2 As NotesDocument

    Note that while both appear in the same Dim statement, they both have their own "As Type" clause. Yuval was working in ND7, and the behaviour may have changed, but I doubt it -- a lot of code would break if things that had previously been Variants were recompiled as typed values. One of the big selling features of VB.NET was that your declaration statement would finally result in two NotesDocuments, but Microsoft's upgrade translator would have translated your declaration statement to:

    Dim doc1 As Object

    Dim doc2 As NotesDocument

    ("Object" is the new .NET Variant.)

    • avatar
    • yuval
    • Thu 24 Mar 2005 09:42

    it end up with one variant and one document and you can use the variant as document unless you try to put him in a function that get document type only, this is why it will work for:

    call doc1.makeresponse(doc2)

    and not for

    doc2.makeresponse(doc1)

    becuase the way you declared it is

    doc1, (variant) doc2 as notesdocument.

    As far as i know - same in VB too.

    • avatar
    • veer
    • Thu 24 Mar 2005 09:56

    Jake,

    You might want to verify one thing. In your code you would not get the error if your call was:

    1)

    Dim doc1, doc2 As NotesDocument

    Call doc1.MakeResponse(doc2)

    However, you will get an error if you did:

    2)

    Dim doc2, doc1 As NotesDocument

    Call doc1.MakeResponse(doc2)

    Since the code you pasted in your blog has both as doc2s...( which lotuscript compiler won't let you compile, hence i guess is a typo when you were putting in this blog ), you need to check if you did 1 or 2 ).

    Hope this helps.

    • avatar
    • Jake Howlett
    • Thu 24 Mar 2005 09:57

    Woops. Fixed a typo in the main post.

    Ok, I've learnt something today. Another painful lesson. I'm too saw from yesterday's flogging to repeat that. Today's was painful by virtue of public humiliation.

    Talking of RTFM. Show me the line in TFM (Notes Designer Help that is) that tells me about this!

    • avatar
    • John Palmer
    • Thu 24 Mar 2005 10:07

    Jake:

    I remember seeing that Notes will ONLY type the var that precedes the type definition and everything else is typed as a string. That's why

    dim str1, str2, str3 as String works with no problem.

  4. It's on the document entitled "Declaring scalar variables explicitly" in the LotusScript Language section, and may live elsewhere.

  5. @John: Nope -- everything that's missing an "As Type" clause (or a suffix, if you're into perversions) will be a Variant. Your statement works because Variants can contain strings.

    • avatar
    • Mike
    • Thu 24 Mar 2005 10:18

    Jake -

    About your "Not a Form" error ....

    There is a bug in 6 whereby a form can become corrupt and lose the fields that tell it it's a form. Had this happen a few months back and lost a few days worth of work. Now, if I have a complex form I try to put as much as possible on subform(s).

    -- Mike

    • avatar
    • Corey Kimball
    • Thu 24 Mar 2005 10:29

    @Blop. Thanks for the feedback. I'm coming at this from a "Notes" developer standpoint. I didn't do any coding prior to Notes.

    Jake

    About the "Not a Form" error. I had this problem recently as well. I found some info on the IBM website after googling it. My problem turned out to be that I was trying to embed the same subform on two other subforms.

    I had some navigation set up on a subform. I wanted to display it on the left side one way (with css) and at the bottom of the page/form another way. Didn't want to have to make changes twice in the future so I thought I could enter the nav on one subform, and then embed that subform in two seperate subforms.

    Anyway, when I included the subform for the left navigation, and then the subform for the bottom navigation, it choked and I got the error message that you referenced.

    It was because the main form now contained the navigation subform in two separate places.

    It allowed me to save the form once, but when I tried to open the form again, I got the error. Had to delete the form and start again.

  6. I just encountered the "Not a Form" error earlier this week. Apparently I shouldn't have cut a subform from within a form and placed it into another subform on the same form. There's not a good reason for doing what I was doing but I did it without error. It wasn't until after I saved and closed the other forms, using the modified subform, that I received the error.

    I've recently been working with VisualStudio.Net and don't encounter near as many headaches when developing. There are also tons of features, style sheet editor to name one, in VS.Net that the Lotus Domino Designer doesn't give us.

    • avatar
    • Jake Howlett
    • Thu 24 Mar 2005 10:47

    Thanks Stan. You really are a big know-it-all aren't you ;o)

    I'm just going to quit while I'm ahead now. That's enough embarrassment for one day.

  7. Jake, I know it's there because I went through a similar (but not quite so public, thank the Big Guy) "learning experience" myself a while back. Oooh, much fun was had at the expense of Stan that day....

    • avatar
    • One of the shrinks
    • Thu 24 Mar 2005 12:32

    Syntax

    { Dim | Static | Public | Private } variableDeclaration [ , variableDeclaration ]...

    type

    Optional for scalar variables, lists, and arrays. A valid LotusScript data type, user-defined data type, user-defined class, or product class. This specifies the type of variableName.

    Specifying the data type

    Either dtSuffix or As type can be specified in variableDeclaration, but not both. If neither is specified, the data type of variableName is Variant.

    (It applies to variableName not variableNames)

    Zist iz vahts in ze help file! See you next week. :)

  8. Thanks for sharing your frustration.

    Made us all have a good laugh.

    I usually follow such days, with a lot of swearing and yelling, "Stupid Notes!".

    Keep up the good work.

  9. We all know Notes is frustrating. That caused me to take up Oracle a few years ago.

    All I can say is, if you think Notes is frustrating... you ain't seen nothin'

    I think it's time we all realised that despite it's frustrations and limitations, Notes is still wonderful stuff. Ray Ozzie and Co hit upon some wonderful ideas whose time had come: replication, security, a flexible application platform coupled with excellent comms.

    More than that, it's time WE started to lead the revival, to stop apologising because Notes is not new and trendy. Let's get out there ahead of IBM and talk it up. I'm game.

    Regarding it not being new and trendy - the windscreen wiper isn't either - it's been around for over 80 years now and has still not been bettered.

    Having said that... I know what you mean... in my case I swear at tables every time I attempt to use them - been doing so for 15 years now.

  10. Corey:

    <snip>

    It was because the main form now contained the navigation subform in two separate places.

    It allowed me to save the form once, but when I tried to open the form again, I got the error. Had to delete the form and start again.

    </snip>

    Actually, you don't have to start all over; you can just export the entire database to XML, remove the subform from one of the places using a text editor, and re-import the database. Much quicker for the most part.

    • avatar
    • Tom
    • Sun 27 Mar 2005 15:27

    Jake,

    Dim doc1 as NotesDocument,

    Dim doc2 as NotesDocument

    you should use this form anyway, as in class declaration (eg public doc1 as NotesDocument)

    you won't be able to use public doc1, doc2 as NotesDocument or similar too.

    Cheers, Tom

  11. Jake,

    Working between Java and Lotuscript always throws problems like this for me as well.

    private MyObject obj1, obj2, obj3;

    This works fine in Java but as you saw not in lotusscript. I know the languages are obviously very different but it still takes me a while to get my head back into the groove of whatever I am programming!

    Jason

    • avatar
    • John Palmer
    • Wed 30 Mar 2005 10:49

    @Stan: DUH, I know that, I know that, I know that. (untyped are variants) I have NO idea why I said 'strings'. Must have been a brain fog rolling in that day. Thanks for keeping me honest. :)

    • avatar
    • Lake
    • Wed 30 Mar 2005 15:52

    RE: "Not a Form" error

    Most of the 'corrupted design -- now start over' experiences I have had in the past have been as a result of complicated arrangements of embedded subforms.

    Now I use computed subforms in place of embeds almost anytime I use subforms and I find it to be much more stable.

    (Loved the holiday story, by the way)

  12. Always computed subforms in favour of regular subforms? Sounds like a great performance killer to me.

    • avatar
    • Lake
    • Wed 30 Mar 2005 16:30

    Subforms in general can slow things down a little; but I haven't seen that the performance difference with computed subforms is worth bothering about.

    cheers.

  13. What to do with the "Not a form" message?

    If its not a form but a document, why is it registered under 'Forms' ?

  14. Hi

    Its an issue related to "Using Database" Document or "About database" document under database Resources.. So uncheck the "Show About database" property from database launch tab.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 24 Mar 2005

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content