C Api: how get formula text from CDFIELD structure

Hi,

I want to get formula text from form’s keyword field and have a problem. What I do:

  1. read a form note into memory (NSFNoteOpen)

  2. read about a “Body$” item (field) in a note to string (NSFItemInfo)

  3. parse CD records and get the CDField record which is keyword field with formula

  4. from CDField get the string which contain formula WHAT I NEED

With this four steps is all right ! :slight_smile:

But the string is in compiled format (in any case I so think) and i don’t know how decompile it. I have trie’d function NSFFormulaDecompile and get error (LotusNotes Designer closed :frowning: ).

Can anyone help me ?

Thanks!

Subject: C Api: how get formula text from CDFIELD structure

Tam, it sounds you are using C API from LotusScript as you “Lotusnotes Designer closed”.

If you show how you use NSFFormulaDecompile we maybe could suggest what’s wrong with your code.

Subject: C Api: how get formula text from CDFIELD structure

NSFFormulaDecompile is correct, as we use it in our Midas Rich Text LSX and Midas Rich Text C++ API. Unfortunately, I can’t give you exact code from those products, but in either you can change the default formula or any of the other field formulas and attributes and actions, so I can assure you that you are on the rich track.

Subject: RE: C Api: how get formula text from CDFIELD structure

Thank You Ben, for good words ! I found my mistake and as ever he is very simple :slight_smile:

wrong function declaring:

Declare Private Function wNSFFormulaDecompile Lib wAPIModule Alias “NSFFormulaDecompile” _

( pFormulaBuffer As String, fSelectionFormula As Boolean, hM As Long, formulaTextLength As Integer) As Integer

right function declaring:

Declare Private Function wNSFFormulaDecompile Lib wAPIModule Alias “NSFFormulaDecompile” _

( Byval pFormulaBuffer As String, fSelectionFormula As Boolean, hM As Long, formulaTextLength As Integer) As Integer

Can I ask one more question ? I don’t understand how to parse CDFIELD record attribute Flags :frowning:

For example, I have Flags attribute with value:

              first byte -> 8A  

              second byte -> 00

In result have 0x8A00

In api documentation I found what meanings can have flags attribute and no one of this not correct for me.

/* CDFIELD Flags Definitions */

#define V3SPARESTOCLEAR 0x0075 /* Clear these if FOCLEARSPARES is TRUE */

#define FREADWRITERS 0x0001 /* Field contains read/writers */

#define FEDITABLE 0x0002 /* Field is editable, not read only */

#define FNAMES 0x0004 /* Field contains distinguished names */

#define FSTOREDV 0x0008 /* Store DV, even if not spec’ed by user */

#define FREADERS 0x0010 /* Field contains document readers */

#define FSECTION 0x0020 /* Field contains a section */

#define FSPARE3 0x0040 /* can be assumed to be clear in memory, V3 & later */

#define FV3FAB 0x0080 /* IF CLEAR, CLEAR AS ABOVE */

#define FCOMPUTED 0x0100 /* Field is a computed field */

#define FKEYWORDS 0x0200 /* Field is a keywords field */

#define FPROTECTED 0x0400 /* Field is protected */

#define FREFERENCE 0x0800 /* Field name is simply a reference to a shared field note */

#define FSIGN 0x1000 /* sign field */

#define FSEAL 0x2000 /* seal field */

#define FKEYWORDS_UI_STANDARD 0x0000 /* standard UI */

#define FKEYWORDS_UI_CHECKBOX 0x4000 /* checkbox UI */

#define FKEYWORDS_UI_RADIOBUTTON 0x8000 /* radiobutton UI */

#define FKEYWORDS_UI_ALLOW_NEW 0xc000 /* allow doc editor to add new values */