PreviousNext…

What we take for granted

As Notes developers, I think we sometimes take for granted a lot of the stuff the product offers us. For example, I was coding a Lotusscript agent yesterday in release 5, and my head was so stuck in "Java land" that I started looking at using a custom class or function for "exploding" a string. in other words, the script equivalent of the StringTokenizer Java class. What a doofus! Of course, Notes 6 offers the developer a function for this (StrToken) which I've used before… but then suddenly, after grabbing Johan's excellent code, I slapped myself upside the head, and did this:


Const K_MACRO = {@Explode(txtDeptStructure; "\\")}
varStructures = Evaluate(K_MACRO, doc)

Update: In the end I used an explodeString function. I had to, as I had a need to tokenize some string variables generated by the code in addition to the field value above. Oh well. The code works well. And it's recursive! I love recursion <insert geek joke here >.

Comments

  1. Just be aware of the following caveat: linkjohn marshall#
  2. Thanks John, yeah the code I posted is working code in an app that needs to explode using the "\" char. That's why I have it doubled up, 'cause as we know, it's an escape character in Notes. So I had to escape the escape…
    ;-)Ben Poole#
  3. R6 has a built in Explode LotusScrip functionjake#
  4. You are right Ben, But beyond just the tokenizer stuff I want to remark the great approach we can take of the Evaluate statement (both in LotusScript and Java), since it give us the power of the @Formulas in a snap. That is one of my favorite LotusScript and Java statements, and I use it frequently. In fact I always have something like:

    Dim myF as string
    
    Dim myEv as variant
    
    myf = {some formula, from @DBLookups to
    some other usefull stuff}
    
    myEv  = Evaluate(myF)
    

    Obviously I use the doc parameter when you want to evaluate the @Formula against a particular document. Very useful .
    ::AleX::.
    Dominocode.Net

    Alex Hernandez#
  5. Jake, you mean Split yeah? Alex, agreed, Evaluate is very useful. I always used to shy away from it on account of the horrendous memory leaks in r4.x, but now it's great stuff.Ben Poole#

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";