< Back

Document Subject: Golden Rule No5: Space out @if statements
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#GR5 or http://A555F9/nn.nsf/ByAlias/GR5

In Notes R3 this couldn't be done, but in R4 and R5 it can be and should be.




What is easier to read / understand / debug?

   This:

DBName := @Implode(@Explode(@Subset(@DbName;-1);"\\");"/");
@Command([FileSave]);
@Command([ToolsRunMacro]; "(UpdateFTIndex)");
@If(@ClientType="Web" & @IsNewDoc;
      @Command([OpenNavigator];Section);
@ClientType="Web" & ReadersDescriptive!="Anyone who can access the database.";
     @URLOpen("/" + DBName+"/int/GoBack4" );
@ClientType="Web";
    @URLOpen("/" + DBName+"/int/GoBack3" );
    @PostedCommand([FileCloseWindow])
)

 

     or this:

 

DBName := @Implode(@Explode(@Subset(@DbName;-1);"\\");"/");
@Command([FileSave]);
@Command([ToolsRunMacro]; "(UpdateFTIndex)");
@If(@ClientType="Web" & @IsNewDoc; @Command([OpenNavigator];Section);@ClientType="Web" & ReadersDescriptive!="Anyone who can access the database.";@URLOpen("/" + DBName+"/int/GoBack4" );@ClientType="Web";@URLOpen("/" + DBName+"/int/GoBack3" ); @PostedCommand([FileCloseWindow]))

 

It is the same code but is just displayed with spaces and extra return lines.

I rest my case.

Rule of thumb stick an extra carriage return in whenever there is a ";" or a bracket at the end of a line, not inside an @formula or as part of an @formula.

Try and indent the result of the @if.

e.g.

@if( condition1;
         do this;
 condition2;
         do this;
 condition3;
         @do(
             do this ;
             and this
          );
  else do this
)