Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • Lotus Notes and Domino Application Development wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.0
  • 6.5
  • 8.0
  • 8.5
  • 8.5.1
  • 8.5.2
  • 8.5.3
  • action bar
  • Agents
  • Ajax
  • app dev
  • Application
  • beginner
  • C&S
  • calendaring and scheduling
  • client
  • composite applications
  • Controls
  • converters
  • css
  • Custom controls
  • Data Binding
  • db2
  • design elements
  • dialog boxes
  • Documents
  • Dojo
  • Domino
  • Domino Designer
  • Domino Designer 8.5
  • DXL
  • Eclipse
  • error handling
  • errors
  • extensions
  • FAQ
  • Forms
  • formulas
  • getting started
  • globalization
  • Help
  • html
  • Installation
  • interface
  • internationalization
  • iPhone
  • Java
  • JavaScript
  • localization
  • Lotus Domino Designer
  • LotusScript
  • LotusSphere
  • LotusTechInfo
  • menu bar
  • Mobile
  • new user
  • Notes
  • Notes 8
  • notes.ini
  • NSD
  • OpenNTF
  • partial update
  • performance
  • Pickers
  • Portal
  • presentations
  • programming
  • Redbooks
  • Requested Articles
  • roadmap
  • rooms and resources
  • samples
  • Scripting
  • security
  • tabs
  • templates
  • themes
  • Tips
  • toolbar
  • troubleshooting
  • tutorials
  • validation
  • variables
  • video
  • VideoFest
  • View
  • view control
  • ViewPanel
  • Views
  • web
  • Web apps
  • Web services
  • webdev
  • XML
  • Xpage
  • XPages
  • XPages Extensibility API
  • xsp-config
  • データソース
  • 九州地区ノーツパートナー会
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Formula Language > Indenting formula language for better readability
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Indenting formula language for better readability 

expanded Abstract
collapsed Abstract
Proposal for indentation rules in nested commands to drastically improve readability
ShowTable of Contents
HideTable of Contents
  • 1 Introduction
  • 2 Proposed coding rules
  • 3 Examples
  • 4 Conclusion

Introduction

Formula language programming has a tendency to create horrificly unreadable formula code. The designer is not very helpful in (semi) automatic indentation adding to that issue. Still, it is still often the most powerful, fastest and most security abiding way of getting things done. Part of the issue is legacy: in older versions it was not possible to break lines or use tabs. Later on, more nested commands were added (i.e. @For) adding to deep and often unreadable nesting.

 

Proposed coding rules

This document proposes simple coding style rules for @Formula language. It is incomplete and informally written.
 

  1. Every opening parenthesis of a control statement (like @If, @For, @Do, etc) is followed by a newline and a new indentation level;
  2. Indentation is done through the use of tabs;
  3. The corresponding closing parenthesis is on a new line and outdented, usually, but not always followed by the closing semicolon. Caveat: no semicolon on the previous line!;
  4. Special case for @If: all even arguments get their own extra indentation, making them easily identifiable to their corresponding condition;
  5. Special case for @For: keep arguments 1, 2 and 3 on one line, as those are controlling the loop.

Examples

	@If(
	    choice = 1;
	       @Setfield("Approved";"Yes");
	    choice = 2;
	       @Setfield("Approved";"No");
	    @Return("")
	);
	



	@If(
	   choice = 1;
	      @Do(
	          @Setfield("Approved";"Yes");
	          @Setfield("ApprovedBy";@Username)
	      );
	   @Return("")
	);
	



	@For(
	    n := 1; n <= 10; n++;
	       result := result + array [n]
	);

	

 

Conclusion

While this coding style created far more lines than free coding, the end result is extremely readable and easily nested.


expanded Article information
collapsed Article information
Category:
Formula Language
Tags:
Formula language, layout

This Version: Version 5 January 18, 2012 11:23:02 AM by Jeroen Meijer  

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (5)
collapsed Versions (5)
Version Comparison     
Version Date Changed by               Summary of changes
This version (5) Jan 18, 2012 11:23:02 AM Jeroen Meijer  
4 Jan 18, 2012 11:21:07 AM Jeroen Meijer  
3 Jan 18, 2012 11:20:13 AM Jeroen Meijer  
2 Jan 18, 2012 11:15:44 AM Jeroen Meijer  
1 Jan 18, 2012 11:08:02 AM Jeroen Meijer  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use